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:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

@@ -12,8 +12,7 @@ import tconstruct.tools.TinkerTools;
import tconstruct.tools.logic.PartBuilderLogic;
import tconstruct.tools.logic.PatternChestLogic;
public class PartCrafterChestContainer extends ActiveContainer
{
public class PartCrafterChestContainer extends ActiveContainer {
protected PatternChestLogic patternLogic;
protected InventoryPlayer invPlayer;
protected PartBuilderLogic logic;
@@ -21,82 +20,73 @@ public class PartCrafterChestContainer extends ActiveContainer
protected Slot[] inventory;
public boolean largeInventory;
public PartCrafterChestContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic, PatternChestLogic pLogic)
{
public PartCrafterChestContainer(
InventoryPlayer inventoryplayer, PartBuilderLogic partLogic, PatternChestLogic pLogic) {
logic = partLogic;
patternLogic = pLogic;
largeInventory = true;
inventory = new Slot[] { new SlotPattern(partLogic, 0, 156, 27), new SlotPattern(partLogic, 1, 156, 45), new Slot(partLogic, 2, 174, 27), new Slot(partLogic, 3, 174, 45), new SlotOnlyTake(partLogic, 4, 218, 27), new SlotOnlyTake(partLogic, 5, 236, 27), new SlotOnlyTake(partLogic, 6, 218, 45), new SlotOnlyTake(partLogic, 7, 236, 45) };
for (int iter = 0; iter < inventory.length; iter++)
this.addSlotToContainer(inventory[iter]);
inventory = new Slot[] {
new SlotPattern(partLogic, 0, 156, 27),
new SlotPattern(partLogic, 1, 156, 45),
new Slot(partLogic, 2, 174, 27),
new Slot(partLogic, 3, 174, 45),
new SlotOnlyTake(partLogic, 4, 218, 27),
new SlotOnlyTake(partLogic, 5, 236, 27),
new SlotOnlyTake(partLogic, 6, 218, 45),
new SlotOnlyTake(partLogic, 7, 236, 45)
};
for (int iter = 0; iter < inventory.length; iter++) this.addSlotToContainer(inventory[iter]);
/* Holder inventory */
for (int column = 0; column < 5; column++)
{
for (int row = 0; row < 6; row++)
{
for (int column = 0; column < 5; column++) {
for (int row = 0; row < 6; row++) {
this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, 8 + row * 18, 30 + column * 18));
}
}
/* Player inventory */
for (int column = 0; column < 3; column++)
{
for (int row = 0; row < 9; row++)
{
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 124 + row * 18, 84 + column * 18));
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 9; row++) {
this.addSlotToContainer(
new Slot(inventoryplayer, row + column * 9 + 9, 124 + row * 18, 84 + column * 18));
}
}
for (int column = 0; column < 9; column++)
{
for (int column = 0; column < 9; column++) {
this.addSlotToContainer(new Slot(inventoryplayer, column, 124 + column * 18, 142));
}
}
@Override
public boolean canInteractWith (EntityPlayer entityplayer)
{
public boolean canInteractWith(EntityPlayer entityplayer) {
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
return false;
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood) return false;
return logic.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
if (slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
int inventorySize = this.inventory.length + this.patternLogic.getSizeInventory();
if (slotID < inventorySize)
{
if (!this.mergeItemStack(slotStack, inventorySize, this.inventorySlots.size(), true))
{
if (slotID < inventorySize) {
if (!this.mergeItemStack(slotStack, inventorySize, this.inventorySlots.size(), true)) {
return null;
}
}
else
{
if (slotStack.getItem() instanceof IPattern)
{
} else {
if (slotStack.getItem() instanceof IPattern) {
if (!this.mergeItemStack(slotStack, 0, 2, false) && !this.mergeItemStack(slotStack, 8, 38, false))
return null;
}
else if (!this.mergeItemStack(slotStack, 2, 4, false))
return null;
} else if (!this.mergeItemStack(slotStack, 2, 4, false)) return null;
}
if (slotStack.stackSize == 0)
{
if (slotStack.stackSize == 0) {
slot.putStack(null);
logic.tryBuildPart(slotID);
}