Posted April 7, 20169 yr Before you say, "Oh, you OnBlockActivated runs twice! Once on the server and client!" That is NOT my problem. The client runs twice and the server runs twice. OnBlockActivated: @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { System.out.println("Is Remote: " + world.isRemote); LockedDoorTileEntity te = (LockedDoorTileEntity) world.getTileEntity(pos); DoorCorner corner = te.corner; if(playerIn.isSneaking() && playerIn.isCreative() && !world.isRemote){ if(corner == DoorCorner.BottomLeftX){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(1, 0, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(1, 1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.BottomRightX){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(-1, 0, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(-1, 1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.TopLeftX){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(1, 0, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, -1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(1, -1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.TopRightX){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(-1, 0, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, -1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(-1, -1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.BottomLeftZ){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 0, 1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 1, 1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.BottomRightZ){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 0, -1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 1, -1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.TopLeftZ){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 0, 1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, -1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, -1, 1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } if(corner == DoorCorner.TopRightZ){ ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, 0, -1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, -1, 0))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos.add(0, -1, -1))).toggleKey(); ((LockedDoorTileEntity) world.getTileEntity(pos)).toggleKey(); } LockedDoorTileEntity tehere = (LockedDoorTileEntity)world.getTileEntity(pos); String keyName = tehere.useSilverKey ? TextFormatting.DARK_GRAY + "silver " : TextFormatting.GOLD + "gold "; playerIn.addChatComponentMessage(new TextComponentString("This door now takes the " + keyName + TextFormatting.RESET + "key.")); TaleCraft.network.sendToDimension(new DoorPacket(pos, tehere.useSilverKey), world.provider.getDimension()); return false; } if(world.isRemote){ if(heldItem != null && heldItem.getItem() instanceof KeyItem){ if((heldItem.getItem() == TaleCraftItems.silverKey && te.useSilverKey) || (heldItem.getItem() == TaleCraftItems.goldKey && !te.useSilverKey))world.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.block_chest_open, SoundCategory.BLOCKS, 100f, 1f, false); } return false; } if(heldItem != null && heldItem.getItem() instanceof KeyItem){ if((heldItem.getItem() == TaleCraftItems.silverKey && te.useSilverKey) || (heldItem.getItem() == TaleCraftItems.goldKey && !te.useSilverKey)){ world.setBlockToAir(pos); onBlockDestroyedByPlayer(world, pos, state); heldItem.stackSize--; return false; } } return true; } Console Output: [17:11:50] [Client thread/INFO] [sTDOUT]: [tiffit.talecraft.blocks.world.LockedDoorBlock:onBlockActivated:42]: Is Remote: true [17:11:50] [Client thread/INFO] [sTDOUT]: [tiffit.talecraft.blocks.world.LockedDoorBlock:onBlockActivated:42]: Is Remote: true [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.blocks.world.LockedDoorBlock:onBlockActivated:42]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.blocks.world.LockedDoorBlock:onBlockActivated:42]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [server thread/INFO] [sTDOUT]: [tiffit.talecraft.tileentity.LockedDoorTileEntity:toggleKey:32]: Is Remote: false [17:11:50] [Client thread/INFO]: [CHAT] This door now takes the §6gold §rkey. [17:11:50] [Client thread/INFO]: [CHAT] This door now takes the §8silver §rkey. Can't seem to find the solution to this, but it is toggling and then immediately retoggling a boolean thus keeping it the same.
April 7, 20169 yr Try returning true instead of false within your if statements - that signals Minecraft that something happened. http://i.imgur.com/NdrFdld.png[/img]
April 7, 20169 yr Author Try returning true instead of false within your if statements - that signals Minecraft that something happened. That works, thanks!
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.