mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 11:59:14 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -11,33 +11,26 @@ import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.inventory.*;
|
||||
|
||||
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory {
|
||||
boolean craftedTop;
|
||||
boolean craftedBottom;
|
||||
|
||||
public PartBuilderLogic()
|
||||
{
|
||||
public PartBuilderLogic() {
|
||||
super(10);
|
||||
craftedTop = false;
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "toolstation.parts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++) {
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++) {
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++) {
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (tile != null && tile instanceof PatternChestLogic && (x == xPos || z == zPos))
|
||||
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
|
||||
@@ -48,172 +41,132 @@ public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
public boolean canDropInventorySlot(int slot) {
|
||||
return slot <= 3; // 0-3 = only drop input slots
|
||||
}
|
||||
|
||||
//Called when emptying a slot, not when another item is placed in it
|
||||
// Called when emptying a slot, not when another item is placed in it
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slotID, int quantity)
|
||||
{
|
||||
public ItemStack decrStackSize(int slotID, int quantity) {
|
||||
ItemStack returnStack = super.decrStackSize(slotID, quantity);
|
||||
tryBuildPart(slotID);
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void tryBuildPart (int slotID)
|
||||
{
|
||||
if (slotID == 4 || slotID == 5)
|
||||
{
|
||||
if (!craftedTop && inventory[0] != null)
|
||||
{
|
||||
public void tryBuildPart(int slotID) {
|
||||
if (slotID == 4 || slotID == 5) {
|
||||
if (!craftedTop && inventory[0] != null) {
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[2]);
|
||||
IPattern item = (IPattern) inventory[0].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[0]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
if (value > 0 && cost > 0) {
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(2, decrease); //Call super to avoid crafting again
|
||||
if (cost % value != 0) decrease++;
|
||||
super.decrStackSize(2, decrease); // Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[4] != null || inventory[5] != null)
|
||||
craftedTop = true;
|
||||
else
|
||||
craftedTop = false;
|
||||
if (inventory[4] != null || inventory[5] != null) craftedTop = true;
|
||||
else craftedTop = false;
|
||||
}
|
||||
|
||||
if (!craftedTop)
|
||||
buildTopPart();
|
||||
if (!craftedTop) buildTopPart();
|
||||
|
||||
if (slotID == 6 || slotID == 7)
|
||||
{
|
||||
if (!craftedBottom && inventory[1] != null)
|
||||
{
|
||||
if (slotID == 6 || slotID == 7) {
|
||||
if (!craftedBottom && inventory[1] != null) {
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[3]);
|
||||
IPattern item = (IPattern) inventory[1].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[1]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
if (value > 0 && cost > 0) {
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(3, decrease); //Call super to avoid crafting again
|
||||
if (cost % value != 0) decrease++;
|
||||
super.decrStackSize(3, decrease); // Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[6] != null || inventory[7] != null)
|
||||
craftedBottom = true;
|
||||
else
|
||||
craftedBottom = false;
|
||||
if (inventory[6] != null || inventory[7] != null) craftedBottom = true;
|
||||
else craftedBottom = false;
|
||||
}
|
||||
|
||||
if (!craftedBottom)
|
||||
buildBottomPart();
|
||||
if (!craftedBottom) buildBottomPart();
|
||||
}
|
||||
|
||||
//Called when a slot has something placed into it.
|
||||
// Called when a slot has something placed into it.
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack) {
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if ((slot == 0 || slot == 2) && !craftedTop)
|
||||
buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom)
|
||||
buildBottomPart();
|
||||
if ((slot == 0 || slot == 2) && !craftedTop) buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom) buildBottomPart();
|
||||
}
|
||||
|
||||
void buildTopPart ()
|
||||
{
|
||||
void buildTopPart() {
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]);
|
||||
if (parts != null)
|
||||
{
|
||||
if (parts != null) {
|
||||
inventory[4] = parts[0];
|
||||
inventory[5] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inventory[4] = inventory[5] = null;
|
||||
}
|
||||
}
|
||||
|
||||
void buildBottomPart ()
|
||||
{
|
||||
void buildBottomPart() {
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
|
||||
if (parts != null)
|
||||
{
|
||||
if (parts != null) {
|
||||
inventory[6] = parts[0];
|
||||
inventory[7] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inventory[6] = inventory[7] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
craftedTop = tags.getBoolean("CraftedTop");
|
||||
craftedBottom = tags.getBoolean("CraftedBottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("CraftedTop", craftedTop);
|
||||
tags.setBoolean("CraftedBottom", craftedBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user