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

231 lines
11 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockRailBase.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRailBase.java
@@ -34,7 +34,7 @@
public static boolean func_176563_d(IBlockState p_176563_0_)
{
Block block = p_176563_0_.func_177230_c();
- return block == Blocks.field_150448_aq || block == Blocks.field_150318_D || block == Blocks.field_150319_E || block == Blocks.field_150408_cc;
+ return block instanceof BlockRailBase;
}
protected BlockRailBase(boolean p_i45389_1_)
@@ -57,7 +57,7 @@
public AxisAlignedBB func_185496_a(IBlockState p_185496_1_, IBlockAccess p_185496_2_, BlockPos p_185496_3_)
{
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = p_185496_1_.func_177230_c() == this ? (BlockRailBase.EnumRailDirection)p_185496_1_.func_177229_b(this.func_176560_l()) : null;
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = p_185496_1_.func_177230_c() == this ? getRailDirection(p_185496_2_, p_185496_3_, p_185496_1_, null) : null;
return blockrailbase$enumraildirection != null && blockrailbase$enumraildirection.func_177018_c() ? field_190959_b : field_185590_a;
}
@@ -73,7 +73,7 @@
public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_)
{
- return p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_185896_q();
+ return p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).isSideSolid(p_176196_1_, p_176196_2_.func_177977_b(), EnumFacing.UP);
}
public void func_176213_c(World p_176213_1_, BlockPos p_176213_2_, IBlockState p_176213_3_)
@@ -93,27 +93,27 @@
{
if (!p_189540_2_.field_72995_K)
{
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_189540_1_.func_177229_b(this.func_176560_l());
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = getRailDirection(p_189540_2_, p_189540_3_, p_189540_2_.func_180495_p(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_2_.func_180495_p(p_189540_3_.func_177977_b()).isSideSolid(p_189540_2_, p_189540_3_.func_177977_b(), EnumFacing.UP))
{
flag = true;
}
- if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !p_189540_2_.func_180495_p(p_189540_3_.func_177974_f()).func_185896_q())
+ if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !p_189540_2_.func_180495_p(p_189540_3_.func_177974_f()).isSideSolid(p_189540_2_, p_189540_3_.func_177974_f(), EnumFacing.UP))
{
flag = true;
}
- else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !p_189540_2_.func_180495_p(p_189540_3_.func_177976_e()).func_185896_q())
+ else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !p_189540_2_.func_180495_p(p_189540_3_.func_177976_e()).isSideSolid(p_189540_2_, p_189540_3_.func_177976_e(), EnumFacing.UP))
{
flag = true;
}
- else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !p_189540_2_.func_180495_p(p_189540_3_.func_177978_c()).func_185896_q())
+ else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !p_189540_2_.func_180495_p(p_189540_3_.func_177978_c()).isSideSolid(p_189540_2_, p_189540_3_.func_177978_c(), EnumFacing.UP))
{
flag = true;
}
- else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !p_189540_2_.func_180495_p(p_189540_3_.func_177968_d()).func_185896_q())
+ else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !p_189540_2_.func_180495_p(p_189540_3_.func_177968_d()).isSideSolid(p_189540_2_, p_189540_3_.func_177968_d(), EnumFacing.UP))
{
flag = true;
}
@@ -154,7 +154,7 @@
{
super.func_180663_b(p_180663_1_, p_180663_2_, p_180663_3_);
- if (((BlockRailBase.EnumRailDirection)p_180663_3_.func_177229_b(this.func_176560_l())).func_177018_c())
+ if (getRailDirection(p_180663_1_, p_180663_2_, p_180663_3_, null).func_177018_c())
{
p_180663_1_.func_175685_c(p_180663_2_.func_177984_a(), this, false);
}
@@ -166,8 +166,101 @@
}
}
+ //Forge: Use getRailDirection(IBlockAccess, BlockPos, IBlockState, EntityMinecart) for enhanced ability
public abstract IProperty<BlockRailBase.EnumRailDirection> 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(IBlockAccess world, BlockPos pos)
+ {
+ return !this.field_150053_a;
+ }
+
+ /**
+ * 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(IBlockAccess 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 EnumRailDirection getRailDirection(IBlockAccess world, BlockPos pos, IBlockState state, @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(World world, net.minecraft.entity.item.EntityMinecart cart, BlockPos pos)
+ {
+ 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(World world, net.minecraft.entity.item.EntityMinecart cart, BlockPos pos)
+ {
+ }
+
+ /**
+ * Rotate the block. For vanilla blocks this rotates around the axis passed in (generally, it should be the "face" that was hit).
+ * Note: for mod blocks, this is up to the block and modder to decide. It is not mandated that it be a rotation around the
+ * face, but could be a rotation to orient *to* that face, or a visiting of possible rotations.
+ * The method should return true if the rotation was successful though.
+ *
+ * @param world The world
+ * @param pos Block position in world
+ * @param axis The axis to rotate around
+ * @return True if the rotation was successful, False if the rotation failed, or is not possible
+ */
+ public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
+ {
+ IBlockState state = world.func_180495_p(pos);
+ for (IProperty prop : state.func_177228_b().keySet())
+ {
+ if (prop.func_177701_a().equals("shape"))
+ {
+ world.func_175656_a(pos, state.func_177231_a(prop));
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* ======================================== FORGE END =====================================*/
+
public static enum EnumRailDirection implements IStringSerializable
{
NORTH_SOUTH(0, "north_south"),
@@ -238,6 +331,7 @@
private IBlockState field_180366_e;
private final boolean field_150656_f;
private final List<BlockPos> field_150657_g = Lists.<BlockPos>newArrayList();
+ private final boolean canMakeSlopes;
public Rail(World p_i45739_2_, BlockPos p_i45739_3_, IBlockState p_i45739_4_)
{
@@ -245,8 +339,9 @@
this.field_180367_c = p_i45739_3_;
this.field_180366_e = p_i45739_4_;
this.field_180365_d = (BlockRailBase)p_i45739_4_.func_177230_c();
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_i45739_4_.func_177229_b(this.field_180365_d.func_176560_l());
- this.field_150656_f = this.field_180365_d.field_150053_a;
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = field_180365_d.getRailDirection(p_i45739_2_, p_i45739_3_, p_i45739_4_, null);
+ this.field_150656_f = !this.field_180365_d.isFlexibleRail(p_i45739_2_, p_i45739_3_);
+ this.canMakeSlopes = this.field_180365_d.canMakeSlopes(p_i45739_2_, p_i45739_3_);
this.func_180360_a(blockrailbase$enumraildirection);
}
@@ -438,7 +533,7 @@
}
}
- if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
+ if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH && canMakeSlopes)
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos.func_177984_a()))
{
@@ -451,7 +546,7 @@
}
}
- if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
+ if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST && canMakeSlopes)
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos3.func_177984_a()))
{
@@ -594,7 +689,7 @@
}
}
- if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
+ if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH && canMakeSlopes)
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos.func_177984_a()))
{
@@ -607,7 +702,7 @@
}
}
- if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
+ if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST && canMakeSlopes)
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos3.func_177984_a()))
{