Using dedicated item handler instances to circumvent FML mapping issues of getStackInSlot().
This commit is contained in:
parent
5b1a6e0877
commit
dcf8a27d82
7 changed files with 267 additions and 228 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
|
||||
"1.12.2": {
|
||||
"1.0.6-b1": "[A] Added small waste incinerator (delayed fifo-buffered item disposal).\n[M] Fixed item/block name capitalization (by Voxelo).\n[M] Metal ladders are easier to break/harvest.",
|
||||
"1.0.6-b1": "[A] Added small waste incinerator (delayed fifo-buffered item disposal).\n[M] Fixed item/block name capitalization (by Voxelo).\n[M] Metal ladders are easier to break/harvest.\n[F] Fixed FML remapping issue by using dedicated IItemHandler instances.",
|
||||
"1.0.5": "[R] Release based on v1.0.5-b1. Release-to-release changes: * Small electrical passthrough-furnace added. * Passive fluid accumulator added. * Config options added. * Sign plates added. * Minor bug fixes.\n[A] Added sign \"Electrical hazzard\"/\"Caution hot wire\".\n[A] Added sign \"Caution dangerous there\" (skull/bones).",
|
||||
"1.0.5-b1": "[A] Added passive fluid accumulator.\n[A] Added small electrical passthrough-furnace.\n[F] Fixed version check URL.\n[M] Opt-out config options for valves, passive fluid accumulator, and furni.",
|
||||
"1.0.4": "[R] Release based on v1.0.4-b9. Release-to-release changes: * Crafting table: Quick crafting history re-fab, JEI integration. * Rendering improvements and issue fixes (stairs, ambient occlusion, optifine, etc). * Walls with texture variations. * Thin/thick steel poles with support feet/heads. * Horizontal steel double-T support beams added. * Fluid pipe valves added: Check valve, redstone controlled valve, analog redstone controlled valve. Support pressurized transfer. * Tool tip documentation (CTRL-SHIFT) for stairs added. * Internal code cleanups. * Recipes tuned.\n[E] Added pass-through electrical furnace (experimental, see config).",
|
||||
|
|
|
@ -13,6 +13,7 @@ Mod sources for Minecraft version 1.12.2.
|
|||
- v1.0.6-b1 [A] Added small waste incinerator (delayed fifo-buffered item disposal).
|
||||
[M] Fixed item/block name capitalization (by Voxelo).
|
||||
[M] Metal ladders are easier to break/harvest.
|
||||
[F] Fixed FML remapping issue by using dedicated IItemHandler instances.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
- v1.0.5 [R] Release based on v1.0.5-b1. Release-to-release changes:
|
||||
|
|
|
@ -391,7 +391,7 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
// Tile entity
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static class BTileEntity extends TileEntity implements ITickable, ISidedInventory, IItemHandler, Networking.IPacketReceiver
|
||||
public static class BTileEntity extends TileEntity implements ITickable, ISidedInventory, Networking.IPacketReceiver
|
||||
{
|
||||
public static final int TICK_INTERVAL = 32;
|
||||
public static final int NUM_OF_SLOTS = 15;
|
||||
|
@ -666,80 +666,95 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
|
||||
// IItemHandler --------------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{ return SIDED_INV_SLOTS.length; }
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index)
|
||||
{ return getInventoryStackLimit(); }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{ return is_input_slot(slot); }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int index, @Nonnull ItemStack stack, boolean simulate)
|
||||
protected static class BItemHandler implements IItemHandler
|
||||
{
|
||||
if((stack.isEmpty()) || (!is_input_slot(index))) return ItemStack.EMPTY;
|
||||
int slotno = 0;
|
||||
ItemStack slotstack = getStackInSlot(slotno);
|
||||
if(!slotstack.isEmpty())
|
||||
private BTileEntity te;
|
||||
|
||||
BItemHandler(BTileEntity te)
|
||||
{ this.te = te; }
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{ return SIDED_INV_SLOTS.length; }
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index)
|
||||
{ return te.getInventoryStackLimit(); }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{ return te.is_input_slot(slot); }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int index, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
if(slotstack.getCount() >= Math.min(slotstack.getMaxStackSize(), getSlotLimit(index))) return stack;
|
||||
if(!ItemHandlerHelper.canItemStacksStack(stack, slotstack)) return stack;
|
||||
if(!canInsertItem(slotno, stack, EnumFacing.UP) || (!isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index)) - slotstack.getCount();
|
||||
if(stack.getCount() <= n) {
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(slotstack.getCount());
|
||||
setInventorySlotContents(slotno, copy);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.splitStack(n);
|
||||
copy.grow(slotstack.getCount());
|
||||
setInventorySlotContents(slotno, copy);
|
||||
return stack;
|
||||
if((stack.isEmpty()) || (!te.is_input_slot(index))) return ItemStack.EMPTY;
|
||||
int slotno = 0;
|
||||
ItemStack slotstack = getStackInSlot(slotno);
|
||||
if(!slotstack.isEmpty())
|
||||
{
|
||||
if(slotstack.getCount() >= Math.min(slotstack.getMaxStackSize(), getSlotLimit(index))) return stack;
|
||||
if(!ItemHandlerHelper.canItemStacksStack(stack, slotstack)) return stack;
|
||||
if(!te.canInsertItem(slotno, stack, EnumFacing.UP) || (!te.isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index)) - slotstack.getCount();
|
||||
if(stack.getCount() <= n) {
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(slotstack.getCount());
|
||||
te.setInventorySlotContents(slotno, copy);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!canInsertItem(slotno, stack, EnumFacing.UP) || (!isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index));
|
||||
if(n < stack.getCount()) {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
setInventorySlotContents(slotno, stack.splitStack(n));
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.splitStack(n);
|
||||
copy.grow(slotstack.getCount());
|
||||
te.setInventorySlotContents(slotno, copy);
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!simulate) setInventorySlotContents(slotno, stack);
|
||||
return ItemStack.EMPTY;
|
||||
if(!te.canInsertItem(slotno, stack, EnumFacing.UP) || (!te.isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index));
|
||||
if(n < stack.getCount()) {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
te.setInventorySlotContents(slotno, stack.splitStack(n));
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
} else {
|
||||
if(!simulate) te.setInventorySlotContents(slotno, stack);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int index, int amount, boolean simulate)
|
||||
{
|
||||
if((amount <= 0) || (!te.is_input_slot(index))) return ItemStack.EMPTY;
|
||||
ItemStack stack = te.stacks_.get(index).copy();
|
||||
if(stack.getCount() > amount) stack.setCount(amount);
|
||||
if(simulate) return stack;
|
||||
te.stacks_.get(index).shrink(stack.getCount());
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{ return te.getStackInSlot(index); }
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int index, int amount, boolean simulate)
|
||||
{
|
||||
if((amount <= 0) || (!is_input_slot(index))) return ItemStack.EMPTY;
|
||||
ItemStack stack = stacks_.get(index).copy();
|
||||
if(stack.getCount() > amount) stack.setCount(amount);
|
||||
if(simulate) return stack;
|
||||
stacks_.get(index).shrink(stack.getCount());
|
||||
return stack;
|
||||
}
|
||||
BItemHandler item_handler_ = new BItemHandler(this);
|
||||
|
||||
// Capability export ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -752,11 +767,8 @@ public class BlockDecorDropper extends BlockDecorDirected
|
|||
@Nullable
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if((facing != null) && (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)) {
|
||||
return (T)this;
|
||||
} else {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T)item_handler_;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
// IPacketReceiver -------------------------------------------------------------------------------
|
||||
|
|
|
@ -452,12 +452,6 @@ public class BlockDecorFurnace extends BlockDecorDirected
|
|||
public static final int AUX_0_SLOT_NO = 9;
|
||||
public static final int AUX_1_SLOT_NO =10;
|
||||
|
||||
private static final int[] SLOTS_TOP = new int[] {FIFO_INPUT_1_SLOT_NO};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {FIFO_OUTPUT_1_SLOT_NO};
|
||||
private static final int[] SLOTS_SIDES = new int[] {FIFO_FUEL_1_SLOT_NO};
|
||||
private final IItemHandler sided_itemhandler_top_ = new SidedInvWrapper(this, EnumFacing.UP);
|
||||
private final IItemHandler sided_itemhandler_down_ = new SidedInvWrapper(this, EnumFacing.DOWN);
|
||||
private final IItemHandler sided_itemhandler_sides_ = new SidedInvWrapper(this, EnumFacing.WEST);
|
||||
private static double proc_fuel_efficiency_ = 1.0;
|
||||
private static int proc_speed_interval_ = DEFAULT_SPEED_INTERVAL;
|
||||
private static int boost_energy_consumption = DEFAULT_BOOST_ENERGY * TICK_INTERVAL;
|
||||
|
@ -725,6 +719,13 @@ public class BlockDecorFurnace extends BlockDecorDirected
|
|||
|
||||
// ISidedInventory ----------------------------------------------------------------------------
|
||||
|
||||
private static final int[] SLOTS_TOP = new int[] {FIFO_INPUT_1_SLOT_NO};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {FIFO_OUTPUT_1_SLOT_NO};
|
||||
private static final int[] SLOTS_SIDES = new int[] {FIFO_FUEL_1_SLOT_NO};
|
||||
private final IItemHandler sided_itemhandler_top_ = new SidedInvWrapper(this, EnumFacing.UP);
|
||||
private final IItemHandler sided_itemhandler_down_ = new SidedInvWrapper(this, EnumFacing.DOWN);
|
||||
private final IItemHandler sided_itemhandler_sides_ = new SidedInvWrapper(this, EnumFacing.WEST);
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
|
|
|
@ -273,7 +273,7 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
|
|||
// Tile entity
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static class BTileEntity extends BlockDecorFurnace.BTileEntity implements ITickable, ISidedInventory, IEnergyStorage, IItemHandler
|
||||
public static class BTileEntity extends BlockDecorFurnace.BTileEntity implements ITickable, ISidedInventory, IEnergyStorage
|
||||
{
|
||||
public static final int TICK_INTERVAL = 4;
|
||||
public static final int FIFO_INTERVAL = 20;
|
||||
|
@ -429,6 +429,10 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
|
|||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{ return ((index < 0) || (index >= SIDED_INV_SLOTS.length)) ? ItemStack.EMPTY : stacks_.get(SIDED_INV_SLOTS[index]); }
|
||||
|
||||
// ISidedInventory ----------------------------------------------------------------------------
|
||||
|
||||
private static final int[] SIDED_INV_SLOTS = new int[] {
|
||||
|
@ -482,96 +486,104 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
|
|||
|
||||
// IItemHandler --------------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{ return SIDED_INV_SLOTS.length; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{ return ((index < 0) || (index >= SIDED_INV_SLOTS.length)) ? ItemStack.EMPTY : stacks_.get(SIDED_INV_SLOTS[index]); }
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index)
|
||||
{ return getInventoryStackLimit(); }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int index, @Nonnull ItemStack stack, boolean simulate)
|
||||
protected static class BItemHandler implements IItemHandler
|
||||
{
|
||||
if(stack.isEmpty()) return ItemStack.EMPTY;
|
||||
if((index < 0) || (index >= SIDED_INV_SLOTS.length)) return ItemStack.EMPTY;
|
||||
int slotno = SIDED_INV_SLOTS[index];
|
||||
ItemStack slotstack = getStackInSlot(slotno);
|
||||
if(!slotstack.isEmpty())
|
||||
private BTileEntity te;
|
||||
|
||||
BItemHandler(BTileEntity te)
|
||||
{ this.te = te; }
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{ return SIDED_INV_SLOTS.length; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{ return te.getStackInSlot(index); }
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index)
|
||||
{ return te.getInventoryStackLimit(); }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int index, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
if(slotstack.getCount() >= Math.min(slotstack.getMaxStackSize(), getSlotLimit(index))) return stack;
|
||||
if(!ItemHandlerHelper.canItemStacksStack(stack, slotstack)) return stack;
|
||||
if(!canInsertItem(slotno, stack, EnumFacing.UP) || (!isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index)) - slotstack.getCount();
|
||||
if(stack.getCount() <= n) {
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(slotstack.getCount());
|
||||
setInventorySlotContents(slotno, copy);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.splitStack(n);
|
||||
copy.grow(slotstack.getCount());
|
||||
setInventorySlotContents(slotno, copy);
|
||||
return stack;
|
||||
if(stack.isEmpty()) return ItemStack.EMPTY;
|
||||
if((index < 0) || (index >= SIDED_INV_SLOTS.length)) return ItemStack.EMPTY;
|
||||
int slotno = SIDED_INV_SLOTS[index];
|
||||
ItemStack slotstack = getStackInSlot(slotno);
|
||||
if(!slotstack.isEmpty()) {
|
||||
if(slotstack.getCount() >= Math.min(slotstack.getMaxStackSize(), getSlotLimit(index))) return stack;
|
||||
if(!ItemHandlerHelper.canItemStacksStack(stack, slotstack)) return stack;
|
||||
if(!te.canInsertItem(slotno, stack, EnumFacing.UP) || (!te.isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index)) - slotstack.getCount();
|
||||
if(stack.getCount() <= n) {
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(slotstack.getCount());
|
||||
te.setInventorySlotContents(slotno, copy);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.splitStack(n);
|
||||
copy.grow(slotstack.getCount());
|
||||
te.setInventorySlotContents(slotno, copy);
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!te.canInsertItem(slotno, stack, EnumFacing.UP) || (!te.isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index));
|
||||
if(n < stack.getCount()) {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
te.setInventorySlotContents(slotno, stack.splitStack(n));
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
} else {
|
||||
if(!simulate) te.setInventorySlotContents(slotno, stack);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!canInsertItem(slotno, stack, EnumFacing.UP) || (!isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index));
|
||||
if(n < stack.getCount()) {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
setInventorySlotContents(slotno, stack.splitStack(n));
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int index, int amount, boolean simulate) {
|
||||
if(amount == 0) return ItemStack.EMPTY;
|
||||
if((index < 0) || (index >= SIDED_INV_SLOTS.length)) return ItemStack.EMPTY;
|
||||
int slotno = SIDED_INV_SLOTS[index];
|
||||
ItemStack stackInSlot = getStackInSlot(slotno);
|
||||
if(stackInSlot.isEmpty()) return ItemStack.EMPTY;
|
||||
if(!te.canExtractItem(slotno, stackInSlot, EnumFacing.DOWN)) return ItemStack.EMPTY;
|
||||
if(simulate) {
|
||||
if(stackInSlot.getCount() < amount) return stackInSlot.copy();
|
||||
ItemStack ostack = stackInSlot.copy();
|
||||
ostack.setCount(amount);
|
||||
return ostack;
|
||||
} else {
|
||||
if(!simulate) setInventorySlotContents(slotno, stack);
|
||||
return ItemStack.EMPTY;
|
||||
ItemStack ostack = te.decrStackSize(slotno, Math.min(stackInSlot.getCount(), amount));
|
||||
te.markDirty();
|
||||
return ostack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int index, int amount, boolean simulate)
|
||||
{
|
||||
if(amount == 0) return ItemStack.EMPTY;
|
||||
if((index < 0) || (index >= SIDED_INV_SLOTS.length)) return ItemStack.EMPTY;
|
||||
int slotno = SIDED_INV_SLOTS[index];
|
||||
ItemStack stackInSlot = getStackInSlot(slotno);
|
||||
if(stackInSlot.isEmpty()) return ItemStack.EMPTY;
|
||||
if(!canExtractItem(slotno, stackInSlot, EnumFacing.DOWN)) return ItemStack.EMPTY;
|
||||
if(simulate) {
|
||||
if(stackInSlot.getCount() < amount) return stackInSlot.copy();
|
||||
ItemStack ostack = stackInSlot.copy();
|
||||
ostack.setCount(amount);
|
||||
return ostack;
|
||||
} else {
|
||||
ItemStack ostack = decrStackSize(slotno, Math.min(stackInSlot.getCount(), amount));
|
||||
markDirty();
|
||||
return ostack;
|
||||
}
|
||||
}
|
||||
protected BItemHandler item_handler_ = new BItemHandler(this);
|
||||
|
||||
// Capability export ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -584,11 +596,9 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
|
|||
@Nullable
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if((capability == CapabilityEnergy.ENERGY) || (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)) {
|
||||
return ((T)this);
|
||||
} else {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if(capability == CapabilityEnergy.ENERGY) return ((T)this);
|
||||
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T)item_handler_;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
// ITickable ------------------------------------------------------------------------------------
|
||||
|
|
|
@ -303,7 +303,7 @@ public class BlockDecorWasteIncinerator extends BlockDecor
|
|||
// Tile entity
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static class BTileEntity extends TileEntity implements ITickable, ISidedInventory, IEnergyStorage, IItemHandler
|
||||
public static class BTileEntity extends TileEntity implements ITickable, ISidedInventory, IEnergyStorage
|
||||
{
|
||||
public static final int TICK_INTERVAL = 20;
|
||||
public static final int ENERGIZED_TICK_INTERVAL = 5;
|
||||
|
@ -449,8 +449,8 @@ public class BlockDecorWasteIncinerator extends BlockDecor
|
|||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
stacks_.set(index, stack);
|
||||
if(stack.getCount() > getInventoryStackLimit()) stack.setCount(getInventoryStackLimit());
|
||||
stacks_.set(index, stack);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ public class BlockDecorWasteIncinerator extends BlockDecor
|
|||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{ return index==0; }
|
||||
{ return (index==0); }
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
|
@ -544,74 +544,89 @@ public class BlockDecorWasteIncinerator extends BlockDecor
|
|||
|
||||
// IItemHandler --------------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{ return 1; }
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index)
|
||||
{ return getInventoryStackLimit(); }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int index, @Nonnull ItemStack stack, boolean simulate)
|
||||
protected static class BItemHandler implements IItemHandler
|
||||
{
|
||||
if(stack.isEmpty()) return ItemStack.EMPTY;
|
||||
if(index != 0) return ItemStack.EMPTY;
|
||||
int slotno = 0;
|
||||
ItemStack slotstack = getStackInSlot(slotno);
|
||||
if(!slotstack.isEmpty())
|
||||
private BTileEntity te;
|
||||
|
||||
BItemHandler(BTileEntity te)
|
||||
{ this.te = te; }
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{ return 1; }
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int index)
|
||||
{ return te.getInventoryStackLimit(); }
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{ return true; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int index, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
if(slotstack.getCount() >= Math.min(slotstack.getMaxStackSize(), getSlotLimit(index))) return stack;
|
||||
if(!ItemHandlerHelper.canItemStacksStack(stack, slotstack)) return stack;
|
||||
if(!canInsertItem(slotno, stack, EnumFacing.UP) || (!isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index)) - slotstack.getCount();
|
||||
if(stack.getCount() <= n) {
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(slotstack.getCount());
|
||||
setInventorySlotContents(slotno, copy);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.splitStack(n);
|
||||
copy.grow(slotstack.getCount());
|
||||
setInventorySlotContents(slotno, copy);
|
||||
return stack;
|
||||
if(stack.isEmpty()) return ItemStack.EMPTY;
|
||||
if(index != 0) return ItemStack.EMPTY;
|
||||
int slotno = 0;
|
||||
ItemStack slotstack = getStackInSlot(slotno);
|
||||
if(!slotstack.isEmpty())
|
||||
{
|
||||
if(slotstack.getCount() >= Math.min(slotstack.getMaxStackSize(), getSlotLimit(index))) return stack;
|
||||
if(!ItemHandlerHelper.canItemStacksStack(stack, slotstack)) return stack;
|
||||
if(!te.canInsertItem(slotno, stack, EnumFacing.UP) || (!te.isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index)) - slotstack.getCount();
|
||||
if(stack.getCount() <= n) {
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.grow(slotstack.getCount());
|
||||
te.setInventorySlotContents(slotno, copy);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!canInsertItem(slotno, stack, EnumFacing.UP) || (!isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index));
|
||||
if(n < stack.getCount()) {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
setInventorySlotContents(slotno, stack.splitStack(n));
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
ItemStack copy = stack.splitStack(n);
|
||||
copy.grow(slotstack.getCount());
|
||||
te.setInventorySlotContents(slotno, copy);
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!simulate) setInventorySlotContents(slotno, stack);
|
||||
return ItemStack.EMPTY;
|
||||
if(!te.canInsertItem(slotno, stack, EnumFacing.UP) || (!te.isItemValidForSlot(slotno, stack))) return stack;
|
||||
int n = Math.min(stack.getMaxStackSize(), getSlotLimit(index));
|
||||
if(n < stack.getCount()) {
|
||||
stack = stack.copy();
|
||||
if(!simulate) {
|
||||
te.setInventorySlotContents(slotno, stack.splitStack(n));
|
||||
return stack;
|
||||
} else {
|
||||
stack.shrink(n);
|
||||
return stack;
|
||||
}
|
||||
} else {
|
||||
if(!simulate) te.setInventorySlotContents(slotno, stack);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int index, int amount, boolean simulate)
|
||||
{ return ItemStack.EMPTY; }
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{ return te.getStackInSlot(index); }
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int index, int amount, boolean simulate)
|
||||
{ return ItemStack.EMPTY; }
|
||||
private BItemHandler item_handler_ = new BItemHandler(this);
|
||||
|
||||
// Capability export ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -625,7 +640,7 @@ public class BlockDecorWasteIncinerator extends BlockDecor
|
|||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if((facing != null) && (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)) {
|
||||
return (T)this;
|
||||
return (T)item_handler_;
|
||||
} else if(capability == CapabilityEnergy.ENERGY) {
|
||||
return (T)this;
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
|
||||
"1.12.2": {
|
||||
"1.0.6-b1": "[A] Added small waste incinerator (delayed fifo-buffered item disposal).\n[M] Fixed item/block name capitalization (by Voxelo).\n[M] Metal ladders are easier to break/harvest.",
|
||||
"1.0.6-b1": "[A] Added small waste incinerator (delayed fifo-buffered item disposal).\n[M] Fixed item/block name capitalization (by Voxelo).\n[M] Metal ladders are easier to break/harvest.\n[F] Fixed FML remapping issue by using dedicated IItemHandler instances.",
|
||||
"1.0.5": "[R] Release based on v1.0.5-b1. Release-to-release changes: * Small electrical passthrough-furnace added. * Passive fluid accumulator added. * Config options added. * Sign plates added. * Minor bug fixes.\n[A] Added sign \"Electrical hazzard\"/\"Caution hot wire\".\n[A] Added sign \"Caution dangerous there\" (skull/bones).",
|
||||
"1.0.5-b1": "[A] Added passive fluid accumulator.\n[A] Added small electrical passthrough-furnace.\n[F] Fixed version check URL.\n[M] Opt-out config options for valves, passive fluid accumulator, and furni.",
|
||||
"1.0.4": "[R] Release based on v1.0.4-b9. Release-to-release changes: * Crafting table: Quick crafting history re-fab, JEI integration. * Rendering improvements and issue fixes (stairs, ambient occlusion, optifine, etc). * Walls with texture variations. * Thin/thick steel poles with support feet/heads. * Horizontal steel double-T support beams added. * Fluid pipe valves added: Check valve, redstone controlled valve, analog redstone controlled valve. Support pressurized transfer. * Tool tip documentation (CTRL-SHIFT) for stairs added. * Internal code cleanups. * Recipes tuned.\n[E] Added pass-through electrical furnace (experimental, see config).",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue