Skip to content

Commit

Permalink
Change calculation of Bounding-Box for Slopes (#27)
Browse files Browse the repository at this point in the history
- commited better .gitignore too
  • Loading branch information
NitroxydeX authored and canitzp committed Sep 11, 2016
1 parent 0258cd0 commit 79159e9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
28 changes: 21 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
/build
/Traincraft-5.iws
/out
/.gradle
/run
/Traincraft-5.ipr
/Traincraft-5.iml
# eclipse
bin
*.launch
.settings
.metadata
eclipse

# idea
out
.idea
*.iws
*.iml
*.ipr

# gradle
build
.gradle

# other
run
lib
12 changes: 9 additions & 3 deletions src/main/java/si/meansoft/traincraft/blocks/BlockTrack.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package si.meansoft.traincraft.blocks;

import java.util.List;

import jline.internal.Nullable;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
Expand All @@ -24,8 +26,6 @@
import si.meansoft.traincraft.track.TrackGrid;
import si.meansoft.traincraft.track.TrackPoint;

import java.util.List;

/**
* @author canitzp
*/
Expand Down Expand Up @@ -195,7 +195,13 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, Bloc
if (tileEntityTrack == null) return FULL_BLOCK_AABB; //Items with NBT data will crash otherwise!
int blockIndex = tileEntityTrack.blockIndex;
double perBlockDiff = 1d / slopeLength;
return new AxisAlignedBB(0, 0, 0, 1, blockIndex * perBlockDiff + perBlockDiff * .5, 1);
// 0.125 is the minimum Bounding-Box-Value for the Tracks. It's identical with
// Vanilla-Rails. 1 is the maximal Bounding-Box-Value. If it's planned it can be changed
// with an int-Value we decide individually on every Slope. For Slopes that are 2-Blocks
// height
return new AxisAlignedBB(0, 0, 0, 1,
Math.max(0.125, Math.min(1, blockIndex * perBlockDiff + perBlockDiff * .5)), 1);

}
return FLAT_AABB;
}
Expand Down

0 comments on commit 79159e9

Please sign in to comment.