Skip to content

Commit

Permalink
feat: fix bq crafting quest | based on GTNewHorizons@769fb24
Browse files Browse the repository at this point in the history
  • Loading branch information
KorewaLidesu committed Mar 3, 2024
1 parent 7fb49fc commit 01ca1e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public GuiRequestTable(EntityPlayer entityPlayer, PipeBlockRequestTable table) {
dummy.addDummySlot(i++, guiLeft + (x * 18) + 20, guiTop + (y * 18) + 15);
}
}
dummy.addCallableSlotHandler(0, _table.resultInv, guiLeft + 101, guiTop + 33, _table::getResultForClick);
dummy.addCallableSlotHandler(0, _table.resultInv, guiLeft + 101, guiTop + 33, () -> _table.getResultForClick(entityPlayer));
dummy.addNormalSlot(0, _table.getModuleRequesterTable().toSortInv, guiLeft + 164, guiTop + 51);
dummy.addNormalSlot(0, _table.getModuleRequesterTable().diskInv, guiLeft + 164, guiTop + 25);
dummy.addNormalSlotsForPlayerInventory(20, 150);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/logisticspipes/network/GuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void guiClosedByPlayer(EntityPlayer player) {
dummy.addDummySlot(i++, 0, 0);
}
}
dummy.addCallableSlotHandler(0, ((PipeBlockRequestTable) pipe.pipe).resultInv, 0, 0, () -> ((PipeBlockRequestTable) fpipe.pipe).getResultForClick());
dummy.addCallableSlotHandler(0, ((PipeBlockRequestTable) pipe.pipe).resultInv, 0, 0, () -> ((PipeBlockRequestTable) fpipe.pipe).getResultForClick(player));
dummy.addNormalSlot(0, ((PipeBlockRequestTable) pipe.pipe).getModuleRequesterTable().toSortInv, 0, 0);
dummy.addNormalSlot(0, ((PipeBlockRequestTable) pipe.pipe).getModuleRequesterTable().diskInv, 0, 0);
dummy.addNormalSlotsForPlayerInventory(0, 0);
Expand Down
35 changes: 19 additions & 16 deletions src/main/java/logisticspipes/pipes/PipeBlockRequestTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public void cycleRecipe(boolean down) {
}

@Nonnull
public ItemStack getOutput(boolean oreDict) {
public ItemStack getOutput(EntityPlayer player, boolean oreDict) {
if (cache == null) {
cacheRecipe();
if (cache == null) {
Expand Down Expand Up @@ -443,9 +443,10 @@ public ItemStack getOutput(boolean oreDict) {
if (fake == null) {
fake = MainProxy.getFakePlayer(getWorld());
}
EntityPlayer playerToUse = player == null ? fake : player;
result = result.copy();

SlotCrafting craftingSlot = new SlotCrafting(fake, crafter, resultInv, 0, 0, 0) {
SlotCrafting craftingSlot = new SlotCrafting(playerToUse, crafter, resultInv, 0, 0, 0) {

@Override
protected void onCrafting(@Nonnull ItemStack stack) {
Expand All @@ -456,7 +457,7 @@ protected void onCrafting(@Nonnull ItemStack stack) {
this.inventory = tmp;
}
};
result = craftingSlot.onTake(fake, result);
result = craftingSlot.onTake(playerToUse, result);
for (int i = 0; i < 9; i++) {
ItemStack left = crafter.getStackInSlot(i);
crafter.setInventorySlotContents(i, ItemStack.EMPTY);
Expand All @@ -467,25 +468,27 @@ protected void onCrafting(@Nonnull ItemStack stack) {
}
}
}
for (int i = 0; i < fake.inventory.getSizeInventory(); i++) {
ItemStack left = fake.inventory.getStackInSlot(i);
fake.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
if (!left.isEmpty()) {
left.setCount(moduleRequesterTable.inv.addCompressed(left, false));
if (left.getCount() > 0) {
ItemIdentifierInventory.dropItems(getWorld(), left, getX(), getY(), getZ());
}
}
}
if (playerToUse == fake) {
for (int i = 0; i < fake.inventory.getSizeInventory(); i++) {
ItemStack left = fake.inventory.getStackInSlot(i);
fake.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
if (!left.isEmpty()) {
left.setCount(moduleRequesterTable.inv.addCompressed(left, false));
if (left.getCount() > 0) {
ItemIdentifierInventory.dropItems(getWorld(), left, getX(), getY(), getZ());
}
}
}
}
return result;
}

@Nonnull
public ItemStack getResultForClick() {
public ItemStack getResultForClick(EntityPlayer player) {
if (MainProxy.isServer(getWorld())) {
ItemStack result = getOutput(true);
ItemStack result = getOutput(player, true);
if (result.isEmpty()) {
result = getOutput(false);
result = getOutput(player, false);
}
if (result.isEmpty()) {
return ItemStack.EMPTY;
Expand Down

0 comments on commit 01ca1e8

Please sign in to comment.