| 1 | package net.minecraft.block;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.util.List;
|
| 5 | import net.minecraft.block.material.Material;
|
| 6 | import net.minecraft.block.properties.IProperty;
|
| 7 | import net.minecraft.block.state.IBlockState;
|
| 8 | import net.minecraft.creativetab.CreativeTabs;
|
| 9 | import net.minecraft.init.Blocks;
|
| 10 | import net.minecraft.util.AxisAlignedBB;
|
| 11 | import net.minecraft.util.BlockPos;
|
| 12 | import net.minecraft.util.EnumFacing;
|
| 13 | import net.minecraft.util.EnumWorldBlockLayer;
|
| 14 | import net.minecraft.util.IStringSerializable;
|
| 15 | import net.minecraft.util.MovingObjectPosition;
|
| 16 | import net.minecraft.util.Vec3;
|
| 17 | import net.minecraft.world.IBlockAccess;
|
| 18 | import net.minecraft.world.World;
|
| 19 |
|
| 20 | public abstract class BlockRailBase extends Block
|
| 21 | {
|
| 22 | protected final boolean isPowered;
|
| 23 |
|
| 24 | public static boolean isRailBlock(World worldIn, BlockPos pos)
|
| 25 | {
|
| 26 | return isRailBlock(worldIn.getBlockState(pos));
|
| 27 | }
|
| 28 |
|
| 29 | public static boolean isRailBlock(IBlockState state)
|
| 30 | {
|
| 31 | Block block = state.getBlock();
|
| 32 | return block == Blocks.rail || block == Blocks.golden_rail || block == Blocks.detector_rail || block == Blocks.activator_rail;
|
| 33 | }
|
| 34 |
|
| 35 | protected BlockRailBase(boolean isPowered)
|
| 36 | {
|
| 37 | super(Material.circuits);
|
| 38 | this.isPowered = isPowered;
|
| 39 | this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
| 40 | this.setCreativeTab(CreativeTabs.tabTransport);
|
| 41 | }
|
| 42 |
|
| 43 | public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
|
| 44 | {
|
| 45 | return null;
|
| 46 | }
|
| 47 |
|
| 48 | /**
|
| 49 | * Used to determine ambient occlusion and culling when rebuilding chunks for render
|
| 50 | */
|
| 51 | public boolean isOpaqueCube()
|
| 52 | {
|
| 53 | return false;
|
| 54 | }
|
| 55 |
|
| 56 | /**
|
| 57 | * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
|
| 58 | */
|
| 59 | public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
|
| 60 | {
|
| 61 | this.setBlockBoundsBasedOnState(worldIn, pos);
|
| 62 | return super.collisionRayTrace(worldIn, pos, start, end);
|
| 63 | }
|
| 64 |
|
| 65 | public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
| 66 | {
|
| 67 | IBlockState iblockstate = worldIn.getBlockState(pos);
|
| 68 | BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() == this ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(this.getShapeProperty()) : null;
|
| 69 |
|
| 70 | if (blockrailbase$enumraildirection != null && blockrailbase$enumraildirection.isAscending())
|
| 71 | {
|
| 72 | this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F);
|
| 73 | }
|
| 74 | else
|
| 75 | {
|
| 76 | this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
| 77 | }
|
| 78 | }
|
| 79 |
|
| 80 | public boolean isFullCube()
|
| 81 | {
|
| 82 | return false;
|
| 83 | }
|
| 84 |
|
| 85 | public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
|
| 86 | {
|
| 87 | return World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
|
| 88 | }
|
| 89 |
|
| 90 | public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
|
| 91 | {
|
| 92 | if (!worldIn.isRemote)
|
| 93 | {
|
| 94 | state = this.func_176564_a(worldIn, pos, state, true);
|
| 95 |
|
| 96 | if (this.isPowered)
|
| 97 | {
|
| 98 | this.onNeighborBlockChange(worldIn, pos, state, this);
|
| 99 | }
|
| 100 | }
|
| 101 | }
|
| 102 |
|
| 103 | /**
|
| 104 | * Called when a neighboring block changes.
|
| 105 | */
|
| 106 | public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
| 107 | {
|
| 108 | if (!worldIn.isRemote)
|
| 109 | {
|
| 110 | BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(this.getShapeProperty());
|
| 111 | boolean flag = false;
|
| 112 |
|
| 113 | if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
|
| 114 | {
|
| 115 | flag = true;
|
| 116 | }
|
| 117 |
|
| 118 | if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !World.doesBlockHaveSolidTopSurface(worldIn, pos.east()))
|
| 119 | {
|
| 120 | flag = true;
|
| 121 | }
|
| 122 | else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !World.doesBlockHaveSolidTopSurface(worldIn, pos.west()))
|
| 123 | {
|
| 124 | flag = true;
|
| 125 | }
|
| 126 | else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !World.doesBlockHaveSolidTopSurface(worldIn, pos.north()))
|
| 127 | {
|
| 128 | flag = true;
|
| 129 | }
|
| 130 | else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !World.doesBlockHaveSolidTopSurface(worldIn, pos.south()))
|
| 131 | {
|
| 132 | flag = true;
|
| 133 | }
|
| 134 |
|
| 135 | if (flag)
|
| 136 | {
|
| 137 | this.dropBlockAsItem(worldIn, pos, state, 0);
|
| 138 | worldIn.setBlockToAir(pos);
|
| 139 | }
|
| 140 | else
|
| 141 | {
|
| 142 | this.onNeighborChangedInternal(worldIn, pos, state, neighborBlock);
|
| 143 | }
|
| 144 | }
|
| 145 | }
|
| 146 |
|
| 147 | protected void onNeighborChangedInternal(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
|
| 148 | {
|
| 149 | }
|
| 150 |
|
| 151 | protected IBlockState func_176564_a(World worldIn, BlockPos p_176564_2_, IBlockState p_176564_3_, boolean p_176564_4_)
|
| 152 | {
|
| 153 | return worldIn.isRemote ? p_176564_3_ : (new BlockRailBase.Rail(worldIn, p_176564_2_, p_176564_3_)).func_180364_a(worldIn.isBlockPowered(p_176564_2_), p_176564_4_).getBlockState();
|
| 154 | }
|
| 155 |
|
| 156 | public int getMobilityFlag()
|
| 157 | {
|
| 158 | return 0;
|
| 159 | }
|
| 160 |
|
| 161 | public EnumWorldBlockLayer getBlockLayer()
|
| 162 | {
|
| 163 | return EnumWorldBlockLayer.CUTOUT;
|
| 164 | }
|
| 165 |
|
| 166 | public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
| 167 | {
|
| 168 | super.breakBlock(worldIn, pos, state);
|
| 169 |
|
| 170 | if (((BlockRailBase.EnumRailDirection)state.getValue(this.getShapeProperty())).isAscending())
|
| 171 | {
|
| 172 | worldIn.notifyNeighborsOfStateChange(pos.up(), this);
|
| 173 | }
|
| 174 |
|
| 175 | if (this.isPowered)
|
| 176 | {
|
| 177 | worldIn.notifyNeighborsOfStateChange(pos, this);
|
| 178 | worldIn.notifyNeighborsOfStateChange(pos.down(), this);
|
| 179 | }
|
| 180 | }
|
| 181 |
|
| 182 | public abstract IProperty<BlockRailBase.EnumRailDirection> getShapeProperty();
|
| 183 |
|
| 184 | public static enum EnumRailDirection implements IStringSerializable
|
| 185 | {
|
| 186 | NORTH_SOUTH(0, "north_south"),
|
| 187 | EAST_WEST(1, "east_west"),
|
| 188 | ASCENDING_EAST(2, "ascending_east"),
|
| 189 | ASCENDING_WEST(3, "ascending_west"),
|
| 190 | ASCENDING_NORTH(4, "ascending_north"),
|
| 191 | ASCENDING_SOUTH(5, "ascending_south"),
|
| 192 | SOUTH_EAST(6, "south_east"),
|
| 193 | SOUTH_WEST(7, "south_west"),
|
| 194 | NORTH_WEST(8, "north_west"),
|
| 195 | NORTH_EAST(9, "north_east");
|
| 196 |
|
| 197 | private static final BlockRailBase.EnumRailDirection[] META_LOOKUP = new BlockRailBase.EnumRailDirection[values().length];
|
| 198 | private final int meta;
|
| 199 | private final String name;
|
| 200 |
|
| 201 | private EnumRailDirection(int meta, String name)
|
| 202 | {
|
| 203 | this.meta = meta;
|
| 204 | this.name = name;
|
| 205 | }
|
| 206 |
|
| 207 | public int getMetadata()
|
| 208 | {
|
| 209 | return this.meta;
|
| 210 | }
|
| 211 |
|
| 212 | public String toString()
|
| 213 | {
|
| 214 | return this.name;
|
| 215 | }
|
| 216 |
|
| 217 | public boolean isAscending()
|
| 218 | {
|
| 219 | return this == ASCENDING_NORTH || this == ASCENDING_EAST || this == ASCENDING_SOUTH || this == ASCENDING_WEST;
|
| 220 | }
|
| 221 |
|
| 222 | public static BlockRailBase.EnumRailDirection byMetadata(int meta)
|
| 223 | {
|
| 224 | if (meta < 0 || meta >= META_LOOKUP.length)
|
| 225 | {
|
| 226 | meta = 0;
|
| 227 | }
|
| 228 |
|
| 229 | return META_LOOKUP[meta];
|
| 230 | }
|
| 231 |
|
| 232 | public String getName()
|
| 233 | {
|
| 234 | return this.name;
|
| 235 | }
|
| 236 |
|
| 237 | static {
|
| 238 | for (BlockRailBase.EnumRailDirection blockrailbase$enumraildirection : values())
|
| 239 | {
|
| 240 | META_LOOKUP[blockrailbase$enumraildirection.getMetadata()] = blockrailbase$enumraildirection;
|
| 241 | }
|
| 242 | }
|
| 243 | }
|
| 244 |
|
| 245 | public class Rail
|
| 246 | {
|
| 247 | private final World world;
|
| 248 | private final BlockPos pos;
|
| 249 | private final BlockRailBase block;
|
| 250 | private IBlockState state;
|
| 251 | private final boolean isPowered;
|
| 252 | private final List<BlockPos> field_150657_g = Lists.<BlockPos>newArrayList();
|
| 253 |
|
| 254 | public Rail(World worldIn, BlockPos pos, IBlockState state)
|
| 255 | {
|
| 256 | this.world = worldIn;
|
| 257 | this.pos = pos;
|
| 258 | this.state = state;
|
| 259 | this.block = (BlockRailBase)state.getBlock();
|
| 260 | BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(BlockRailBase.this.getShapeProperty());
|
| 261 | this.isPowered = this.block.isPowered;
|
| 262 | this.func_180360_a(blockrailbase$enumraildirection);
|
| 263 | }
|
| 264 |
|
| 265 | private void func_180360_a(BlockRailBase.EnumRailDirection p_180360_1_)
|
| 266 | {
|
| 267 | this.field_150657_g.clear();
|
| 268 |
|
| 269 | switch (p_180360_1_)
|
| 270 | {
|
| 271 | case NORTH_SOUTH:
|
| 272 | this.field_150657_g.add(this.pos.north());
|
| 273 | this.field_150657_g.add(this.pos.south());
|
| 274 | break;
|
| 275 |
|
| 276 | case EAST_WEST:
|
| 277 | this.field_150657_g.add(this.pos.west());
|
| 278 | this.field_150657_g.add(this.pos.east());
|
| 279 | break;
|
| 280 |
|
| 281 | case ASCENDING_EAST:
|
| 282 | this.field_150657_g.add(this.pos.west());
|
| 283 | this.field_150657_g.add(this.pos.east().up());
|
| 284 | break;
|
| 285 |
|
| 286 | case ASCENDING_WEST:
|
| 287 | this.field_150657_g.add(this.pos.west().up());
|
| 288 | this.field_150657_g.add(this.pos.east());
|
| 289 | break;
|
| 290 |
|
| 291 | case ASCENDING_NORTH:
|
| 292 | this.field_150657_g.add(this.pos.north().up());
|
| 293 | this.field_150657_g.add(this.pos.south());
|
| 294 | break;
|
| 295 |
|
| 296 | case ASCENDING_SOUTH:
|
| 297 | this.field_150657_g.add(this.pos.north());
|
| 298 | this.field_150657_g.add(this.pos.south().up());
|
| 299 | break;
|
| 300 |
|
| 301 | case SOUTH_EAST:
|
| 302 | this.field_150657_g.add(this.pos.east());
|
| 303 | this.field_150657_g.add(this.pos.south());
|
| 304 | break;
|
| 305 |
|
| 306 | case SOUTH_WEST:
|
| 307 | this.field_150657_g.add(this.pos.west());
|
| 308 | this.field_150657_g.add(this.pos.south());
|
| 309 | break;
|
| 310 |
|
| 311 | case NORTH_WEST:
|
| 312 | this.field_150657_g.add(this.pos.west());
|
| 313 | this.field_150657_g.add(this.pos.north());
|
| 314 | break;
|
| 315 |
|
| 316 | case NORTH_EAST:
|
| 317 | this.field_150657_g.add(this.pos.east());
|
| 318 | this.field_150657_g.add(this.pos.north());
|
| 319 | }
|
| 320 | }
|
| 321 |
|
| 322 | private void func_150651_b()
|
| 323 | {
|
| 324 | for (int i = 0; i < this.field_150657_g.size(); ++i)
|
| 325 | {
|
| 326 | BlockRailBase.Rail blockrailbase$rail = this.findRailAt((BlockPos)this.field_150657_g.get(i));
|
| 327 |
|
| 328 | if (blockrailbase$rail != null && blockrailbase$rail.func_150653_a(this))
|
| 329 | {
|
| 330 | this.field_150657_g.set(i, blockrailbase$rail.pos);
|
| 331 | }
|
| 332 | else
|
| 333 | {
|
| 334 | this.field_150657_g.remove(i--);
|
| 335 | }
|
| 336 | }
|
| 337 | }
|
| 338 |
|
| 339 | private boolean hasRailAt(BlockPos pos)
|
| 340 | {
|
| 341 | return BlockRailBase.isRailBlock(this.world, pos) || BlockRailBase.isRailBlock(this.world, pos.up()) || BlockRailBase.isRailBlock(this.world, pos.down());
|
| 342 | }
|
| 343 |
|
| 344 | private BlockRailBase.Rail findRailAt(BlockPos pos)
|
| 345 | {
|
| 346 | IBlockState iblockstate = this.world.getBlockState(pos);
|
| 347 |
|
| 348 | if (BlockRailBase.isRailBlock(iblockstate))
|
| 349 | {
|
| 350 | return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
|
| 351 | }
|
| 352 | else
|
| 353 | {
|
| 354 | BlockPos lvt_2_1_ = pos.up();
|
| 355 | iblockstate = this.world.getBlockState(lvt_2_1_);
|
| 356 |
|
| 357 | if (BlockRailBase.isRailBlock(iblockstate))
|
| 358 | {
|
| 359 | return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
|
| 360 | }
|
| 361 | else
|
| 362 | {
|
| 363 | lvt_2_1_ = pos.down();
|
| 364 | iblockstate = this.world.getBlockState(lvt_2_1_);
|
| 365 | return BlockRailBase.isRailBlock(iblockstate) ? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
|
| 366 | }
|
| 367 | }
|
| 368 | }
|
| 369 |
|
| 370 | private boolean func_150653_a(BlockRailBase.Rail p_150653_1_)
|
| 371 | {
|
| 372 | return this.func_180363_c(p_150653_1_.pos);
|
| 373 | }
|
| 374 |
|
| 375 | private boolean func_180363_c(BlockPos p_180363_1_)
|
| 376 | {
|
| 377 | for (int i = 0; i < this.field_150657_g.size(); ++i)
|
| 378 | {
|
| 379 | BlockPos blockpos = (BlockPos)this.field_150657_g.get(i);
|
| 380 |
|
| 381 | if (blockpos.getX() == p_180363_1_.getX() && blockpos.getZ() == p_180363_1_.getZ())
|
| 382 | {
|
| 383 | return true;
|
| 384 | }
|
| 385 | }
|
| 386 |
|
| 387 | return false;
|
| 388 | }
|
| 389 |
|
| 390 | protected int countAdjacentRails()
|
| 391 | {
|
| 392 | int i = 0;
|
| 393 |
|
| 394 | for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
|
| 395 | {
|
| 396 | if (this.hasRailAt(this.pos.offset(enumfacing)))
|
| 397 | {
|
| 398 | ++i;
|
| 399 | }
|
| 400 | }
|
| 401 |
|
| 402 | return i;
|
| 403 | }
|
| 404 |
|
| 405 | private boolean func_150649_b(BlockRailBase.Rail rail)
|
| 406 | {
|
| 407 | return this.func_150653_a(rail) || this.field_150657_g.size() != 2;
|
| 408 | }
|
| 409 |
|
| 410 | private void func_150645_c(BlockRailBase.Rail p_150645_1_)
|
| 411 | {
|
| 412 | this.field_150657_g.add(p_150645_1_.pos);
|
| 413 | BlockPos blockpos = this.pos.north();
|
| 414 | BlockPos blockpos1 = this.pos.south();
|
| 415 | BlockPos blockpos2 = this.pos.west();
|
| 416 | BlockPos blockpos3 = this.pos.east();
|
| 417 | boolean flag = this.func_180363_c(blockpos);
|
| 418 | boolean flag1 = this.func_180363_c(blockpos1);
|
| 419 | boolean flag2 = this.func_180363_c(blockpos2);
|
| 420 | boolean flag3 = this.func_180363_c(blockpos3);
|
| 421 | BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = null;
|
| 422 |
|
| 423 | if (flag || flag1)
|
| 424 | {
|
| 425 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
|
| 426 | }
|
| 427 |
|
| 428 | if (flag2 || flag3)
|
| 429 | {
|
| 430 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
|
| 431 | }
|
| 432 |
|
| 433 | if (!this.isPowered)
|
| 434 | {
|
| 435 | if (flag1 && flag3 && !flag && !flag2)
|
| 436 | {
|
| 437 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
|
| 438 | }
|
| 439 |
|
| 440 | if (flag1 && flag2 && !flag && !flag3)
|
| 441 | {
|
| 442 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
|
| 443 | }
|
| 444 |
|
| 445 | if (flag && flag2 && !flag1 && !flag3)
|
| 446 | {
|
| 447 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
|
| 448 | }
|
| 449 |
|
| 450 | if (flag && flag3 && !flag1 && !flag2)
|
| 451 | {
|
| 452 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
|
| 453 | }
|
| 454 | }
|
| 455 |
|
| 456 | if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
|
| 457 | {
|
| 458 | if (BlockRailBase.isRailBlock(this.world, blockpos.up()))
|
| 459 | {
|
| 460 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_NORTH;
|
| 461 | }
|
| 462 |
|
| 463 | if (BlockRailBase.isRailBlock(this.world, blockpos1.up()))
|
| 464 | {
|
| 465 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_SOUTH;
|
| 466 | }
|
| 467 | }
|
| 468 |
|
| 469 | if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
|
| 470 | {
|
| 471 | if (BlockRailBase.isRailBlock(this.world, blockpos3.up()))
|
| 472 | {
|
| 473 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_EAST;
|
| 474 | }
|
| 475 |
|
| 476 | if (BlockRailBase.isRailBlock(this.world, blockpos2.up()))
|
| 477 | {
|
| 478 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_WEST;
|
| 479 | }
|
| 480 | }
|
| 481 |
|
| 482 | if (blockrailbase$enumraildirection == null)
|
| 483 | {
|
| 484 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
|
| 485 | }
|
| 486 |
|
| 487 | this.state = this.state.withProperty(this.block.getShapeProperty(), blockrailbase$enumraildirection);
|
| 488 | this.world.setBlockState(this.pos, this.state, 3);
|
| 489 | }
|
| 490 |
|
| 491 | private boolean func_180361_d(BlockPos p_180361_1_)
|
| 492 | {
|
| 493 | BlockRailBase.Rail blockrailbase$rail = this.findRailAt(p_180361_1_);
|
| 494 |
|
| 495 | if (blockrailbase$rail == null)
|
| 496 | {
|
| 497 | return false;
|
| 498 | }
|
| 499 | else
|
| 500 | {
|
| 501 | blockrailbase$rail.func_150651_b();
|
| 502 | return blockrailbase$rail.func_150649_b(this);
|
| 503 | }
|
| 504 | }
|
| 505 |
|
| 506 | public BlockRailBase.Rail func_180364_a(boolean p_180364_1_, boolean p_180364_2_)
|
| 507 | {
|
| 508 | BlockPos blockpos = this.pos.north();
|
| 509 | BlockPos blockpos1 = this.pos.south();
|
| 510 | BlockPos blockpos2 = this.pos.west();
|
| 511 | BlockPos blockpos3 = this.pos.east();
|
| 512 | boolean flag = this.func_180361_d(blockpos);
|
| 513 | boolean flag1 = this.func_180361_d(blockpos1);
|
| 514 | boolean flag2 = this.func_180361_d(blockpos2);
|
| 515 | boolean flag3 = this.func_180361_d(blockpos3);
|
| 516 | BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = null;
|
| 517 |
|
| 518 | if ((flag || flag1) && !flag2 && !flag3)
|
| 519 | {
|
| 520 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
|
| 521 | }
|
| 522 |
|
| 523 | if ((flag2 || flag3) && !flag && !flag1)
|
| 524 | {
|
| 525 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
|
| 526 | }
|
| 527 |
|
| 528 | if (!this.isPowered)
|
| 529 | {
|
| 530 | if (flag1 && flag3 && !flag && !flag2)
|
| 531 | {
|
| 532 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
|
| 533 | }
|
| 534 |
|
| 535 | if (flag1 && flag2 && !flag && !flag3)
|
| 536 | {
|
| 537 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
|
| 538 | }
|
| 539 |
|
| 540 | if (flag && flag2 && !flag1 && !flag3)
|
| 541 | {
|
| 542 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
|
| 543 | }
|
| 544 |
|
| 545 | if (flag && flag3 && !flag1 && !flag2)
|
| 546 | {
|
| 547 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
|
| 548 | }
|
| 549 | }
|
| 550 |
|
| 551 | if (blockrailbase$enumraildirection == null)
|
| 552 | {
|
| 553 | if (flag || flag1)
|
| 554 | {
|
| 555 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
|
| 556 | }
|
| 557 |
|
| 558 | if (flag2 || flag3)
|
| 559 | {
|
| 560 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.EAST_WEST;
|
| 561 | }
|
| 562 |
|
| 563 | if (!this.isPowered)
|
| 564 | {
|
| 565 | if (p_180364_1_)
|
| 566 | {
|
| 567 | if (flag1 && flag3)
|
| 568 | {
|
| 569 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
|
| 570 | }
|
| 571 |
|
| 572 | if (flag2 && flag1)
|
| 573 | {
|
| 574 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
|
| 575 | }
|
| 576 |
|
| 577 | if (flag3 && flag)
|
| 578 | {
|
| 579 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
|
| 580 | }
|
| 581 |
|
| 582 | if (flag && flag2)
|
| 583 | {
|
| 584 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
|
| 585 | }
|
| 586 | }
|
| 587 | else
|
| 588 | {
|
| 589 | if (flag && flag2)
|
| 590 | {
|
| 591 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_WEST;
|
| 592 | }
|
| 593 |
|
| 594 | if (flag3 && flag)
|
| 595 | {
|
| 596 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_EAST;
|
| 597 | }
|
| 598 |
|
| 599 | if (flag2 && flag1)
|
| 600 | {
|
| 601 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_WEST;
|
| 602 | }
|
| 603 |
|
| 604 | if (flag1 && flag3)
|
| 605 | {
|
| 606 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.SOUTH_EAST;
|
| 607 | }
|
| 608 | }
|
| 609 | }
|
| 610 | }
|
| 611 |
|
| 612 | if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.NORTH_SOUTH)
|
| 613 | {
|
| 614 | if (BlockRailBase.isRailBlock(this.world, blockpos.up()))
|
| 615 | {
|
| 616 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_NORTH;
|
| 617 | }
|
| 618 |
|
| 619 | if (BlockRailBase.isRailBlock(this.world, blockpos1.up()))
|
| 620 | {
|
| 621 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_SOUTH;
|
| 622 | }
|
| 623 | }
|
| 624 |
|
| 625 | if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.EAST_WEST)
|
| 626 | {
|
| 627 | if (BlockRailBase.isRailBlock(this.world, blockpos3.up()))
|
| 628 | {
|
| 629 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_EAST;
|
| 630 | }
|
| 631 |
|
| 632 | if (BlockRailBase.isRailBlock(this.world, blockpos2.up()))
|
| 633 | {
|
| 634 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.ASCENDING_WEST;
|
| 635 | }
|
| 636 | }
|
| 637 |
|
| 638 | if (blockrailbase$enumraildirection == null)
|
| 639 | {
|
| 640 | blockrailbase$enumraildirection = BlockRailBase.EnumRailDirection.NORTH_SOUTH;
|
| 641 | }
|
| 642 |
|
| 643 | this.func_180360_a(blockrailbase$enumraildirection);
|
| 644 | this.state = this.state.withProperty(this.block.getShapeProperty(), blockrailbase$enumraildirection);
|
| 645 |
|
| 646 | if (p_180364_2_ || this.world.getBlockState(this.pos) != this.state)
|
| 647 | {
|
| 648 | this.world.setBlockState(this.pos, this.state, 3);
|
| 649 |
|
| 650 | for (int i = 0; i < this.field_150657_g.size(); ++i)
|
| 651 | {
|
| 652 | BlockRailBase.Rail blockrailbase$rail = this.findRailAt((BlockPos)this.field_150657_g.get(i));
|
| 653 |
|
| 654 | if (blockrailbase$rail != null)
|
| 655 | {
|
| 656 | blockrailbase$rail.func_150651_b();
|
| 657 |
|
| 658 | if (blockrailbase$rail.func_150649_b(this))
|
| 659 | {
|
| 660 | blockrailbase$rail.func_150645_c(this);
|
| 661 | }
|
| 662 | }
|
| 663 | }
|
| 664 | }
|
| 665 |
|
| 666 | return this;
|
| 667 | }
|
| 668 |
|
| 669 | public IBlockState getBlockState()
|
| 670 | {
|
| 671 | return this.state;
|
| 672 | }
|
| 673 | }
|
| 674 | }
|
| 675 |
|