Posted July 19, 201312 yr Hello to anyone reading this, I am kris91268, the creator of Light bridges and doors, if you may know On a previous version of Minecraft (1.5.2) My light door rotated correctly when you place it on the underside of a block. But in the 1.6 versions, it doesn't do this anymore, and only can rotate in one way (I would of said one direction, but I don't want to). I was wandering if anyone on the forums could help me with this dilemma. Below is the source code of the whole BlockLightDoorSource file, any help would be much appreciated. BlockLightDoorSource.java package kris91268.lbd.Blocks; import java.util.Random; import kris91268.lbd.ModLBD; import kris91268.lbd.Tileentity.TileEntityLightDoorSource; import cpw.mods.fml.common.registry.BlockProxy; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import static net.minecraftforge.common.ForgeDirection.*; /** * * @author Arbiter * */ public class BlockLightDoorSource extends BlockContainer implements BlockProxy { public final boolean powered; public BlockLightDoorSource(int par1, boolean par2) { super(par1, Material.iron); powered = par2; setHardness(1.5F); setResistance(0.5F); setStepSound(Block.soundMetalFootstep); setUnlocalizedName("lightDoorSource"); setCreativeTab(CreativeTabs.tabRedstone); } public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return false; } public int getRenderBlockPass() { return 1; } public void onBlockAdded(World par1World, int par2, int par3, int par4) { if (par1World.getBlockMetadata(par2, par3, par4) == 0) { if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 2); } else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } else { this.dropLightDoorIfCantStay(par1World, par2, par3, par4); } } if (par1World.isRemote) { if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4); } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { int par5 = par1World.getBlockMetadata(par2, par3, par4); if (par5 == 5) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 5, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 0, 2); } else { break; } } } if (par5 == 1) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 1, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 1, 2); } else { break; } } } if (par5 == 2) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 2, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 2, 2); } else { break; } } } if (par5 == 3) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 3, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 3, 2); } else { break; } } } } } } public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { return par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true); } public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { int par10 = par9; if (par9 == 1 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par10 = 1; } if (par9 == 3 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par10 = 3; } if (par9 == 5 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par10 = 5; } if (par9 == 2 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true)) { par10 = 2; } return par10; } public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { int par5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4); float par6 = 0.625F; float par7 = 0.575F; if (par5 == 5) { // Shorter side facing west setBlockBounds(1.0F - par6, 1.0F, 0.0F, 0.55F, 0.8F, 1.0F); } if (par5 == 1) { // Shorter side facing north setBlockBounds(0.0F, 1.0F, 1.0F - par7, 1.0F, 0.8F, 0.625F); } if (par5 == 2) { // Shorter side facing east setBlockBounds(1.0F - par7, 1.0F, 0.0F, 0.625F, 0.8F, 1.0F); } if (par5 == 3) { // Shorter side facing south setBlockBounds(0.0F, 1.0F, 1.0F - par6, 1.0F, 0.8F, 0.55F); } } protected boolean dropLightDoorIfCantStay(World par1World, int par2, int par3, int par4) { if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) { if (par1World.getBlockId(par2, par3, par4) == this.blockID) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } return false; } else { return true; } } public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { if (this.dropLightDoorIfCantStay(par1World, par2, par3, par4)) { int par6 = par1World.getBlockMetadata(par2, par3, par4); boolean flag = false; if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 5) { flag = true; } if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 2) { flag = true; } if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 3) { flag = true; } if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN, true) && par6 == 1) { flag = true; } if (flag) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } } if (!par1World.isRemote) { if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4); } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { int par6 = par1World.getBlockMetadata(par2, par3, par4); if (par6 == 5) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 5, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 0, 2); } else { break; } } } if (par6 == 1) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 1, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 1, 2); } else { break; } } } if (par6 == 2) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 2, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 2, 2); } else { break; } } } if (par6 == 3) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSourceActive.blockID, 3, 2); for (int par7 = par3 - 1; par7 >= par3 - 50; --par7) { if (par1World.isAirBlock(par2, par7, par4)) { par1World.setBlock(par2, par7, par4, ModLBD.lightDoorSection.blockID, 3, 2); } else { break; } } } } } } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote && this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { int par6 = par1World.getBlockMetadata(par2, par3, par4); if (par6 == 5) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSource.blockID, 5, 2); } if (par6 == 1) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSource.blockID, 1, 2); } if (par6 == 2) { par1World.setBlock(par2, par3, par4, ModLBD.lightBridgeSource.blockID, 2, 2); } if (par6 == 3) { par1World.setBlock(par2, par3, par4, ModLBD.lightDoorSource.blockID, 3, 2); } } } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) { int par7 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (par7 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1, 2); } if (par7 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (par7 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (par7 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (par6ItemStack.hasDisplayName()) { ((TileEntityLightDoorSource)par1World.getBlockTileEntity(par2, par3, par4)).func_91249_a(par6ItemStack.getDisplayName()); } } public int quantityDropped(Random par1Random) { return 1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return -1; } public TileEntity getBlockEntity() { return new TileEntityLightDoorSource(); } public TileEntity createNewTileEntity(World par1World) { return new TileEntityLightDoorSource(); } } Thanks kris91268
July 20, 201312 yr Author Please can someone reply to this/help me out, as this is a very urgent bug.
July 20, 201312 yr Change this Line: public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) into this Line: public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
July 21, 201312 yr Author You could have figured this out much earlier (and on your own) if you had used @Override. Sorry, but I am not that good with annotations, it never occurs to me to use the @Override annotation. But I do feel stupid about myself because I didn't see this
July 21, 201312 yr Author Change this Line: public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) into this Line: public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) Thank you so much, you are amazing. I would of figured this out myself, but I did not see that the other method was a new one (notch changed the onBlockPlacedBy method), but anyway, thanks so much. +Thank you
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.