Skip to content

Commit

Permalink
update for mc 1.11
Browse files Browse the repository at this point in the history
switch to latest mapping, added final touches for update and added
missing checks for empty itemstacks. Also removed legacy file support
  • Loading branch information
Azanor committed Dec 5, 2016
1 parent 7a74942 commit a07373f
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 160 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baubles/api/cap/BaublesContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 8 additions & 6 deletions src/main/java/baubles/api/inv/BaublesInventoryWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public ITextComponent getDisplayName() {
public int getSizeInventory() {
return handler.getSlots();
}

@Override
public boolean func_191420_l() {
public boolean isEmpty() {
return false;
}

Expand All @@ -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;
}

Expand All @@ -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) { }

Expand Down Expand Up @@ -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);
}
}



}
2 changes: 1 addition & 1 deletion src/main/java/baubles/api/package-info.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baubles/client/BaublesRenderLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baubles/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/baubles/client/gui/GuiEvents.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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;
import net.minecraftforge.client.event.GuiScreenEvent;
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 {

Expand All @@ -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));
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/baubles/client/gui/GuiPlayerExpanded.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -149,20 +149,20 @@ 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()));
}
}

@Override
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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/baubles/common/Baubles.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";

Expand Down
79 changes: 43 additions & 36 deletions src/main/java/baubles/common/container/ContainerPlayerExpanded.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}

/**
Expand All @@ -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
Expand All @@ -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())
{
Expand All @@ -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;
}
}

Expand All @@ -217,7 +217,7 @@ else if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR &&

if (!this.mergeItemStack(itemstack1, i, i + 1, false))
{
return null;
return ItemStack.EMPTY;
}
}

Expand All @@ -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;
}
}

Expand All @@ -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;
Expand Down
Loading

0 comments on commit a07373f

Please sign in to comment.