diff --git a/src/main/java/tschipp/carryon/CarryOn.java b/src/main/java/tschipp/carryon/CarryOn.java index 66c08da..f4289f5 100644 --- a/src/main/java/tschipp/carryon/CarryOn.java +++ b/src/main/java/tschipp/carryon/CarryOn.java @@ -29,7 +29,7 @@ public class CarryOn { public static CarryOn instance; public static final String MODID = "carryon"; - public static final String VERSION = "1.4"; + public static final String VERSION = "1.4.1"; public static final String NAME = "Carry On"; public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/"; public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn"); diff --git a/src/main/java/tschipp/carryon/common/event/ItemEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEvents.java index 86bcfc2..2d7f5a3 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEvents.java +++ b/src/main/java/tschipp/carryon/common/event/ItemEvents.java @@ -13,6 +13,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.ClickEvent.Action; import net.minecraft.world.World; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -107,18 +111,31 @@ public class ItemEvents { if (ItemTile.storeTileData(te, world, pos, state.getActualState(world, pos), stack)) { - CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem), (EntityPlayerMP) player); - if (world.getTileEntity(pos) != null) + IBlockState statee = world.getBlockState(pos); + NBTTagCompound tag = new NBTTagCompound(); + tag = world.getTileEntity(pos) != null ? world.getTileEntity(pos).writeToNBT(tag) : new NBTTagCompound(); + + try { - TileEntity newtile = world.getTileEntity(pos).getClass().newInstance(); + CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem), (EntityPlayerMP) player); world.removeTileEntity(pos); - world.setTileEntity(pos, newtile); + world.setBlockToAir(pos); + player.setHeldItem(EnumHand.MAIN_HAND, stack); + event.setUseBlock(Result.DENY); + event.setCanceled(true); + } + catch (Exception e) + { + CarryOn.network.sendTo(new CarrySlotPacket(9), (EntityPlayerMP) player); + world.setBlockState(pos, statee); + if (!tag.hasNoTags()) + TileEntity.create(world, tag); + + player.addChatMessage(new TextComponentString(TextFormatting.RED + "Error detected. Cannot pick up block.")); + TextComponentString s = new TextComponentString(TextFormatting.GOLD + "here"); + s.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/Tschipp/CarryOn/issues")); + player.addChatMessage(new TextComponentString(TextFormatting.RED + "Please report this error ").appendSibling(s)); } - world.setBlockToAir(pos); - player.setHeldItem(EnumHand.MAIN_HAND, stack); - event.setUseBlock(Result.DENY); - event.setCanceled(true); - } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 5da688d..f27ffa9 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid" : "carryon", "name" : "Carry On", - "version" : "1.4", "mcversion" : "1.10.2", + "version" : "1.4.1", "mcversion" : "1.10.2", "url" : "", "credits" : "Tschipp, Purplicious_Cow, cy4n", "authorList" : ["Tschipp, Purplicious_Cow, cy4n"],