Posted November 9, 20168 yr Hi I have this tool that when I right click, it fills a flat area with Blocks. The problem is, the blocks sometimes get placed on the server and client side correctly, but when the amount of blocks that are changing is too large, they only get placed on the client side. Here's my code: @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { matToReplace = world.getBlockState(pos); positions.add(pos); for(int i = 0; i < 80; i++) { for(int j = 0; j < positions.size(); j++) { if(side == EnumFacing.NORTH || side == EnumFacing.SOUTH) { addPositionsNorth(j,world); } if(side == EnumFacing.EAST || side == EnumFacing.WEST) { addPositionsEast(j,world); } if(side == EnumFacing.DOWN || side == EnumFacing.UP) { addPositionsDown(j,world); } } positions.addAll(tempPositions); tempPositions.clear(); } for(int k = 0; k < positions.size(); k++) { world.setBlockState(positions.get(k), Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage"))); world.scheduleBlockUpdate(positions.get(k), world.getBlockState(positions.get(k)).getBlock(), 1, 1); } positions.clear(); tempPositions.clear(); return EnumActionResult.PASS; } Any help would be apprechiated
November 9, 20168 yr Author They are fields in my Item class... So how should I do it differently? Forge Events? Packets?
November 9, 20168 yr Author They store the values for BlockPos so that they can get placed by the Item.
November 9, 20168 yr Items are singletons (only one instance of them ever exists), so instance fields can't be used to store per-stack data. The ItemStack's NBTTagCompound should be used to store data that is per-stack. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
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.