mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 12:42:19 +00:00
Sync recipe result pickup flag
This commit is contained in:
1 parent
01e9122700
commit
1585aa8e55
2 files changed
+31
No files matched your search
@@ -29,6 +29,7 @@ public class ContainerAnvilRepair extends Container {
|
||||
|
||||
private RecipeAnvil currentRecipe;
|
||||
private SlotAnvilOutput resultSlot;
|
||||
private boolean resultCanPickup = true;
|
||||
|
||||
public ContainerAnvilRepair(InventoryPlayer playerInv, World world, int x, int y, int z) {
|
||||
this.worldObj = world;
|
||||
@@ -172,6 +173,7 @@ public class ContainerAnvilRepair extends Container {
|
||||
}
|
||||
|
||||
anvilResult.setInventorySlotContents(0, output);
|
||||
this.resultCanPickup = canPickup;
|
||||
if (this.resultSlot != null) {
|
||||
this.resultSlot.setCanPickup(canPickup);
|
||||
}
|
||||
@@ -184,6 +186,7 @@ public class ContainerAnvilRepair extends Container {
|
||||
public void addCraftingToCrafters(ICrafting listener) {
|
||||
super.addCraftingToCrafters(listener);
|
||||
listener.sendProgressBarUpdate(this, 0, this.repairCost);
|
||||
listener.sendProgressBarUpdate(this, 1, this.resultCanPickup ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,6 +194,7 @@ public class ContainerAnvilRepair extends Container {
|
||||
super.detectAndSendChanges();
|
||||
for (Object crafterObj : this.crafters) {
|
||||
((ICrafting) crafterObj).sendProgressBarUpdate(this, 0, this.repairCost);
|
||||
((ICrafting) crafterObj).sendProgressBarUpdate(this, 1, this.resultCanPickup ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +202,8 @@ public class ContainerAnvilRepair extends Container {
|
||||
public void updateProgressBar(int id, int data) {
|
||||
if (id == 0) {
|
||||
this.repairCost = data;
|
||||
} else if (id == 1 && this.resultSlot != null) {
|
||||
this.resultSlot.setCanPickup(data != 0);
|
||||
}
|
||||
}
|
||||
// --- End Sync Methods ---
|
||||
|
||||
@@ -24,6 +24,7 @@ public class ContainerCarpentryBench extends Container {
|
||||
|
||||
private RecipeCarpentry currentRecipe;
|
||||
private SlotCarpentryResult resultSlot;
|
||||
private boolean resultCanPickup = true;
|
||||
|
||||
public ContainerCarpentryBench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) {
|
||||
this.worldObj = par2World;
|
||||
@@ -84,6 +85,7 @@ public class ContainerCarpentryBench extends Container {
|
||||
}
|
||||
|
||||
this.craftResult.setInventorySlotContents(0, item);
|
||||
this.resultCanPickup = canPickup;
|
||||
if (this.resultSlot != null) {
|
||||
this.resultSlot.setCanPickup(canPickup);
|
||||
}
|
||||
@@ -175,6 +177,29 @@ public class ContainerCarpentryBench extends Container {
|
||||
return slotIn.inventory != this.craftResult && super.func_94530_a(stack, slotIn);
|
||||
}
|
||||
|
||||
// --- Sync Methods ---
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting listener) {
|
||||
super.addCraftingToCrafters(listener);
|
||||
listener.sendProgressBarUpdate(this, 0, this.resultCanPickup ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (Object crafterObj : this.crafters) {
|
||||
((ICrafting) crafterObj).sendProgressBarUpdate(this, 0, this.resultCanPickup ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int id, int data) {
|
||||
if (id == 0 && this.resultSlot != null) {
|
||||
this.resultSlot.setCanPickup(data != 0);
|
||||
}
|
||||
}
|
||||
// --- End Sync Methods ---
|
||||
|
||||
// Custom result slot to handle recipe scripts
|
||||
private class SlotCarpentryResult extends SlotCrafting {
|
||||
private final ContainerCarpentryBench container;
|
||||
|
||||
Reference in new issue
Block a user