mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-16 10:45:02 +00:00
The great format and clean up. IMPORTANT: Read below.
All devs and contributors should use the provided formatter settings. If your IDE does not support the format, the rules are simple, it is the default java formatting rules, with 200char line lengths and 1 extra line after class definitions.
This commit is contained in:
1 parent
06c5f5930f
commit
82792ed22e
136 files changed
+10365
-11272
No files matched your search
@@ -12,118 +12,102 @@ import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.item.ItemChisel;
|
||||
import com.cricketcraft.chisel.utils.General;
|
||||
|
||||
public class ContainerChisel extends Container
|
||||
{
|
||||
public final InventoryChiselSelection inventory;
|
||||
public InventoryPlayer playerInventory;
|
||||
int currentIndex;
|
||||
public ItemStack chisel;
|
||||
public boolean finished;
|
||||
public Carving carving;
|
||||
public class ContainerChisel extends Container {
|
||||
|
||||
public ContainerChisel(InventoryPlayer inventoryplayer, InventoryChiselSelection inv)
|
||||
{
|
||||
inventory = inv;
|
||||
playerInventory = inventoryplayer;
|
||||
currentIndex = playerInventory.currentItem;
|
||||
inv.container = this;
|
||||
public final InventoryChiselSelection inventory;
|
||||
public InventoryPlayer playerInventory;
|
||||
int currentIndex;
|
||||
public ItemStack chisel;
|
||||
public boolean finished;
|
||||
public Carving carving;
|
||||
|
||||
int[] leftOffsets = {8, 26, 134, 152, 44, 116};
|
||||
int[] topOffsets = {8, 26, 44, 62};
|
||||
public ContainerChisel(InventoryPlayer inventoryplayer, InventoryChiselSelection inv) {
|
||||
inventory = inv;
|
||||
playerInventory = inventoryplayer;
|
||||
currentIndex = playerInventory.currentItem;
|
||||
inv.container = this;
|
||||
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
int[] leftOffsets = { 8, 26, 134, 152, 44, 116 };
|
||||
int[] topOffsets = { 8, 26, 44, 62 };
|
||||
|
||||
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]));
|
||||
}
|
||||
}
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotChiselInput(this, inventory, InventoryChiselSelection.normalSlots, 80, 35));
|
||||
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]));
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
addSlotToContainer(new SlotChiselInput(this, inventory, InventoryChiselSelection.normalSlots, 80, 35));
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
chisel = inventoryplayer.getCurrentItem();
|
||||
if(chisel.stackTagCompound != null)
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(chisel.stackTagCompound.getCompoundTag("chiselTarget"));
|
||||
inventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, stack);
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
Item item = General.getItem(chisel);
|
||||
carving = item instanceof ItemChisel ? ((ItemChisel) item).carving : Carving.chisel;
|
||||
chisel = inventoryplayer.getCurrentItem();
|
||||
if (chisel.stackTagCompound != null) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(chisel.stackTagCompound.getCompoundTag("chiselTarget"));
|
||||
inventory.setInventorySlotContents(InventoryChiselSelection.normalSlots, stack);
|
||||
}
|
||||
|
||||
inventory.updateItems();
|
||||
}
|
||||
Item item = General.getItem(chisel);
|
||||
carving = item instanceof ItemChisel ? ItemChisel.carving : Carving.chisel;
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer)
|
||||
{
|
||||
if(par3 == 2 && par2 == currentIndex)
|
||||
return null;
|
||||
inventory.updateItems();
|
||||
}
|
||||
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
}
|
||||
@Override
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
|
||||
if (par3 == 2 && par2 == currentIndex)
|
||||
return null;
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
inventory.clearItems();
|
||||
super.onContainerClosed(entityplayer);
|
||||
}
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return inventory.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
inventory.clearItems();
|
||||
super.onContainerClosed(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entity, int i)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return inventory.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
public void onChiselSlotChanged()
|
||||
{
|
||||
ItemStack stack = playerInventory.mainInventory[currentIndex];
|
||||
if(!stack.isItemEqual(chisel)) finished = true;
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entity, int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(finished) return;
|
||||
public void onChiselSlotChanged() {
|
||||
ItemStack stack = playerInventory.mainInventory[currentIndex];
|
||||
if (!stack.isItemEqual(chisel))
|
||||
finished = true;
|
||||
|
||||
if(chisel.stackTagCompound == null)
|
||||
chisel.stackTagCompound = new NBTTagCompound();
|
||||
if (finished)
|
||||
return;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if(inventory.getStackInSpecialSlot() != null)
|
||||
inventory.getStackInSpecialSlot().writeToNBT(tag);
|
||||
if (chisel.stackTagCompound == null)
|
||||
chisel.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
chisel.stackTagCompound.setTag("chiselTarget", tag);
|
||||
playerInventory.mainInventory[currentIndex] = chisel;
|
||||
}
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (inventory.getStackInSpecialSlot() != null)
|
||||
inventory.getStackInSpecialSlot().writeToNBT(tag);
|
||||
|
||||
chisel.stackTagCompound.setTag("chiselTarget", tag);
|
||||
playerInventory.mainInventory[currentIndex] = chisel;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user