ForgePatch/patches/minecraft/net/minecraft/block/BlockRailBase.java.patch

124 lines
6.0 KiB
Diff

--- a/net/minecraft/block/BlockRailBase.java
+++ b/net/minecraft/block/BlockRailBase.java
@@ -37,7 +37,7 @@
}
public VoxelShape func_196244_b(IBlockState p_196244_1_, IBlockReader p_196244_2_, BlockPos p_196244_3_) {
- RailShape railshape = p_196244_1_.func_177230_c() == this ? p_196244_1_.func_177229_b(this.func_176560_l()) : null;
+ RailShape railshape = p_196244_1_.func_177230_c() == this ? getRailDirection(p_196244_1_, p_196244_2_, p_196244_3_, null) : null;
return railshape != null && railshape.func_208092_c() ? field_190959_b : field_185590_a;
}
@@ -50,7 +50,8 @@
}
public boolean func_196260_a(IBlockState p_196260_1_, IWorldReaderBase p_196260_2_, BlockPos p_196260_3_) {
- return p_196260_2_.func_180495_p(p_196260_3_.func_177977_b()).func_185896_q();
+ IBlockState down = p_196260_2_.func_180495_p(p_196260_3_.func_177977_b());
+ return down.func_185896_q() || down.func_193401_d(p_196260_2_, p_196260_3_.func_177977_b(), EnumFacing.UP) == BlockFaceShape.SOLID;
}
public void func_196259_b(IBlockState p_196259_1_, World p_196259_2_, BlockPos p_196259_3_, IBlockState p_196259_4_) {
@@ -67,19 +68,19 @@
public void func_189540_a(IBlockState p_189540_1_, World p_189540_2_, BlockPos p_189540_3_, Block p_189540_4_, BlockPos p_189540_5_) {
if (!p_189540_2_.field_72995_K) {
- RailShape railshape = p_189540_1_.func_177229_b(this.func_176560_l());
+ RailShape railshape = getRailDirection(p_189540_1_, p_189540_2_, p_189540_3_, null);
boolean flag = false;
- if (!p_189540_2_.func_180495_p(p_189540_3_.func_177977_b()).func_185896_q()) {
+ if (!p_189540_1_.func_196955_c(p_189540_2_, p_189540_3_)) {
flag = true;
}
- if (railshape == RailShape.ASCENDING_EAST && !p_189540_2_.func_180495_p(p_189540_3_.func_177974_f()).func_185896_q()) {
+ if (railshape == RailShape.ASCENDING_EAST && !p_189540_1_.func_196955_c(p_189540_2_, p_189540_3_.func_177974_f().func_177984_a())) {
flag = true;
- } else if (railshape == RailShape.ASCENDING_WEST && !p_189540_2_.func_180495_p(p_189540_3_.func_177976_e()).func_185896_q()) {
+ } else if (railshape == RailShape.ASCENDING_WEST && !p_189540_1_.func_196955_c(p_189540_2_, p_189540_3_.func_177976_e().func_177984_a())) {
flag = true;
- } else if (railshape == RailShape.ASCENDING_NORTH && !p_189540_2_.func_180495_p(p_189540_3_.func_177978_c()).func_185896_q()) {
+ } else if (railshape == RailShape.ASCENDING_NORTH && !p_189540_1_.func_196955_c(p_189540_2_, p_189540_3_.func_177978_c().func_177984_a())) {
flag = true;
- } else if (railshape == RailShape.ASCENDING_SOUTH && !p_189540_2_.func_180495_p(p_189540_3_.func_177968_d()).func_185896_q()) {
+ } else if (railshape == RailShape.ASCENDING_SOUTH && !p_189540_1_.func_196955_c(p_189540_2_, p_189540_3_.func_177968_d().func_177984_a())) {
flag = true;
}
@@ -111,7 +112,7 @@
public void func_196243_a(IBlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, IBlockState p_196243_4_, boolean p_196243_5_) {
if (!p_196243_5_) {
super.func_196243_a(p_196243_1_, p_196243_2_, p_196243_3_, p_196243_4_, p_196243_5_);
- if (p_196243_1_.func_177229_b(this.func_176560_l()).func_208092_c()) {
+ if (getRailDirection(p_196243_1_, p_196243_2_, p_196243_3_, null).func_208092_c()) {
p_196243_2_.func_195593_d(p_196243_3_.func_177984_a(), this);
}
@@ -123,5 +124,66 @@
}
}
+ //Forge: Use getRailDirection(IBlockAccess, BlockPos, IBlockState, EntityMinecart) for enhanced ability
public abstract IProperty<RailShape> func_176560_l();
+
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * Return true if the rail can make corners.
+ * Used by placement logic.
+ * @param world The world.
+ * @param pos Block's position in world
+ * @return True if the rail can make corners.
+ */
+ public boolean isFlexibleRail(IBlockState state, IBlockReader world, BlockPos pos)
+ {
+ return !this.field_196277_c;
+ }
+
+ /**
+ * Returns true if the rail can make up and down slopes.
+ * Used by placement logic.
+ * @param world The world.
+ * @param pos Block's position in world
+ * @return True if the rail can make slopes.
+ */
+ public boolean canMakeSlopes(IBlockState state, IBlockReader world, BlockPos pos) {
+ return true;
+ }
+
+ /**
+ * Return the rail's direction.
+ * Can be used to make the cart think the rail is a different shape,
+ * for example when making diamond junctions or switches.
+ * The cart parameter will often be null unless it it called from EntityMinecart.
+ *
+ * @param world The world.
+ * @param pos Block's position in world
+ * @param state The BlockState
+ * @param cart The cart asking for the metadata, null if it is not called by EntityMinecart.
+ * @return The direction.
+ */
+ public RailShape getRailDirection(IBlockState state, IBlockReader world, BlockPos pos, @javax.annotation.Nullable net.minecraft.entity.item.EntityMinecart cart) {
+ return state.func_177229_b(func_176560_l());
+ }
+
+ /**
+ * Returns the max speed of the rail at the specified position.
+ * @param world The world.
+ * @param cart The cart on the rail, may be null.
+ * @param pos Block's position in world
+ * @return The max speed of the current rail.
+ */
+ public float getRailMaxSpeed(IBlockState state, World world, BlockPos pos, net.minecraft.entity.item.EntityMinecart cart) {
+ return 0.4f;
+ }
+
+ /**
+ * This function is called by any minecart that passes over this rail.
+ * It is called once per update tick that the minecart is on the rail.
+ * @param world The world.
+ * @param cart The cart on the rail.
+ * @param pos Block's position in world
+ */
+ public void onMinecartPass(IBlockState state, World world, BlockPos pos, net.minecraft.entity.item.EntityMinecart cart) { }
}