use of com.codetaylor.mc.artisanworktables.modules.worktables.tile.RoundRobinGhostStackHandler in project artisan-worktables by codetaylor.
the class TileEntityBase method initialize.
protected void initialize(EnumType type) {
this.uuid = type.getName() + "." + this.getTier().getName();
this.craftingMatrixHandler = this.createCraftingMatrixHandler();
this.toolHandler = this.createToolHandler();
this.secondaryOutputHandler = this.createSecondaryOutputHandler();
this.resultHandler = new ItemStackHandler(1);
this.tank = this.createFluidTank(type);
{
ObservableStackHandler.IContentsChangedEventHandler contentsChangedEventHandler;
contentsChangedEventHandler = (stackHandler, slotIndex) -> {
this.markDirty();
this.requiresRecipeUpdate = true;
if (this.isLocked()) {
ItemStack stackInSlot = stackHandler.getStackInSlot(slotIndex);
if (!stackInSlot.isEmpty()) {
ItemStack copy = stackInSlot.copy();
copy.setCount(1);
this.craftingMatrixHandlerGhost.setStackInSlot(slotIndex, copy);
}
}
this.notifyBlockUpdate();
};
this.craftingMatrixHandler.addObserver(contentsChangedEventHandler);
this.toolHandler.addObserver(contentsChangedEventHandler);
this.secondaryOutputHandler.addObserver(contentsChangedEventHandler);
}
this.craftingMatrixHandlerGhost = new CraftingMatrixStackHandler(this.craftingMatrixHandler.getWidth(), this.craftingMatrixHandler.getHeight());
this.roundRobinGhostStackHandler = new RoundRobinGhostStackHandler(this, this.craftingMatrixHandler, this.craftingMatrixHandlerGhost);
{
ObservableStackHandler.IContentsChangedEventHandler contentsChangedEventHandler;
contentsChangedEventHandler = (stackHandler, slotIndex) -> {
this.markDirty();
};
this.craftingMatrixHandlerGhost.addObserver(contentsChangedEventHandler);
}
}
Aggregations