diff --git a/build.gradle b/build.gradle index 35f69645..a212e141 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ targetCompat = JavaVersion.VERSION_1_8 minecraft { version = "1.11-13.19.0.2180" runDir = "run" - mappings = "snapshot_20161111" + mappings = "snapshot_20161204" makeObfSourceJar = false } diff --git a/src/main/java/baubles/api/cap/BaublesContainer.java b/src/main/java/baubles/api/cap/BaublesContainer.java index 9dfa7f54..dae1c3b6 100644 --- a/src/main/java/baubles/api/cap/BaublesContainer.java +++ b/src/main/java/baubles/api/cap/BaublesContainer.java @@ -29,7 +29,7 @@ public void setSize(int size) */ @Override public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player) { - if (stack == null || !(stack.getItem() instanceof IBauble) || + if (stack==null || stack.isEmpty() || !(stack.getItem() instanceof IBauble) || !((IBauble) stack.getItem()).canEquip(stack, player)) return false; diff --git a/src/main/java/baubles/api/inv/BaublesInventoryWrapper.java b/src/main/java/baubles/api/inv/BaublesInventoryWrapper.java index 07b6d5e3..c966cde7 100644 --- a/src/main/java/baubles/api/inv/BaublesInventoryWrapper.java +++ b/src/main/java/baubles/api/inv/BaublesInventoryWrapper.java @@ -43,9 +43,9 @@ public ITextComponent getDisplayName() { public int getSizeInventory() { return handler.getSlots(); } - + @Override - public boolean func_191420_l() { + public boolean isEmpty() { return false; } @@ -62,7 +62,7 @@ public ItemStack decrStackSize(int index, int count) { @Override public ItemStack removeStackFromSlot(int index) { ItemStack out = this.getStackInSlot(index); - handler.setStackInSlot(index, null); + handler.setStackInSlot(index, ItemStack.EMPTY); return out; } @@ -80,10 +80,10 @@ public int getInventoryStackLimit() { public void markDirty() { } @Override - public boolean isUseableByPlayer(EntityPlayer player) { + public boolean isUsableByPlayer(EntityPlayer player) { return true; } - + @Override public void openInventory(EntityPlayer player) { } @@ -112,8 +112,10 @@ public int getFieldCount() { public void clear() { for (int i = 0; i < this.getSizeInventory(); ++i) { - this.setInventorySlotContents(i, null); + this.setInventorySlotContents(i, ItemStack.EMPTY); } } + + } diff --git a/src/main/java/baubles/api/package-info.java b/src/main/java/baubles/api/package-info.java index 6cce6ed0..dd3bbd5e 100644 --- a/src/main/java/baubles/api/package-info.java +++ b/src/main/java/baubles/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Baubles", apiVersion = "1.3.1.1", provides = "Baubles|API") +@API(owner = "Baubles", apiVersion = "1.4.0.0", provides = "Baubles|API") package baubles.api; import net.minecraftforge.fml.common.API; diff --git a/src/main/java/baubles/client/BaublesRenderLayer.java b/src/main/java/baubles/client/BaublesRenderLayer.java index 44b322dc..faa470e7 100644 --- a/src/main/java/baubles/client/BaublesRenderLayer.java +++ b/src/main/java/baubles/client/BaublesRenderLayer.java @@ -53,7 +53,7 @@ public void doRenderLayer(@Nonnull EntityPlayer player, float limbSwing, float l private void dispatchRenders(IBaublesItemHandler inv, EntityPlayer player, RenderType type, float partialTicks) { for(int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack != null) { + if(stack != null && !stack.isEmpty()) { Item item = stack.getItem(); if(item instanceof IRenderBauble) { GlStateManager.pushMatrix(); diff --git a/src/main/java/baubles/client/ClientProxy.java b/src/main/java/baubles/client/ClientProxy.java index deba3e76..bf3a7614 100644 --- a/src/main/java/baubles/client/ClientProxy.java +++ b/src/main/java/baubles/client/ClientProxy.java @@ -41,7 +41,7 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int @Override public World getClientWorld() { - return FMLClientHandler.instance().getClient().theWorld; + return FMLClientHandler.instance().getClient().world; } @Override diff --git a/src/main/java/baubles/client/gui/GuiEvents.java b/src/main/java/baubles/client/gui/GuiEvents.java index 8ef02463..c94042f0 100644 --- a/src/main/java/baubles/client/gui/GuiEvents.java +++ b/src/main/java/baubles/client/gui/GuiEvents.java @@ -1,5 +1,8 @@ package baubles.client.gui; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketOpenBaublesInventory; +import baubles.common.network.PacketOpenNormalInventory; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.resources.I18n; @@ -7,9 +10,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import baubles.common.network.PacketHandler; -import baubles.common.network.PacketOpenBaublesInventory; -import baubles.common.network.PacketOpenNormalInventory; public class GuiEvents { @@ -31,14 +31,14 @@ public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) { if (event.getGui() instanceof GuiInventory) { if (event.getButton().id == 55) { - PacketHandler.INSTANCE.sendToServer(new PacketOpenBaublesInventory(event.getGui().mc.thePlayer)); + PacketHandler.INSTANCE.sendToServer(new PacketOpenBaublesInventory(event.getGui().mc.player)); } } if (event.getGui() instanceof GuiPlayerExpanded) { if (event.getButton().id == 55) { - event.getGui().mc.displayGuiScreen(new GuiInventory(event.getGui().mc.thePlayer)); - PacketHandler.INSTANCE.sendToServer(new PacketOpenNormalInventory(event.getGui().mc.thePlayer)); + event.getGui().mc.displayGuiScreen(new GuiInventory(event.getGui().mc.player)); + PacketHandler.INSTANCE.sendToServer(new PacketOpenNormalInventory(event.getGui().mc.player)); } } } diff --git a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java index 804187ad..94e542df 100644 --- a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java +++ b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java @@ -35,7 +35,7 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { public GuiPlayerExpanded(EntityPlayer player) { - super(new ContainerPlayerExpanded(player.inventory, !player.worldObj.isRemote, player)); + super(new ContainerPlayerExpanded(player.inventory, !player.getEntityWorld().isRemote, player)); this.allowUserInput = true; } @@ -96,11 +96,11 @@ protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2 Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1); if (slot.getHasStack() && slot.getSlotStackLimit()==1) { - this.drawTexturedModalRect(k+slot.xDisplayPosition, l+slot.yDisplayPosition, 200, 0, 16, 16); + this.drawTexturedModalRect(k+slot.xPos, l+slot.yPos, 200, 0, 16, 16); } } - drawPlayerModel(k + 51, l + 75, 30, (float)(k + 51) - this.xSizeFloat, (float)(l + 75 - 50) - this.ySizeFloat, this.mc.thePlayer); + drawPlayerModel(k + 51, l + 75, 30, (float)(k + 51) - this.xSizeFloat, (float)(l + 75 - 50) - this.ySizeFloat, this.mc.player); } public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase playerdrawn) @@ -149,12 +149,12 @@ protected void actionPerformed(GuiButton button) { if (button.id == 0) { - this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); + this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.player.getStatFileWriter())); } if (button.id == 1) { - this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); + this.mc.displayGuiScreen(new GuiStats(this, this.mc.player.getStatFileWriter())); } } @@ -162,7 +162,7 @@ protected void actionPerformed(GuiButton button) protected void keyTyped(char par1, int par2) throws IOException { if (par2 == Baubles.proxy.keyHandler.key.getKeyCode()) { - this.mc.thePlayer.closeScreen(); + this.mc.player.closeScreen(); } else super.keyTyped(par1, par2); } diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index fd202a79..fdb808c5 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -5,9 +5,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import baubles.api.cap.BaublesCapabilities.CapabilityBaubles; import baubles.api.cap.BaublesContainer; import baubles.api.cap.IBaublesItemHandler; -import baubles.api.cap.BaublesCapabilities.CapabilityBaubles; import baubles.common.event.CommandBaubles; import baubles.common.event.EventHandlerEntity; import baubles.common.network.PacketHandler; @@ -31,7 +31,7 @@ //dependencies="required-after:Forge@[13.19.0.2180,);") public class Baubles { - public static final String MODID = "Baubles"; + public static final String MODID = "baubles"; public static final String MODNAME = "Baubles"; public static final String VERSION = "1.4.0"; diff --git a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java index 453f0cad..b4cf8643 100644 --- a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java +++ b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java @@ -3,6 +3,7 @@ import baubles.api.IBauble; import baubles.api.cap.BaublesCapabilities; import baubles.api.cap.IBaublesItemHandler; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -64,14 +65,13 @@ public int getSlotStackLimit() @Override public boolean isItemValid(ItemStack stack) { - if (stack == null) - { - return false; - } - else - { - return stack.getItem().isValidArmor(stack, slot, thePlayer); - } + return stack.getItem().isValidArmor(stack, slot, player); + } + @Override + public boolean canTakeStack(EntityPlayer playerIn) + { + ItemStack itemstack = this.getStack(); + return !itemstack.isEmpty() && !playerIn.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false : super.canTakeStack(playerIn); } @Override @SideOnly(Side.CLIENT) @@ -130,7 +130,7 @@ public String getSlotTexture() @Override public void onCraftMatrixChanged(IInventory par1IInventory) { - this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj)); + this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.world)); } /** @@ -144,13 +144,13 @@ public void onContainerClosed(EntityPlayer player) { ItemStack itemstack = this.craftMatrix.removeStackFromSlot(i); - if (itemstack != null) + if (!itemstack.isEmpty()) { player.dropItem(itemstack, false); } } - this.craftResult.setInventorySlotContents(0, ItemStack.field_190927_a); + this.craftResult.setInventorySlotContents(0, ItemStack.EMPTY); } @Override @@ -163,10 +163,10 @@ public boolean canInteractWith(EntityPlayer par1EntityPlayer) * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(par2); + ItemStack itemstack = ItemStack.EMPTY; + Slot slot = (Slot)this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { @@ -177,36 +177,36 @@ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) int slotShift = baubles.getSlots(); - if (par2 == 0) + if (index == 0) { if (!this.mergeItemStack(itemstack1, 9+ slotShift, 45+ slotShift, true)) { - return null; + return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); } - else if (par2 >= 1 && par2 < 5) + else if (index >= 1 && index < 5) { if (!this.mergeItemStack(itemstack1, 9+ slotShift, 45+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } } - else if (par2 >= 5 && par2 < 9) + else if (index >= 5 && index < 9) { if (!this.mergeItemStack(itemstack1, 9+ slotShift, 45+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } } // baubles -> inv - else if (par2 >= 9 && par2 < 9+slotShift) + else if (index >= 9 && index < 9+slotShift) { if (!this.mergeItemStack(itemstack1, 9+ slotShift, 45+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } } @@ -217,7 +217,7 @@ else if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR && if (!this.mergeItemStack(itemstack1, i, i + 1, false)) { - return null; + return ItemStack.EMPTY; } } @@ -226,7 +226,7 @@ else if (entityequipmentslot == EntityEquipmentSlot.OFFHAND && !((Slot)this.inve { if (!this.mergeItemStack(itemstack1, 45+ slotShift, 46+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } } @@ -238,46 +238,53 @@ else if (itemstack.getItem() instanceof IBauble) if ( bauble.canEquip(itemstack1, thePlayer) && !((Slot)this.inventorySlots.get(baubleSlot+9)).getHasStack() && !this.mergeItemStack(itemstack1, baubleSlot+9, baubleSlot + 10, false)) { - return null; + return ItemStack.EMPTY; } - if (itemstack1.func_190916_E() == 0) break; + if (itemstack1.getCount() == 0) break; } } - else if (par2 >= 9+ slotShift && par2 < 36+ slotShift) + else if (index >= 9+ slotShift && index < 36+ slotShift) { if (!this.mergeItemStack(itemstack1, 36+ slotShift, 45+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } } - else if (par2 >= 36+ slotShift && par2 < 45+ slotShift) + else if (index >= 36+ slotShift && index < 45+ slotShift) { if (!this.mergeItemStack(itemstack1, 9+ slotShift, 36+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 9+ slotShift, 45+ slotShift, false)) { - return null; + return ItemStack.EMPTY; } - if (itemstack1.func_190916_E() == 0) + if (itemstack1.isEmpty()) { - slot.putStack((ItemStack)null); + slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } - if (itemstack1.func_190916_E() == itemstack.func_190916_E()) + if (itemstack1.getCount() == itemstack.getCount()) { - return null; + return ItemStack.EMPTY; } - slot.func_190901_a(par1EntityPlayer, itemstack1); + slot.onTake(playerIn, itemstack1); + + ItemStack itemstack2 = slot.onTake(playerIn, itemstack1); + + if (index == 0) + { + playerIn.dropItem(itemstack2, false); + } } return itemstack; diff --git a/src/main/java/baubles/common/container/SlotBauble.java b/src/main/java/baubles/common/container/SlotBauble.java index 83b45c68..0a47a5b6 100644 --- a/src/main/java/baubles/common/container/SlotBauble.java +++ b/src/main/java/baubles/common/container/SlotBauble.java @@ -25,7 +25,7 @@ public SlotBauble(EntityPlayer player, IBaublesItemHandler itemHandler, int slot @Override public boolean isItemValid(ItemStack stack) { - return stack!=null && stack.getItem() !=null && + return stack!=null && !stack.isEmpty() && stack.getItem() !=null && stack.getItem() instanceof IBauble && ((IBauble)stack.getItem()).getBaubleType(stack).hasSlot(baubleSlot) && ((IBauble)stack.getItem()).canEquip(stack, player); @@ -33,16 +33,17 @@ public boolean isItemValid(ItemStack stack) @Override public boolean canTakeStack(EntityPlayer player) { - return getStack()!=null && + return getStack()!=null && !getStack().isEmpty() && ((IBauble)getStack().getItem()).canUnequip(getStack(), player); } @Override - public ItemStack func_190901_a(EntityPlayer playerIn, ItemStack stack) { - if (!getHasStack() && !((IBaublesItemHandler)getItemHandler()).isEventBlocked()) { + public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) { + if (!getHasStack() && !((IBaublesItemHandler)getItemHandler()).isEventBlocked() && + stack.getItem() instanceof IBauble) { ((IBauble)stack.getItem()).onUnequipped(stack, playerIn); } - super.func_190901_a(playerIn, stack); + super.onTake(playerIn, stack); return stack; } diff --git a/src/main/java/baubles/common/event/CommandBaubles.java b/src/main/java/baubles/common/event/CommandBaubles.java index 2fe38975..c0b57056 100644 --- a/src/main/java/baubles/common/event/CommandBaubles.java +++ b/src/main/java/baubles/common/event/CommandBaubles.java @@ -25,17 +25,17 @@ public CommandBaubles() { } @Override - public String getCommandName() { + public String getName() { return "baubles"; } @Override - public List getCommandAliases() { + public List getAliases() { return aliases; } @Override - public String getCommandUsage(ICommandSender icommandsender) { + public String getUsage(ICommandSender icommandsender) { return "/baubles [ []]"; } @@ -52,30 +52,30 @@ public boolean isUsernameIndex(String[] astring, int i) { @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 2 || args[0].equalsIgnoreCase("help")) { - sender.addChatMessage(new TextComponentTranslation("\u00a73You can also use /baub or /bau instead of /baubles.")); - sender.addChatMessage(new TextComponentTranslation("\u00a73Use this to view the baubles inventory of a player.")); - sender.addChatMessage(new TextComponentTranslation(" /baubles view ")); - sender.addChatMessage(new TextComponentTranslation("\u00a73Use this to clear a players baubles inventory. Default is everything or you can give a slot number")); - sender.addChatMessage(new TextComponentTranslation(" /baubles clear []")); + sender.sendMessage(new TextComponentTranslation("\u00a73You can also use /baub or /bau instead of /baubles.")); + sender.sendMessage(new TextComponentTranslation("\u00a73Use this to view the baubles inventory of a player.")); + sender.sendMessage(new TextComponentTranslation(" /baubles view ")); + sender.sendMessage(new TextComponentTranslation("\u00a73Use this to clear a players baubles inventory. Default is everything or you can give a slot number")); + sender.sendMessage(new TextComponentTranslation(" /baubles clear []")); } else if (args.length >= 2) { EntityPlayerMP entityplayermp = getPlayer(server,sender,args[1]); if (entityplayermp==null) { - sender.addChatMessage(new TextComponentTranslation("\u00a7c"+args[1]+" not found")); + sender.sendMessage(new TextComponentTranslation("\u00a7c"+args[1]+" not found")); return; } IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(entityplayermp); if (args[0].equalsIgnoreCase("view")) { - sender.addChatMessage(new TextComponentTranslation("\u00a73Showing baubles for "+entityplayermp.getName())); + sender.sendMessage(new TextComponentTranslation("\u00a73Showing baubles for "+entityplayermp.getName())); for (int a = 0; a= baubles.getSlots()) { - sender.addChatMessage(new TextComponentTranslation("\u00a7cInvalid arguments")); - sender.addChatMessage(new TextComponentTranslation("\u00a7cUse /baubles help to get help")); + sender.sendMessage(new TextComponentTranslation("\u00a7cInvalid arguments")); + sender.sendMessage(new TextComponentTranslation("\u00a7cUse /baubles help to get help")); } else { - baubles.setStackInSlot(slot, null); - sender.addChatMessage(new TextComponentTranslation("\u00a73Cleared baubles slot "+slot+" for "+entityplayermp.getName())); - entityplayermp.addChatMessage(new TextComponentTranslation("\u00a74Your baubles slot "+slot+" has been cleared by admin "+sender.getName())); + baubles.setStackInSlot(slot, ItemStack.EMPTY); + sender.sendMessage(new TextComponentTranslation("\u00a73Cleared baubles slot "+slot+" for "+entityplayermp.getName())); + entityplayermp.sendMessage(new TextComponentTranslation("\u00a74Your baubles slot "+slot+" has been cleared by admin "+sender.getName())); } } else { for (int a = 0; a drops, Entity e) { IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player); for (int i = 0; i < baubles.getSlots(); ++i) { - if (baubles.getStackInSlot(i) != null) { - EntityItem ei = new EntityItem(e.worldObj, + if (baubles.getStackInSlot(i) != null && !baubles.getStackInSlot(i).isEmpty()) { + EntityItem ei = new EntityItem(e.world, e.posX, e.posY + e.getEyeHeight(), e.posZ, baubles.getStackInSlot(i).copy()); ei.setPickupDelay(40); - float f1 = e.worldObj.rand.nextFloat() * 0.5F; - float f2 = e.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; + float f1 = e.world.rand.nextFloat() * 0.5F; + float f2 = e.world.rand.nextFloat() * (float) Math.PI * 2.0F; ei.motionX = (double) (-MathHelper.sin(f2) * f1); ei.motionZ = (double) (MathHelper.cos(f2) * f1); ei.motionY = 0.20000000298023224D; drops.add(ei); - baubles.setStackInSlot(i, null); + baubles.setStackInSlot(i, ItemStack.EMPTY); } } } @@ -152,63 +152,10 @@ public void dropItemsAt(EntityPlayer player, List drops, Entity e) { @SubscribeEvent public void tooltipEvent(ItemTooltipEvent event) { - if (event.getItemStack()!=null && event.getItemStack().getItem() instanceof IBauble) { + if (event.getItemStack()!=null && !event.getItemStack().isEmpty() && event.getItemStack().getItem() instanceof IBauble) { BaubleType bt = ((IBauble)event.getItemStack().getItem()).getBaubleType(event.getItemStack()); event.getToolTip().add(TextFormatting.GOLD+I18n.translateToLocal("name."+bt)); } } - - - - @SubscribeEvent - public void playerLoad(PlayerEvent.LoadFromFile event) { - File file1 = getPlayerFile("baub", event.getPlayerDirectory(), event.getEntityPlayer().getDisplayNameString()); - if (file1.exists()) { - Baubles.log.info("Loading legacy baubles inventory for ["+event.getEntityPlayer().getDisplayNameString()+"]. Occupied slots will be skipped"); - loadPlayerBaubles(event.getEntityPlayer(), file1, getPlayerFile("baubback", event.getPlayerDirectory(), event.getEntityPlayer().getDisplayNameString())); - file1.delete(); - } - } - - public void loadPlayerBaubles(EntityPlayer player, File file1, File file2) { - if (player != null && !player.worldObj.isRemote) { - try { - NBTTagCompound data = null; - boolean save = false; - if (file1 != null && file1.exists()) { - try { - FileInputStream fileinputstream = new FileInputStream(file1); - data = CompressedStreamTools.readCompressed(fileinputstream); - fileinputstream.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - if (data != null) { - IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player); - NBTTagList tagList = data.getTagList("Baubles.Inventory", 10); - for (int i = 0; i < tagList.tagCount(); ++i) { - NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.getCompoundTagAt(i); - int j = nbttagcompound.getByte("Slot") & 255; - ItemStack itemstack = new ItemStack(nbttagcompound); - if (itemstack != null && baubles.getStackInSlot(j)==null) { - baubles.setStackInSlot(j, itemstack); - } - } - } - } catch (Exception exception1) { - Baubles.log.fatal("Error loading legacy baubles inventory"); - exception1.printStackTrace(); - } - } - } - - public File getPlayerFile(String suffix, File playerDirectory, String playername) - { - if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved"); - return new File(playerDirectory, "_"+playername+"."+suffix); - } - } diff --git a/src/main/java/baubles/common/items/ItemRing.java b/src/main/java/baubles/common/items/ItemRing.java index a4d7e97e..85d562a0 100644 --- a/src/main/java/baubles/common/items/ItemRing.java +++ b/src/main/java/baubles/common/items/ItemRing.java @@ -1,7 +1,5 @@ package baubles.common.items; -import java.util.List; - import baubles.api.BaubleType; import baubles.api.BaublesApi; import baubles.api.IBauble; @@ -52,10 +50,10 @@ public ActionResult onItemRightClick(World world, EntityPlayer player if(!world.isRemote) { IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player); for(int i = 0; i < baubles.getSlots(); i++) - if(baubles.getStackInSlot(i) == null && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) { + if((baubles.getStackInSlot(i) == null || baubles.getStackInSlot(i).isEmpty()) && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) { baubles.setStackInSlot(i, player.getHeldItem(hand).copy()); if(!player.capabilities.isCreativeMode){ - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY); } onEquipped(player.getHeldItem(hand), player); break; diff --git a/src/main/java/baubles/common/network/PacketOpenBaublesInventory.java b/src/main/java/baubles/common/network/PacketOpenBaublesInventory.java index fc89aed2..fa21c782 100644 --- a/src/main/java/baubles/common/network/PacketOpenBaublesInventory.java +++ b/src/main/java/baubles/common/network/PacketOpenBaublesInventory.java @@ -23,9 +23,9 @@ public void fromBytes(ByteBuf buffer) {} @Override public IMessage onMessage(PacketOpenBaublesInventory message, MessageContext ctx) { - IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; + IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.world; mainThread.addScheduledTask(new Runnable(){ public void run() { - ctx.getServerHandler().playerEntity.openGui(Baubles.instance, Baubles.GUI, ctx.getServerHandler().playerEntity.worldObj, (int)ctx.getServerHandler().playerEntity.posX, (int)ctx.getServerHandler().playerEntity.posY, (int)ctx.getServerHandler().playerEntity.posZ); + ctx.getServerHandler().playerEntity.openGui(Baubles.instance, Baubles.GUI, ctx.getServerHandler().playerEntity.world, (int)ctx.getServerHandler().playerEntity.posX, (int)ctx.getServerHandler().playerEntity.posY, (int)ctx.getServerHandler().playerEntity.posZ); }}); return null; } diff --git a/src/main/java/baubles/common/network/PacketOpenNormalInventory.java b/src/main/java/baubles/common/network/PacketOpenNormalInventory.java index ce99a21b..8774eb5c 100644 --- a/src/main/java/baubles/common/network/PacketOpenNormalInventory.java +++ b/src/main/java/baubles/common/network/PacketOpenNormalInventory.java @@ -22,7 +22,7 @@ public void fromBytes(ByteBuf buffer) {} @Override public IMessage onMessage(PacketOpenNormalInventory message, MessageContext ctx) { - IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; + IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.world; mainThread.addScheduledTask(new Runnable(){ public void run() { ctx.getServerHandler().playerEntity.openContainer.onContainerClosed(ctx.getServerHandler().playerEntity); ctx.getServerHandler().playerEntity.openContainer = ctx.getServerHandler().playerEntity.inventoryContainer; diff --git a/src/main/resources/changelog.txt b/src/main/resources/changelog.txt index 0940353c..5a960434 100644 --- a/src/main/resources/changelog.txt +++ b/src/main/resources/changelog.txt @@ -1,3 +1,7 @@ +1.4.0 +- update for MC 1.11 +- removed support for legacy baubles files (.baub) + 1.3.6 - catch edge-case crash if a player is somehow 'ticked' before the world has finished loading. Just do it better this time diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index ac7756d0..e1df31e5 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 1, + "pack_format": 3, "description": "Resources used for Baubles" } } \ No newline at end of file