Merge pull request #741 from Dynious/master

Fixed #735, #733, #731
This commit is contained in:
Pahimar 2014-10-17 10:04:43 -04:00
commit f1c513768e
4 changed files with 81 additions and 45 deletions

View file

@ -80,7 +80,6 @@ public class ItemRendererGlassBell implements IItemRenderer
modelGlassBell.render();
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
}

View file

@ -1,5 +1,7 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.item.ItemGem;
import com.pahimar.ee3.item.ItemToolEE;
import com.pahimar.ee3.tileentity.TileEntityAugmentationTable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -37,6 +39,73 @@ public class ContainerAugmentationTable extends ContainerEE
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
return super.transferStackInSlot(entityPlayer, slotIndex);
ItemStack itemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack slotItemStack = slot.getStack();
itemStack = slotItemStack.copy();
/**
* If we are shift-clicking an item out of the AugmentationTable's container,
* attempt to put it in the first available slot in the player's
* inventory
*/
if (slotIndex < TileEntityAugmentationTable.INVENTORY_SIZE)
{
if (!this.mergeItemStack(slotItemStack, TileEntityAugmentationTable.INVENTORY_SIZE, inventorySlots.size(), false))
{
return null;
}
}
else
{
/**
* If the stack being shift-clicked into the AugmentationTable's container
* is a tool(?), first try to put it in the tool slot.
*/
//TODO: create IAugmentable(?) interface
if (slotItemStack.getItem() instanceof ItemToolEE)
{
if (!this.mergeItemStack(slotItemStack, TileEntityAugmentationTable.INPUT_SLOT_INVENTORY_INDEX, TileEntityAugmentationTable.AUGMENT_SLOT_INVENTORY_INDEX, false))
{
return null;
}
}
/**
* If the stack being shift-clicked into the AugmentationTable's container
* is an augment(?), try to put it in the augment slot.
*/
else if (slotItemStack.getItem() instanceof ItemGem)
{
if (!this.mergeItemStack(slotItemStack, TileEntityAugmentationTable.AUGMENT_SLOT_INVENTORY_INDEX, TileEntityAugmentationTable.OUTPUT_SLOT_INVENTORY_INDEX, false))
{
return null;
}
}
/**
* If the stack is not augmentable or an augment don't add it in a slot
*/
else
{
return null;
}
}
if (slotItemStack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
}
return itemStack;
}
}

View file

@ -33,7 +33,9 @@ public class ItemAlchemicalTome extends ItemEE implements IOwnable
{
// Set the owner
ItemHelper.setOwner(itemStack, entityPlayer);
}
else
{
entityPlayer.openGui(EquivalentExchange3.instance, GUIs.ALCHEMICAL_TOME.ordinal(), entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ);
}

View file

@ -1,14 +1,12 @@
package com.pahimar.ee3.network.message;
import com.pahimar.ee3.reference.Colors;
import com.pahimar.ee3.tileentity.TileEntityGlassBell;
import com.pahimar.ee3.util.ColorHelper;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -18,7 +16,7 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler<Mes
public byte orientation;
public byte state;
public String customName, owner;
public int itemId, metaData, stackSize, itemColor;
public ItemStack outputItemStack;
public MessageTileEntityGlassBell()
{
@ -33,21 +31,7 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler<Mes
this.state = (byte) tileEntityGlassBell.getState();
this.customName = tileEntityGlassBell.getCustomName();
this.owner = tileEntityGlassBell.getOwner();
if (outputItemStack != null)
{
this.itemId = Item.getIdFromItem(outputItemStack.getItem());
this.metaData = outputItemStack.getItemDamage();
this.stackSize = outputItemStack.stackSize;
this.itemColor = ColorHelper.getColor(outputItemStack);
}
else
{
this.itemId = -1;
this.metaData = 0;
this.stackSize = 0;
this.itemColor = 0;
}
this.outputItemStack = outputItemStack;
}
@Override
@ -62,10 +46,7 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler<Mes
this.customName = new String(buf.readBytes(customNameLength).array());
int ownerLength = buf.readInt();
this.owner = new String(buf.readBytes(ownerLength).array());
this.itemId = buf.readInt();
this.metaData = buf.readInt();
this.stackSize = buf.readInt();
this.itemColor = buf.readInt();
outputItemStack = ByteBufUtils.readItemStack(buf);
}
@Override
@ -80,10 +61,7 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler<Mes
buf.writeBytes(customName.getBytes());
buf.writeInt(owner.length());
buf.writeBytes(owner.getBytes());
buf.writeInt(itemId);
buf.writeInt(metaData);
buf.writeInt(stackSize);
buf.writeInt(itemColor);
ByteBufUtils.writeItemStack(buf, outputItemStack);
}
@Override
@ -97,19 +75,7 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler<Mes
((TileEntityGlassBell) tileEntity).setState(message.state);
((TileEntityGlassBell) tileEntity).setCustomName(message.customName);
((TileEntityGlassBell) tileEntity).setOwner(message.owner);
ItemStack outputItemStack = null;
if (message.itemId != -1)
{
outputItemStack = new ItemStack(Item.getItemById(message.itemId), message.stackSize, message.metaData);
if (message.itemColor != Integer.parseInt(Colors.PURE_WHITE, 16))
{
ColorHelper.setColor(outputItemStack, itemColor);
}
}
((TileEntityGlassBell) tileEntity).outputItemStack = outputItemStack;
((TileEntityGlassBell) tileEntity).outputItemStack = message.outputItemStack;
//NAME UPDATE
FMLClientHandler.instance().getClient().theWorld.func_147451_t(message.x, message.y, message.z);
@ -121,6 +87,6 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler<Mes
@Override
public String toString()
{
return String.format("MessageTileEntityGlassBell - x:%s, y:%s, z:%s, orientation:%s, state:%s, customName:%s, owner:%s, itemId: %s, metaData: %s, stackSize: %s, itemColor: %s", x, y, z, orientation, state, customName, owner, itemId, metaData, stackSize, itemColor);
return String.format("MessageTileEntityGlassBell - x:%s, y:%s, z:%s, orientation:%s, state:%s, customName:%s, owner:%s, outputItemStack: %s", x, y, z, orientation, state, customName, owner, outputItemStack.toString());
}
}