Added in all of the original files

This commit is contained in:
TheCricket committed 2014-10-27 16:26:14 -04:00
1 parent b61f5f1072
commit aa52debeb5
1764 files changed
+15476

No files matched your search

@@ -0,0 +1,76 @@
package info.jbcs.minecraft.chisel.inventory;
import info.jbcs.minecraft.chisel.block.tileentity.TileEntityAutoChisel;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerAutoChisel extends Container {
public static TileEntityAutoChisel autoChisel;
public static EntityPlayer player;
public ContainerAutoChisel(InventoryPlayer player, TileEntityAutoChisel tileEntityAutoChisel){
this.player = player.player;
autoChisel = tileEntityAutoChisel;
addSlotToContainer(new Slot(tileEntityAutoChisel, 0, 53, 15));
addSlotToContainer(new Slot(tileEntityAutoChisel, 1, 103, 15));
addSlotToContainer(new Slot(tileEntityAutoChisel, 2, 78, 51));
bindPlayerInventory(player);
}
protected void bindPlayerInventory(InventoryPlayer invPlayer){
for(int row = 0; row < 3; row++){
for(int column = 0; column < 9; column++){
addSlotToContainer(new Slot(invPlayer, column + row * 9 + 9, 8 + column * 18, 84 + row * 18));
}
}
for(int slotNumber = 0; slotNumber < 9; slotNumber++){
addSlotToContainer(new Slot(invPlayer, slotNumber, 8 + slotNumber * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return autoChisel.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
if(slotObject != null && slotObject.getHasStack()){
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if(slot < autoChisel.getSizeInventory()){
if(!this.mergeItemStack(stackInSlot, 0, 35, true)){
return null;
}
} else if(!this.mergeItemStack(stackInSlot, 0, 3, false)){
return null;
}
if(stackInSlot.stackSize == 0){
slotObject.putStack(null);
} else {
slotObject.onSlotChanged();
}
if(stackInSlot.stackSize == stack.stackSize){
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}
@@ -0,0 +1,128 @@
package info.jbcs.minecraft.chisel.inventory;
import info.jbcs.minecraft.chisel.carving.Carving;
import info.jbcs.minecraft.chisel.item.ItemChisel;
import info.jbcs.minecraft.utilities.General;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ContainerChisel extends Container
{
public final InventoryChiselSelection inventory;
public InventoryPlayer playerInventory;
int currentIndex;
public ItemStack chisel;
public boolean finished;
public Carving carving;
public ContainerChisel(InventoryPlayer inventoryplayer, InventoryChiselSelection inv)
{
inventory = inv;
playerInventory = inventoryplayer;
currentIndex = playerInventory.currentItem;
inv.container = this;
int[] leftOffsets = {8, 26, 134, 152, 44, 116};
int[] topOffsets = {8, 26, 44, 62};
for(int i = 0; i < 2; i++)
{
for(int y = 0; y < 4; y++)
{
for(int x = 0; x < 2; x++)
{
addSlotToContainer(new SlotChiselSelection(this, inventory, inventory, x + i * 8 + y * 2, leftOffsets[x + i * 2], topOffsets[y]));
}
}
}
for(int y = 0; y < 4; y++)
{
for(int x = 0; x < 2; x++)
{
addSlotToContainer(new SlotChiselSelection(this, inventory, inventory, 16 + x + y * 2, leftOffsets[4 + x], topOffsets[3 - y]));
}
}
addSlotToContainer(new SlotChiselInput(this, inventory, InventoryChiselSelection.normalSlots, 80, 35));
for(int k = 0; k < 3; k++)
{
for(int j1 = 0; j1 < 9; j1++)
{
addSlotToContainer(new Slot(inventoryplayer, j1 + k * 9 + 9, 8 + j1 * 18, 102 + k * 18 - 18));
}
}
for(int l = 0; l < 9; l++)
{
addSlotToContainer(l == currentIndex ?
new SlotChiselPlayer(this, inventoryplayer, l, 8 + l * 18, 160 - 18) :
new Slot(inventoryplayer, l, 8 + l * 18, 160 - 18)
);
}
chisel = inventoryplayer.getCurrentItem();
if(chisel.stackTagCompound != null)
{
ItemStack stack = ItemStack.loadItemStackFromNBT(chisel.stackTagCompound.getCompoundTag("chiselTarget"));
inventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, stack);
}
Item item = General.getItem(chisel);
carving = item instanceof ItemChisel ? ((ItemChisel) item).carving : Carving.chisel;
inventory.updateItems();
}
@Override
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer)
{
if(par3 == 2 && par2 == currentIndex)
return null;
return super.slotClick(par1, par2, par3, par4EntityPlayer);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
inventory.clearItems();
super.onContainerClosed(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return inventory.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entity, int i)
{
return null;
}
public void onChiselSlotChanged()
{
ItemStack stack = playerInventory.mainInventory[currentIndex];
if(!stack.isItemEqual(chisel)) finished = true;
if(finished) return;
if(chisel.stackTagCompound == null)
chisel.stackTagCompound = new NBTTagCompound();
NBTTagCompound tag = new NBTTagCompound();
if(inventory.getStackInSpecialSlot() != null)
inventory.getStackInSpecialSlot().writeToNBT(tag);
chisel.stackTagCompound.setTag("chiselTarget", tag);
playerInventory.mainInventory[currentIndex] = chisel;
}
}
@@ -0,0 +1,186 @@
package info.jbcs.minecraft.chisel.inventory;
import info.jbcs.minecraft.chisel.item.ItemChisel;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
public class InventoryChiselSelection implements IInventory
{
ItemStack chisel = null;
public final static int normalSlots = 32;
public int activeVariations = 0;
ContainerChisel container;
ItemStack[] inventory;
public InventoryChiselSelection(ItemStack c)
{
super();
inventory = new ItemStack[normalSlots + 1];
chisel = c;
}
public void onInventoryUpdate(int slot)
{
}
@Override
public int getSizeInventory()
{
return normalSlots + 1;
}
@Override
public ItemStack getStackInSlot(int var1)
{
return inventory[var1];
}
public void updateInventoryState(int slot)
{
onInventoryUpdate(slot);
}
@Override
public ItemStack decrStackSize(int slot, int amount)
{
if(this.inventory[slot] != null)
{
ItemStack stack;
if(this.inventory[slot].stackSize <= amount)
{
stack = this.inventory[slot];
this.inventory[slot] = null;
updateInventoryState(slot);
return stack;
} else
{
stack = this.inventory[slot].splitStack(amount);
if(this.inventory[slot].stackSize == 0)
this.inventory[slot] = null;
updateInventoryState(slot);
return stack;
}
} else return null;
}
@Override
public String getInventoryName()
{
return "container.chisel";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public void markDirty()
{
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return true;
}
public void clearItems()
{
activeVariations = 0;
for(int i = 0; i < normalSlots; i++)
{
inventory[i] = null;
}
}
public ItemStack getStackInSpecialSlot()
{
return inventory[normalSlots];
}
public void updateItems()
{
ItemStack chiseledItem = inventory[normalSlots];
clearItems();
if(chiseledItem == null)
{
container.onChiselSlotChanged();
return;
}
Item item = chiseledItem.getItem();
if(item == null) return;
if(Block.getBlockFromItem(item) == null)
return;
ArrayList<ItemStack> list = container.carving.getItems(chiseledItem);
activeVariations = 0;
while(activeVariations < normalSlots && activeVariations < list.size())
{
inventory[activeVariations] = list.get(activeVariations);
activeVariations++;
}
container.onChiselSlotChanged();
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
ItemStack stack = getStackInSlot(slot);
if(stack == null)
return null;
inventory[slot] = null;
updateInventoryState(slot);
return stack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack)
{
inventory[slot] = stack;
updateInventoryState(slot);
}
@Override
public void openInventory()
{
}
@Override
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack)
{
return !(stack != null && (stack.getItem() instanceof ItemChisel)) && i == normalSlots;
}
}
@@ -0,0 +1,42 @@
package info.jbcs.minecraft.chisel.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotChiselInput extends Slot
{
public SlotChiselInput(ContainerChisel container, InventoryChiselSelection inv, int i, int j, int k)
{
super(inv, i, j, k);
selInventory = inv;
this.container = container;
}
@Override
public boolean isItemValid(ItemStack itemstack)
{
if(container.finished) return false;
return super.isItemValid(itemstack);
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return !container.finished && super.canTakeStack(par1EntityPlayer);
}
@Override
public void onSlotChanged()
{
if(container.finished) return;
super.onSlotChanged();
selInventory.updateItems();
}
ContainerChisel container;
InventoryChiselSelection selInventory;
}
@@ -0,0 +1,47 @@
package info.jbcs.minecraft.chisel.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotChiselPlayer extends Slot
{
public SlotChiselPlayer(ContainerChisel container, InventoryPlayer inv, int i, int j, int k)
{
super(inv, i, j, k);
this.container = container;
selInventory = inv;
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack)
{
container.finished = true;
}
@Override
public boolean getHasStack()
{
return false;
}
@Override
public ItemStack decrStackSize(int i)
{
return null;
}
ContainerChisel container;
InventoryPlayer selInventory;
}
@@ -0,0 +1,86 @@
package info.jbcs.minecraft.chisel.inventory;
import info.jbcs.minecraft.utilities.General;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotChiselSelection extends Slot
{
public SlotChiselSelection(ContainerChisel container, InventoryChiselSelection inv, IInventory iinventory, int i, int j, int k)
{
super(iinventory, i, j, k);
this.container = container;
selInventory = inv;
}
@Override
public boolean isItemValid(ItemStack itemstack)
{
return false;
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
if(container.finished) return false;
return par1EntityPlayer.inventory.getItemStack() == null;
}
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack)
{
ItemStack stack = player.inventory.getItemStack();
ItemStack crafted = selInventory.inventory[InventoryChiselSelection.normalSlots];
if(stack == null)
{
if(crafted != null && crafted.stackSize > 0) crafted.stackSize--;
if(crafted.stackSize == 0) crafted = null;
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, crafted);
} else
{
putStack(new ItemStack(itemstack.getItem(), itemstack.stackSize, itemstack.getItemDamage()));
player.inventory.setItemStack(null);
if(selInventory.inventory[InventoryChiselSelection.normalSlots] == null) return;
player.inventory.setItemStack(new ItemStack(itemstack.getItem(), selInventory.inventory[InventoryChiselSelection.normalSlots].stackSize, itemstack.getItemDamage()));
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, null);
}
selInventory.updateItems();
String sound = container.carving.getVariationSound(itemstack.getItem(), itemstack.getItemDamage());
player.worldObj.playSoundAtEntity(player, sound, 0.3f + 0.7f * General.rand.nextFloat(), 0.6f + 0.4f * General.rand.nextFloat());
/* ItemStack stack=player.inventory.getItemStack();
putStack(new ItemStack(itemstack.itemID, itemstack.stackSize, itemstack.getItemDamage()));
super.onPickupFromSlot(player,itemstack);
player.inventory.setItemStack(null);
if(selInventory.items[InventoryChiselSelection.normalSlots]==null) return;
player.inventory.setItemStack(new ItemStack(itemstack.itemID, selInventory.items[InventoryChiselSelection.normalSlots].stackSize, itemstack.getItemDamage()));
selInventory.setInventorySlotContents(InventoryChiselSelection.normalSlots,null);
selInventory.updateItems();
String sound=Carving.chisel.getVariationSound(itemstack.itemID, itemstack.getItemDamage());
player.worldObj.playSoundAtEntity(player, sound, 0.3f + 0.7f * General.rand.nextFloat(), 0.6f + 0.4f * General.rand.nextFloat());
*/
}
ContainerChisel container;
InventoryChiselSelection selInventory;
}