Posted October 11, 201410 yr Hello, I have a tool that destroys a 3x3x3 area. The problem is that the blocks that are set to air are replaced with phantom blocks. Phantom blocks are blocks that look like they're just air, but whenever walked into, teleports the player backwards. ItemScythe: package tooldles.item; import java.util.List; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.Block.SoundType; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.world.World; import tooldles.ReferenceOT; import com.google.common.collect.Sets; public class ItemScythe extends ItemTool { private static final Set MINABLE_BLOCKS = Sets.newHashSet(new Block[] { Blocks.tallgrass, Blocks.deadbush, Blocks.leaves, Blocks.leaves2, Blocks.vine, Blocks.red_flower, Blocks.yellow_flower, Blocks.double_plant, Blocks.web }); public ItemScythe(ToolMaterial material, String name) { super(3F, material, MINABLE_BLOCKS); this.setUnlocalizedName(name); this.setTextureName(ReferenceOT.ID + ":" + name); } @Override public boolean func_150897_b(Block block) { return block == Blocks.tallgrass || block == Blocks.deadbush || block == Blocks.leaves || block == Blocks.leaves2 || block == Blocks.vine || block == Blocks.red_flower || block == Blocks.yellow_flower || block == Blocks.double_plant || block == Blocks.web; } @Override public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { return super.onBlockDestroyed(itemStack, world, block, x, y, z, entity); } @Override public boolean onBlockStartBreak(ItemStack itemStack, int x, int y, int z, EntityPlayer player) { World world = player.worldObj; Block block = world.getBlock(x, y, z); if(this.canHarvestBlock(block, itemStack)) { SoundType sound = block.stepSound; world.playSoundAtEntity(player, sound.getBreakSound(), sound.volume, 0.8F); itemStack.damageItem(1, player); breakBlock(world, itemStack, x - 1, y, z, player); breakBlock(world, itemStack, x + 1, y, z, player); breakBlock(world, itemStack, x - 1, y + 1, z, player); breakBlock(world, itemStack, x + 1, y + 1, z, player); breakBlock(world, itemStack, x - 1, y - 1, z, player); breakBlock(world, itemStack, x + 1, y - 1, z, player); breakBlock(world, itemStack, x, y, z - 1, player); breakBlock(world, itemStack, x, y, z + 1, player); breakBlock(world, itemStack, x, y + 1, z - 1, player); breakBlock(world, itemStack, x, y + 1, z + 1, player); breakBlock(world, itemStack, x, y - 1, z - 1, player); breakBlock(world, itemStack, x, y - 1, z + 1, player); breakBlock(world, itemStack, x + 1, y, z + 1, player); breakBlock(world, itemStack, x - 1, y, z - 1, player); breakBlock(world, itemStack, x + 1, y + 1, z + 1, player); breakBlock(world, itemStack, x - 1, y + 1, z - 1, player); breakBlock(world, itemStack, x + 1, y - 1, z + 1, player); breakBlock(world, itemStack, x - 1, y - 1, z - 1, player); breakBlock(world, itemStack, x + 1, y, z - 1, player); breakBlock(world, itemStack, x - 1, y, z + 1, player); breakBlock(world, itemStack, x + 1, y + 1, z - 1, player); breakBlock(world, itemStack, x - 1, y + 1, z + 1, player); breakBlock(world, itemStack, x + 1, y - 1, z - 1, player); breakBlock(world, itemStack, x - 1, y - 1, z + 1, player); breakBlock(world, itemStack, x, y + 1, z, player); breakBlock(world, itemStack, x, y - 1, z, player); return true; } return false; } private void breakBlock(World world, ItemStack itemStack, int x, int y, int z, EntityLivingBase entity) { Block block = world.getBlock(x, y, z); if(this.canHarvestBlock(block, itemStack)) { world.setBlock(x, y, z, Blocks.air); if(!world.isRemote) { List<ItemStack> loot = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 2 + EnchantmentHelper.getFortuneModifier(entity)); for(ItemStack lootItem : loot) { EntityItem lootEntity = new EntityItem(world, x, y, z, lootItem); world.spawnEntityInWorld(lootEntity); } } } } } Kain
October 11, 201410 yr you are probably setting them to air client-side only, you need to do it server-side move "if(!world.isRemote) { " up a few lines
October 11, 201410 yr Author Nothing package tooldles.item; import java.util.List; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.Block.SoundType; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.world.World; import tooldles.ReferenceOT; import com.google.common.collect.Sets; public class ItemScythe extends ItemTool { private static final Set MINABLE_BLOCKS = Sets.newHashSet(new Block[] { Blocks.tallgrass, Blocks.deadbush, Blocks.leaves, Blocks.leaves2, Blocks.vine, Blocks.red_flower, Blocks.yellow_flower, Blocks.double_plant, Blocks.web }); public ItemScythe(ToolMaterial material, String name) { super(3F, material, MINABLE_BLOCKS); this.setUnlocalizedName(name); this.setTextureName(ReferenceOT.ID + ":" + name); } @Override public boolean func_150897_b(Block block) { return block == Blocks.tallgrass || block == Blocks.deadbush || block == Blocks.leaves || block == Blocks.leaves2 || block == Blocks.vine || block == Blocks.red_flower || block == Blocks.yellow_flower || block == Blocks.double_plant || block == Blocks.web; } @Override public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { return super.onBlockDestroyed(itemStack, world, block, x, y, z, entity); } @Override public boolean onBlockStartBreak(ItemStack itemStack, int x, int y, int z, EntityPlayer player) { World world = player.worldObj; Block block = world.getBlock(x, y, z); if(this.canHarvestBlock(block, itemStack)) { SoundType sound = block.stepSound; world.playSoundAtEntity(player, sound.getBreakSound(), sound.volume, 0.8F); itemStack.damageItem(1, player); breakBlock(world, itemStack, x - 1, y, z, player); breakBlock(world, itemStack, x + 1, y, z, player); breakBlock(world, itemStack, x - 1, y + 1, z, player); breakBlock(world, itemStack, x + 1, y + 1, z, player); breakBlock(world, itemStack, x - 1, y - 1, z, player); breakBlock(world, itemStack, x + 1, y - 1, z, player); breakBlock(world, itemStack, x, y, z - 1, player); breakBlock(world, itemStack, x, y, z + 1, player); breakBlock(world, itemStack, x, y + 1, z - 1, player); breakBlock(world, itemStack, x, y + 1, z + 1, player); breakBlock(world, itemStack, x, y - 1, z - 1, player); breakBlock(world, itemStack, x, y - 1, z + 1, player); breakBlock(world, itemStack, x + 1, y, z + 1, player); breakBlock(world, itemStack, x - 1, y, z - 1, player); breakBlock(world, itemStack, x + 1, y + 1, z + 1, player); breakBlock(world, itemStack, x - 1, y + 1, z - 1, player); breakBlock(world, itemStack, x + 1, y - 1, z + 1, player); breakBlock(world, itemStack, x - 1, y - 1, z - 1, player); breakBlock(world, itemStack, x + 1, y, z - 1, player); breakBlock(world, itemStack, x - 1, y, z + 1, player); breakBlock(world, itemStack, x + 1, y + 1, z - 1, player); breakBlock(world, itemStack, x - 1, y + 1, z + 1, player); breakBlock(world, itemStack, x + 1, y - 1, z - 1, player); breakBlock(world, itemStack, x - 1, y - 1, z + 1, player); breakBlock(world, itemStack, x, y + 1, z, player); breakBlock(world, itemStack, x, y - 1, z, player); return true; } return false; } private void breakBlock(World world, ItemStack itemStack, int x, int y, int z, EntityLivingBase entity) { Block block = world.getBlock(x, y, z); if(!world.isRemote && this.canHarvestBlock(block, itemStack)) { List<ItemStack> loot = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 2 + EnchantmentHelper.getFortuneModifier(entity)); for(ItemStack lootItem : loot) { EntityItem lootEntity = new EntityItem(world, x, y, z, lootItem); world.spawnEntityInWorld(lootEntity); } world.setBlock(x, y, z, Blocks.air); } } } Kain
October 11, 201410 yr can you use @Override public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) { to break the blocks onBlockStartBreak might be client side only, and causing the problems
October 11, 201410 yr Author That fixed it, thanks. I have no clue why I overrided that method and just returned super's implementation. Kain
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.