From 2347fdff62c34af40859fb2ed1d59710e01987dc Mon Sep 17 00:00:00 2001 From: wizjany Date: Mon, 24 Jun 2019 22:44:12 -0400 Subject: [PATCH] [Forge] Use IClearable to clear containers. --- .../java/com/sk89q/worldedit/forge/ForgeWorld.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index 840680e1a..6abda18d1 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -54,7 +54,7 @@ import net.minecraft.block.Blocks; import net.minecraft.block.LeavesBlock; import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; -import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.IClearable; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.CompoundNBT; @@ -234,12 +234,8 @@ public class ForgeWorld extends AbstractWorld { public boolean clearContainerBlockContents(BlockVector3 position) { checkNotNull(position); TileEntity tile = getWorld().getTileEntity(ForgeAdapter.toBlockPos(position)); - if ((tile instanceof IInventory)) { - IInventory inv = (IInventory) tile; - int size = inv.getSizeInventory(); - for (int i = 0; i < size; i++) { - inv.setInventorySlotContents(i, ItemStack.EMPTY); - } + if (tile instanceof IClearable) { + ((IClearable) tile).clear(); return true; } return false;