Jump to content

AustinTan

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by AustinTan

  1. I made it so that player other than the owner who placed down the block cannot break the block but every time when the first player place down a block the UUID variable is equal to player 1 name but after player 2 place down another block the UUID variable of both block change to the player 2 UUID what did I do wrong? I am still very new to modding! and coding btw @Override public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { if(player.getUniqueID().equals(ChestTileEntity.permission)) { ChestTileEntity.canBreak = true; System.out.println("It tried to read to tileentity " + ChestTileEntity.permission); System.out.println("Succeseeseidkhowtospeellol"); } else { ChestTileEntity.canBreak = false; } } @SubscribeEvent public static void breakSpeedEvent(BreakSpeed event) { if(ChestTileEntity.canBreak == false) { event.setNewSpeed(0); System.out.println("It tried to read to tileentity " + ChestTileEntity.canBreak); } } Variable: public static UUID permission; public static Boolean canBreak;
  2. I used this but it's still the same what did I do wrong? event.setNewSpeed(0); EDIT: it worked I fixed it Thanks you!
  3. Sorry for the late reply! Now that I store the data in the title entity and then I realized that I used the wrong method for what I am trying to do I want to set so that the player cannot break the block not cannot get the block after it break do you know what method should I use? Because I don't and I've been searching for quite sometime and I still have no idea!
  4. How do I make only the player who place the block can break the Block? I dont know the problem is that I used the wrong method to get the name of the player who placed the block or that I used the canHarvestBlock in a wrong way. I am very new to this ! This is the onBlockPlacedBy and canHarvestBlock: @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { if(placer instanceof PlayerEntity) { permission = placer.getName().toString(); } } @Override public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player) { if(player.getName().getString() == permission) { return state.getBlock().canHarvestBlock(state, world, pos, player); } return false; } Permission variable: public static String permission = null; EDIT: I solve the problem above but now my problem is that I the method I used was wrong! I don't know what method should I use in order to not let player to break the block
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.