Fixed imprinter glitching client side
This commit is contained in:
parent
b41b0f9d04
commit
156553a4f9
5 changed files with 82 additions and 80 deletions
|
@ -1 +1 @@
|
|||
76
|
||||
77
|
||||
|
|
1
info.txt
1
info.txt
|
@ -69,3 +69,4 @@ x AssemblyLine_v0.2.4.64.jar AssemblyLine_v0.2.4.64_api.zip
|
|||
@ AssemblyLine_v0.2.5.74.jar AssemblyLine_v0.2.5.74_api.zip
|
||||
@ AssemblyLine_v0.2.5.75.jar AssemblyLine_v0.2.5.75_api.zip
|
||||
* AssemblyLine_v0.2.5.76.jar AssemblyLine_v0.2.5.76_api.zip
|
||||
@ AssemblyLine_v0.2.6.77.jar AssemblyLine_v0.2.6.77_api.zip
|
||||
|
|
|
@ -25,14 +25,14 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18));
|
||||
this.addSlotToContainer(new WatchedSlot(this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this));
|
||||
}
|
||||
}
|
||||
|
||||
// Imprint Input for Imprinting
|
||||
this.addSlotToContainer(new SlotCustom(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START, 68, 34, new ItemStack(AssemblyLine.itemImprint)));
|
||||
// Item to be imprinted
|
||||
this.addSlotToContainer(new Slot(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 1, 92, 34));
|
||||
this.addSlotToContainer(new WatchedSlot(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 1, 92, 34, this));
|
||||
// Result of Crafting/Imprinting
|
||||
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
||||
|
||||
|
@ -134,7 +134,6 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
}
|
||||
|
||||
this.slotContentsChanged();
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
|
||||
|
@ -142,5 +141,6 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
public void slotContentsChanged()
|
||||
{
|
||||
this.tileEntity.onInventoryChanged();
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotCraftingResult extends Slot
|
||||
public class SlotCraftingResult extends WatchedSlot
|
||||
{
|
||||
private ContainerImprinter container;
|
||||
|
||||
public SlotCraftingResult(ContainerImprinter container, IInventory inventory, int par2, int par3, int par4)
|
||||
{
|
||||
super(inventory, par2, par3, par4);
|
||||
super(inventory, par2, par3, par4, container);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@ public class SlotCraftingResult extends Slot
|
|||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
|
||||
this.container.tileEntity.onPickUpFromResult(entityPlayer, itemStack);
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,98 +268,100 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
|
||||
/**
|
||||
* Makes the stamping recipe for filters
|
||||
*/
|
||||
this.isImprinting = false;
|
||||
|
||||
if (this.isMatrixEmpty() && this.imprinterMatrix[0] != null && this.imprinterMatrix[1] != null)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.imprinterMatrix[0].getItem() instanceof ItemImprinter)
|
||||
{
|
||||
ItemStack outputStack = this.imprinterMatrix[0].copy();
|
||||
outputStack.stackSize = 1;
|
||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(outputStack);
|
||||
boolean filteringItemExists = false;
|
||||
|
||||
for (ItemStack filteredStack : filters)
|
||||
{
|
||||
if (filteredStack.isItemEqual(this.imprinterMatrix[1]))
|
||||
{
|
||||
filters.remove(filteredStack);
|
||||
filteringItemExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!filteringItemExists)
|
||||
{
|
||||
filters.add(this.imprinterMatrix[1]);
|
||||
}
|
||||
|
||||
ItemImprinter.setFilters(outputStack, filters);
|
||||
this.imprinterMatrix[2] = outputStack;
|
||||
this.isImprinting = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isImprinting)
|
||||
{
|
||||
this.imprinterMatrix[2] = null;
|
||||
|
||||
/**
|
||||
* Try to craft from crafting grid. If not possible, then craft from imprint.
|
||||
* Makes the stamping recipe for filters
|
||||
*/
|
||||
boolean didCraft = false;
|
||||
this.isImprinting = false;
|
||||
|
||||
/**
|
||||
* Simulate an Inventory Crafting Instance
|
||||
*/
|
||||
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
||||
|
||||
if (inventoryCrafting != null)
|
||||
{
|
||||
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
||||
|
||||
if (matrixOutput != null)
|
||||
{
|
||||
this.imprinterMatrix[2] = matrixOutput;
|
||||
didCraft = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.imprinterMatrix[0] != null && !didCraft)
|
||||
if (this.isMatrixEmpty() && this.imprinterMatrix[0] != null && this.imprinterMatrix[1] != null)
|
||||
{
|
||||
if (this.imprinterMatrix[0].getItem() instanceof ItemImprinter)
|
||||
{
|
||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(this.imprinterMatrix[0]);
|
||||
ItemStack outputStack = this.imprinterMatrix[0].copy();
|
||||
outputStack.stackSize = 1;
|
||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(outputStack);
|
||||
boolean filteringItemExists = false;
|
||||
|
||||
for (ItemStack outputStack : filters)
|
||||
for (ItemStack filteredStack : filters)
|
||||
{
|
||||
if (outputStack != null)
|
||||
if (filteredStack.isItemEqual(this.imprinterMatrix[1]))
|
||||
{
|
||||
Pair<ItemStack, ItemStack[]> idealRecipe = this.getIdealRecipe(outputStack);
|
||||
filters.remove(filteredStack);
|
||||
filteringItemExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idealRecipe != null)
|
||||
if (!filteringItemExists)
|
||||
{
|
||||
filters.add(this.imprinterMatrix[1]);
|
||||
}
|
||||
|
||||
ItemImprinter.setFilters(outputStack, filters);
|
||||
this.imprinterMatrix[2] = outputStack;
|
||||
this.isImprinting = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isImprinting)
|
||||
{
|
||||
this.imprinterMatrix[2] = null;
|
||||
|
||||
/**
|
||||
* Try to craft from crafting grid. If not possible, then craft from imprint.
|
||||
*/
|
||||
boolean didCraft = false;
|
||||
|
||||
/**
|
||||
* Simulate an Inventory Crafting Instance
|
||||
*/
|
||||
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
||||
|
||||
if (inventoryCrafting != null)
|
||||
{
|
||||
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
||||
|
||||
if (matrixOutput != null)
|
||||
{
|
||||
this.imprinterMatrix[2] = matrixOutput;
|
||||
didCraft = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.imprinterMatrix[0] != null && !didCraft)
|
||||
{
|
||||
if (this.imprinterMatrix[0].getItem() instanceof ItemImprinter)
|
||||
{
|
||||
ArrayList<ItemStack> filters = ItemImprinter.getFilters(this.imprinterMatrix[0]);
|
||||
|
||||
for (ItemStack outputStack : filters)
|
||||
{
|
||||
if (outputStack != null)
|
||||
{
|
||||
ItemStack recipeOutput = idealRecipe.getKey();
|
||||
Pair<ItemStack, ItemStack[]> idealRecipe = this.getIdealRecipe(outputStack);
|
||||
|
||||
if (recipeOutput != null & recipeOutput.stackSize > 0)
|
||||
if (idealRecipe != null)
|
||||
{
|
||||
this.imprinterMatrix[2] = recipeOutput;
|
||||
didCraft = true;
|
||||
break;
|
||||
ItemStack recipeOutput = idealRecipe.getKey();
|
||||
|
||||
if (recipeOutput != null & recipeOutput.stackSize > 0)
|
||||
{
|
||||
this.imprinterMatrix[2] = recipeOutput;
|
||||
didCraft = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!didCraft)
|
||||
{
|
||||
this.imprinterMatrix[2] = null;
|
||||
if (!didCraft)
|
||||
{
|
||||
this.imprinterMatrix[2] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue