Ooof bad duplication issue [1.11.2]
This commit is contained in:
parent
faea11d484
commit
eb0a3f8536
|
|
@ -7,6 +7,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
@ -263,7 +264,7 @@ public class ItemEvents
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
emptyTileEntity(te);
|
world.removeTileEntity(pos);
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||||
event.setUseBlock(Result.DENY);
|
event.setUseBlock(Result.DENY);
|
||||||
|
|
@ -271,16 +272,27 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
try
|
||||||
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
{
|
||||||
world.setBlockState(pos, statee);
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, player.getEntityId(), overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
if (!tag.hasNoTags())
|
emptyTileEntity(te);
|
||||||
TileEntity.create(world, tag);
|
world.setBlockToAir(pos);
|
||||||
|
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||||
|
event.setUseBlock(Result.DENY);
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
|
world.setBlockState(pos, statee);
|
||||||
|
if (!tag.hasNoTags())
|
||||||
|
TileEntity.create(world, tag);
|
||||||
|
|
||||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot pick up block."));
|
player.sendMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot pick up block."));
|
||||||
TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here");
|
||||||
s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues"));
|
||||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s));
|
player.sendMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -290,7 +302,7 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void emptyTileEntity(TileEntity te)
|
public static void emptyTileEntity(TileEntity te)
|
||||||
{
|
{
|
||||||
if (te != null && !te.isInvalid())
|
if (te != null && !te.isInvalid())
|
||||||
|
|
@ -315,6 +327,21 @@ public class ItemEvents
|
||||||
itemHandler.extractItem(i, 64, false);
|
itemHandler.extractItem(i, 64, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (te instanceof IInventory)
|
||||||
|
{
|
||||||
|
IInventory inv = (IInventory) te;
|
||||||
|
inv.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (te instanceof IItemHandler)
|
||||||
|
{
|
||||||
|
IItemHandler itemHandler = (IItemHandler) te;
|
||||||
|
for (int i = 0; i < itemHandler.getSlots(); i++)
|
||||||
|
{
|
||||||
|
itemHandler.extractItem(i, 64, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user