Posted April 5, 201510 yr I am trying to create a diamond powered rail everything works apart from the accelerated motion. When a redstone signal is added the rail lights up 9 blocks but the accelerated effect only works on the block directly next to the redstone signal. I have added the code at the bottom which makes the cart accelerate when it is powered and stop when it is not powered but I think it is making it only work with the rail that is next to the redstone signal. If anyone knows how to make all of the rails connected to the redstone signal accelerate the minecart I would greatly appreciate your help. In the image below I pushed a minecart from the right and with my rail it speed up and stopped right after the redstone signal but with the vanilla rail it kept going until the unpowered one which is what I want my rail to do. [/img] package com.ellybelly.netheradditions.block; import net.minecraft.block.Block; import net.minecraft.block.BlockRailBase; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import com.ellybelly.netheradditions.creativetab.CreativeTab; import com.ellybelly.netheradditions.reference.Reference; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockDiamondRailPowered extends BlockRailBase { @SideOnly(Side.CLIENT) protected IIcon icon; public BlockDiamondRailPowered() { super(true); this.setCreativeTab(CreativeTab.NETHERADDITIONS_TAB); } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int j) { return (j & == 0 ? this.blockIcon : this.icon; } @Override public String getUnlocalizedName() { return String.format("tile.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconregister) { super.blockIcon = iconregister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()))); this.icon = iconregister.registerIcon("netheradditions" + ":" + this.getTextureName() + "_powered"); } protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } public float getRailMaxSpeed(World world, EntityMinecart cart, int x, int y, int z) { return 0.6f; } protected boolean func_150058_a(World world, int x, int y, int z, int i, boolean j, int k) { if (k >= { return false; } else { int j1 = i & 7; boolean flag1 = true; switch (j1) { case 0: if (j) { ++z; } else { --z; } break; case 1: if (j) { --x; } else { ++x; } break; case 2: if (j) { --x; } else { ++x; ++y; flag1 = false; } j1 = 1; break; case 3: if (j) { --x; ++y; flag1 = false; } else { ++x; } j1 = 1; break; case 4: if (j) { ++z; } else { --z; ++y; flag1 = false; } j1 = 0; break; case 5: if (j) { ++z; ++y; flag1 = false; } else { --z; } j1 = 0; } return this.func_150057_a(world, x, y, z, j, k, j1) ? true : flag1 && this.func_150057_a(world, x, y - 1, z, j, k, j1); } } protected boolean func_150057_a(World world, int x, int y, int z, boolean i, int j, int k) { Block block = world.getBlock(x, y, z); if (block == this) { int j1 = world.getBlockMetadata(x, y, z); int k1 = j1 & 7; if (k == 1 && (k1 == 0 || k1 == 4 || k1 == 5)) { return false; } if (k == 0 && (k1 == 1 || k1 == 2 || k1 == 3)) { return false; } if ((j1 & != 0) { if (world.isBlockIndirectlyGettingPowered(x, y, z)) { return true; } return this.func_150058_a(world, x, y, z, j1, i, j + 1); } } return false; } protected void func_150048_a(World world, int x, int y, int z, int i, int j, Block block) { boolean flag = world.isBlockIndirectlyGettingPowered(x, y, z); flag = flag || this.func_150058_a(world, x, y, z, i, true, 0) || this.func_150058_a(world, x, y, z, i, false, 0); boolean flag1 = false; if (flag && (i & == 0) { world.setBlockMetadataWithNotify(x, y, z, j | 8, 3); flag1 = true; } else if (!flag && (i & != 0) { world.setBlockMetadataWithNotify(x, y, z, j, 3); flag1 = true; } if (flag1) { world.notifyBlocksOfNeighborChange(x, y - 1, z, this); if (j == 2 || j == 3 || j == 4 || j == 5) { world.notifyBlocksOfNeighborChange(x, y + 1, z, this); } } } public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) { if (world.isBlockIndirectlyGettingPowered(x, y, z)) { cart.motionX *= 3.5D; cart.motionY *= 0.0D; cart.motionZ *= 3.5D; } else { cart.motionX *= 0.0D; cart.motionY *= 0.0D; cart.motionZ *= 0.0D; } } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.