Posted November 12, 20177 yr @Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if ((stack.getMaxItemUseDuration() - entityLiving.getItemInUseCount()) / 20.0F > 5.0) { NBTTagCompound tag = stack.getTagCompound(); int radius = tag.getInteger("ToolRadius"); for (int x = -radius; x < radius + 1; x++) { for (int y = -radius; y < radius + 1; y++) { for (int z = -radius; z < radius + 1; z++) { BlockPos blockpos = new BlockPos(entityLiving.getPosition().getX() + x, entityLiving.getPosition().getY() + y, entityLiving.getPosition().getZ() + z); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (isOre(iblockstate.getBlock())) { IBlockState stone = Blocks.STONE.getDefaultState(); worldIn.setBlockState(blockpos, stone); ItemStack item = new ItemStack(iblockstate.getBlock()); entityLiving.entityDropItem(item, 1F); } } } } } } I'd like to put the blocks I break in the player inventory but I couldn't find an way to do that, so I tried spawning them in the ground, It works but It also spawns some ghost items that I can't pickup https://github.com/Harystolho/UberMiner/blob/1.12/src/main/java/harystolho/uberminer/objects/items/BowUber.java Edited November 12, 20177 yr by Harystolho
November 12, 20177 yr Don't spawn items on the client. Only spawn them on the server. onPlayerStoppedUsing is run on both sides. check for world.isRemote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.