mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-06-02 14:03:37 +02:00
properly fix #1157
This commit is contained in:
parent
614d6e41c4
commit
33d9cb9fdb
|
@ -53,13 +53,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
|
|
||||||
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid) {
|
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid) {
|
||||||
this.inventory = inventory;
|
this.inventory = inventory;
|
||||||
this.bagInventory = new ItemStackHandlerAA(getSlotAmount(isVoid)) {
|
this.bagInventory = new ItemStackHandlerAA(getSlotAmount(isVoid), (slot, stack, automation) -> !isBlacklisted(stack), ItemStackHandlerAA.REMOVE_TRUE);
|
||||||
@Override
|
|
||||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
|
||||||
if(isBlacklisted(stack)) return stack;
|
|
||||||
return super.insertItem(slot, stack, simulate);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
this.isVoid = isVoid;
|
this.isVoid = isVoid;
|
||||||
this.sack = sack;
|
this.sack = sack;
|
||||||
|
|
||||||
|
@ -74,8 +68,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
return ContainerBag.this.filter.check(stack);
|
return ContainerBag.this.filter.check(stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
for (int j = 0; j < 7; j++) {
|
for (int j = 0; j < 7; j++) {
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.bagInventory, j + i * 7, 10 + j * 18, 10 + i * 18) {
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.bagInventory, j + i * 7, 10 + j * 18, 10 + i * 18) {
|
||||||
|
@ -96,8 +89,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (i == inventory.currentItem) {
|
if (i == inventory.currentItem) {
|
||||||
this.addSlotToContainer(new SlotImmovable(inventory, i, 8 + i * 18, 152));
|
this.addSlotToContainer(new SlotImmovable(inventory, i, 8 + i * 18, 152));
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 152));
|
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 152));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,20 +132,15 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
public void updateProgressBar(int id, int data) {
|
public void updateProgressBar(int id, int data) {
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
this.filter.isWhitelist = data == 1;
|
this.filter.isWhitelist = data == 1;
|
||||||
}
|
} else if (id == 1) {
|
||||||
else if(id == 1){
|
|
||||||
this.filter.respectMeta = data == 1;
|
this.filter.respectMeta = data == 1;
|
||||||
}
|
} else if (id == 2) {
|
||||||
else if(id == 2){
|
|
||||||
this.filter.respectNBT = data == 1;
|
this.filter.respectNBT = data == 1;
|
||||||
}
|
} else if (id == 3) {
|
||||||
else if(id == 3){
|
|
||||||
this.filter.respectOredict = data;
|
this.filter.respectOredict = data;
|
||||||
}
|
} else if (id == 4) {
|
||||||
else if(id == 4){
|
|
||||||
this.autoInsert = data == 1;
|
this.autoInsert = data == 1;
|
||||||
}
|
} else if (id == 5) {
|
||||||
else if(id == 5){
|
|
||||||
this.filter.respectMod = data == 1;
|
this.filter.respectMod = data == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,31 +163,20 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
//Shift from Inventory
|
//Shift from Inventory
|
||||||
if (this.isVoid || !this.filter.check(newStack) || !this.mergeItemStack(newStack, 4, 32, false)) {
|
if (this.isVoid || !this.filter.check(newStack) || !this.mergeItemStack(newStack, 4, 32, false)) {
|
||||||
if (slot >= inventoryStart && slot <= inventoryEnd) {
|
if (slot >= inventoryStart && slot <= inventoryEnd) {
|
||||||
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
|
if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); }
|
||||||
return StackUtil.getEmpty();
|
} else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); }
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){
|
|
||||||
return StackUtil.getEmpty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
}
|
} else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); }
|
||||||
else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){
|
|
||||||
return StackUtil.getEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StackUtil.isValid(newStack)) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.putStack(StackUtil.getEmpty());
|
theSlot.putStack(StackUtil.getEmpty());
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newStack.getCount() == currentStack.getCount()){
|
if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); }
|
||||||
return StackUtil.getEmpty();
|
|
||||||
}
|
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
||||||
return currentStack;
|
return currentStack;
|
||||||
|
@ -212,11 +188,9 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||||
if (SlotFilter.checkFilter(this, slotId, player)) {
|
if (SlotFilter.checkFilter(this, slotId, player)) {
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
} else if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem) {
|
||||||
else if(clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem){
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return super.slotClick(slotId, dragType, clickTypeIn, player);
|
return super.slotClick(slotId, dragType, clickTypeIn, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,8 +216,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
||||||
if (buttonID == 0) {
|
if (buttonID == 0) {
|
||||||
this.autoInsert = !this.autoInsert;
|
this.autoInsert = !this.autoInsert;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.filter.onButtonPressed(buttonID);
|
this.filter.onButtonPressed(buttonID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,8 +235,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
ActuallyAdditions.LOGGER.error("Invalid item in sack blacklist: " + s);
|
ActuallyAdditions.LOGGER.error("Invalid item in sack blacklist: " + s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(split.length == 1)
|
if (split.length == 1) BLACKLIST.add(Pair.of(item, 0));
|
||||||
BLACKLIST.add(Pair.of(item, 0));
|
|
||||||
else if (split.length == 2) {
|
else if (split.length == 2) {
|
||||||
BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1])));
|
BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1])));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
@ -143,13 +143,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean fromAutomation) {
|
public IAcceptor getAcceptor() {
|
||||||
return StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
|
return (slot, stack, automation) -> StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -144,13 +145,8 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
|
public IAcceptor getAcceptor(){
|
||||||
return true;
|
return (slot, stack, automation) -> stack.getItem() instanceof ItemBattery;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation){
|
|
||||||
return stack.getItem() instanceof ItemBattery;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.IGrowable;
|
import net.minecraft.block.IGrowable;
|
||||||
|
@ -23,9 +29,6 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TileEntityBioReactor extends TileEntityInventoryBase implements ISharingEnergyProvider {
|
public class TileEntityBioReactor extends TileEntityInventoryBase implements ISharingEnergyProvider {
|
||||||
|
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 0, 800);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 0, 800);
|
||||||
|
@ -46,10 +49,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (isValid(item)) {
|
if (isValid(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (item instanceof ItemBlock) { return isValid(Block.getBlockFromItem(item)); }
|
||||||
else if(item instanceof ItemBlock){
|
|
||||||
return isValid(Block.getBlockFromItem(item));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -90,14 +90,12 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
|
|
||||||
this.maxBurnTime = 200 - (int) Math.pow(1.8, amount);
|
this.maxBurnTime = 200 - (int) Math.pow(1.8, amount);
|
||||||
this.burnTime = this.maxBurnTime;
|
this.burnTime = this.maxBurnTime;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.burnTime = 0;
|
this.burnTime = 0;
|
||||||
this.maxBurnTime = 0;
|
this.maxBurnTime = 0;
|
||||||
this.producePerTick = 0;
|
this.producePerTick = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.burnTime--;
|
this.burnTime--;
|
||||||
this.storage.receiveEnergyInternal(this.producePerTick, false);
|
this.storage.receiveEnergyInternal(this.producePerTick, false);
|
||||||
}
|
}
|
||||||
|
@ -129,13 +127,13 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int index, ItemStack stack, boolean byAutomation){
|
public IAcceptor getAcceptor() {
|
||||||
return false;
|
return (slot, stack, automation) -> isValidItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int index, ItemStack stack, boolean fromAutomation){
|
public IRemover getRemover() {
|
||||||
return isValidItem(stack);
|
return ItemStackHandlerAA.REMOVE_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -71,9 +72,8 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean automation) {
|
public IAcceptor getAcceptor() {
|
||||||
if(isPlacer) return true;
|
return (slot, stack, automation) -> !automation;
|
||||||
else return !automation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWork() {
|
private void doWork() {
|
||||||
|
|
|
@ -13,6 +13,8 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -97,8 +99,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.currentProcessTime = 0;
|
this.currentProcessTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +112,8 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation){
|
public IAcceptor getAcceptor() {
|
||||||
return (slot == 0 && isCanola(stack));
|
return (slot, stack, automation) -> slot == 0 && isCanola(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCanola(ItemStack stack) {
|
public static boolean isCanola(ItemStack stack) {
|
||||||
|
@ -120,8 +121,8 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
|
public IRemover getRemover() {
|
||||||
return !byAutomation;
|
return (slot, automation) -> !automation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -105,14 +107,16 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean fromAutomation){
|
public IAcceptor getAcceptor() {
|
||||||
return TileEntityFurnace.getItemBurnTime(stack) > 0;
|
return (slot, stack, automation) -> TileEntityFurnace.getItemBurnTime(stack) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
|
public IRemover getRemover() {
|
||||||
if(!byAutomation) return true;
|
return (slot, automation) -> {
|
||||||
|
if (!automation) return true;
|
||||||
return TileEntityFurnace.getItemBurnTime(this.inv.getStackInSlot(0)) <= 0;
|
return TileEntityFurnace.getItemBurnTime(this.inv.getStackInSlot(0)) <= 0;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,6 +16,8 @@ import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -125,8 +127,13 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal());
|
return (slot, stack, automation) -> (slot >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (slot == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (slot == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IRemover getRemover() {
|
||||||
|
return (slot, automation) -> slot == SLOT_OUTPUT || (slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientFromStack(inv.getStackInSlot(slot)) == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeCoffee() {
|
public void storeCoffee() {
|
||||||
|
@ -169,18 +176,12 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
this.tank.drainInternal(WATER_USE, true);
|
this.tank.drainInternal(WATER_USE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.brewTime = 0;
|
this.brewTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
|
||||||
return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientFromStack(stack) == null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
||||||
if (buttonID == 0 && this.brewTime <= 0) {
|
if (buttonID == 0 && this.brewTime <= 0) {
|
||||||
|
|
|
@ -12,6 +12,8 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -90,13 +92,13 @@ public class TileEntityCompost extends TileEntityInventoryBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation) {
|
public IAcceptor getAcceptor() {
|
||||||
return getRecipeForInput(stack) != null;
|
return (slot, stack, automation) -> getRecipeForInput(stack) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation) {
|
public IRemover getRemover() {
|
||||||
return getRecipeForInput(stack) == null;
|
return (slot, automation) -> getRecipeForInput(inv.getStackInSlot(slot)) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState getCurrentDisplay() {
|
public IBlockState getCurrentDisplay() {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -61,8 +62,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
||||||
if (this.currentTime <= 0) {
|
if (this.currentTime <= 0) {
|
||||||
this.doWork();
|
this.doWork();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.currentTime = 15;
|
this.currentTime = 15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,19 +102,14 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation;
|
return (slot, stack, automation) -> !automation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEnergyScaled(int i) {
|
public int getEnergyScaled(int i) {
|
||||||
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRedstoneToggle() {
|
public boolean isRedstoneToggle() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -17,6 +17,8 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -50,7 +52,8 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPossibleInput(ItemStack stack) {
|
public static boolean isPossibleInput(ItemStack stack) {
|
||||||
for(EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) if(r.getInput().apply(stack)) return true;
|
for (EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES)
|
||||||
|
if (r.getInput().apply(stack)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,13 +156,13 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int index, ItemStack stack, boolean automation) {
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || !getRecipesForInput(stack).isEmpty();
|
return (slot, stack, automation) -> !automation || isPossibleInput(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int index, ItemStack stack, boolean automation) {
|
public IRemover getRemover() {
|
||||||
return !automation || getRecipesForInput(stack).isEmpty();
|
return (slot, automation) -> !automation || !isPossibleInput(inv.getStackInSlot(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
|
@ -73,13 +74,13 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || (i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null)));
|
return (slot, stack, automation) -> !automation || (slot == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
public IRemover getRemover() {
|
||||||
return !EnchantmentHelper.hasBindingCurse(stack) && !automation || (slot == 1);
|
return (slot, automation) -> !EnchantmentHelper.hasBindingCurse(inv.getStackInSlot(slot)) && !automation || (slot == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEnergyScaled(int i) {
|
public int getEnergyScaled(int i) {
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -74,19 +75,19 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || (i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null)));
|
return (slot, stack, automation) -> !automation || (slot == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IRemover getRemover() {
|
||||||
|
return (slot, automation) -> !automation || slot == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEnergyScaled(int i) {
|
public int getEnergyScaled(int i) {
|
||||||
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
|
||||||
return !automation || slot == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyToSplitShare() {
|
public int getEnergyToSplitShare() {
|
||||||
return this.storage.getEnergyStored();
|
return this.storage.getEnergyStored();
|
||||||
|
|
|
@ -18,6 +18,8 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -138,13 +140,13 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation) {
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || i < 6;
|
return (slot, stack, automation) -> !automation || slot < 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation) {
|
public IRemover getRemover() {
|
||||||
return !automation || slot >= 6;
|
return (slot, automation) -> !automation || slot >= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import net.minecraft.entity.passive.EntityAnimal;
|
import net.minecraft.entity.passive.EntityAnimal;
|
||||||
import net.minecraft.entity.passive.EntityHorse;
|
import net.minecraft.entity.passive.EntityHorse;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
@ -85,8 +86,8 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
public IRemover getRemover() {
|
||||||
return !automation;
|
return (slot, automation) -> !automation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void feedAnimal(EntityAnimal animal) {
|
private static void feedAnimal(EntityAnimal animal) {
|
||||||
|
|
|
@ -13,6 +13,8 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -53,11 +55,9 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
ItemStack toSplit = StackUtil.getEmpty();
|
ItemStack toSplit = StackUtil.getEmpty();
|
||||||
if (!StackUtil.isValid(first) && StackUtil.isValid(second) && second.getCount() > 1) {
|
if (!StackUtil.isValid(first) && StackUtil.isValid(second) && second.getCount() > 1) {
|
||||||
toSplit = second;
|
toSplit = second;
|
||||||
}
|
} else if (!StackUtil.isValid(second) && StackUtil.isValid(first) && first.getCount() > 1) {
|
||||||
else if(!StackUtil.isValid(second) && StackUtil.isValid(first) && first.getCount() > 1){
|
|
||||||
toSplit = first;
|
toSplit = first;
|
||||||
}
|
} else if (ItemUtil.canBeStacked(first, second)) {
|
||||||
else if(ItemUtil.canBeStacked(first, second)){
|
|
||||||
if (first.getCount() < first.getMaxStackSize() || second.getCount() < second.getMaxStackSize()) {
|
if (first.getCount() < first.getMaxStackSize() || second.getCount() < second.getMaxStackSize()) {
|
||||||
if (!((first.getCount() <= second.getCount() + 1 && first.getCount() >= second.getCount() - 1) || (second.getCount() <= first.getCount() + 1 && second.getCount() >= first.getCount() - 1))) {
|
if (!((first.getCount() <= second.getCount() + 1 && first.getCount() >= second.getCount() - 1) || (second.getCount() <= first.getCount() + 1 && second.getCount() >= first.getCount() - 1))) {
|
||||||
toSplit = first;
|
toSplit = first;
|
||||||
|
@ -120,8 +120,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
}
|
}
|
||||||
smelted = true;
|
smelted = true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.firstSmeltTime = 0;
|
this.firstSmeltTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +134,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
}
|
}
|
||||||
smelted = true;
|
smelted = true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.secondSmeltTime = 0;
|
this.secondSmeltTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,17 +157,20 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || ((i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack)));
|
return (slot, stack, automation) -> !automation || ((slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IRemover getRemover() {
|
||||||
|
return (slot, automation) -> !automation || (slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSmeltOn(int theInput, int theOutput) {
|
public boolean canSmeltOn(int theInput, int theOutput) {
|
||||||
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) {
|
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) {
|
||||||
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput));
|
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput));
|
||||||
if (StackUtil.isValid(output)) {
|
if (StackUtil.isValid(output)) {
|
||||||
if(!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || (this.inv.getStackInSlot(theOutput).isItemEqual(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize()-output.getCount())){
|
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || (this.inv.getStackInSlot(theOutput).isItemEqual(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount())) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,8 +181,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput));
|
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput));
|
||||||
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) {
|
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) {
|
||||||
this.inv.setStackInSlot(theOutput, output.copy());
|
this.inv.setStackInSlot(theOutput, output.copy());
|
||||||
}
|
} else if (this.inv.getStackInSlot(theOutput).getItem() == output.getItem()) {
|
||||||
else if(this.inv.getStackInSlot(theOutput).getItem() == output.getItem()){
|
|
||||||
this.inv.getStackInSlot(theOutput).grow(output.getCount());
|
this.inv.getStackInSlot(theOutput).grow(output.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,11 +196,6 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
||||||
return this.secondSmeltTime * i / SMELT_TIME;
|
return this.secondSmeltTime * i / SMELT_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
|
||||||
return !automation || (slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
||||||
if (buttonID == 0) {
|
if (buttonID == 0) {
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -108,8 +109,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
}
|
}
|
||||||
crushed = storage.getEnergyStored() >= ENERGY_USE;
|
crushed = storage.getEnergyStored() >= ENERGY_USE;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.firstCrushTime = 0;
|
this.firstCrushTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +127,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
}
|
}
|
||||||
crushed = storage.getEnergyStored() >= ENERGY_USE;
|
crushed = storage.getEnergyStored() >= ENERGY_USE;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.secondCrushTime = 0;
|
this.secondCrushTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,8 +155,13 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || ((i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && CrusherRecipeRegistry.getRecipeFromInput(stack) != null);
|
return (slot, stack, automation) -> !automation || ((slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && CrusherRecipeRegistry.getRecipeFromInput(stack) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IRemover getRemover() {
|
||||||
|
return (slot, automation) -> !automation || (slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) {
|
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) {
|
||||||
|
@ -173,9 +177,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
if (StackUtil.isValid(outputTwo) && outputTwo.getItemDamage() == Util.WILDCARD) {
|
if (StackUtil.isValid(outputTwo) && outputTwo.getItemDamage() == Util.WILDCARD) {
|
||||||
outputTwo.setItemDamage(0);
|
outputTwo.setItemDamage(0);
|
||||||
}
|
}
|
||||||
if((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || (this.inv.getStackInSlot(theFirstOutput).isItemEqual(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize()-outputOne.getCount())) && (!StackUtil.isValid(outputTwo) || (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || (this.inv.getStackInSlot(theSecondOutput).isItemEqual(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize()-outputTwo.getCount())))){
|
if ((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || (this.inv.getStackInSlot(theFirstOutput).isItemEqual(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount())) && (!StackUtil.isValid(outputTwo) || (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || (this.inv.getStackInSlot(theSecondOutput).isItemEqual(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount())))) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -195,8 +197,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
}
|
}
|
||||||
if (!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput))) {
|
if (!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput))) {
|
||||||
this.inv.setStackInSlot(theFirstOutput, outputOne.copy());
|
this.inv.setStackInSlot(theFirstOutput, outputOne.copy());
|
||||||
}
|
} else if (this.inv.getStackInSlot(theFirstOutput).getItem() == outputOne.getItem()) {
|
||||||
else if(this.inv.getStackInSlot(theFirstOutput).getItem() == outputOne.getItem()){
|
|
||||||
this.inv.setStackInSlot(theFirstOutput, StackUtil.grow(this.inv.getStackInSlot(theFirstOutput), outputOne.getCount()));
|
this.inv.setStackInSlot(theFirstOutput, StackUtil.grow(this.inv.getStackInSlot(theFirstOutput), outputOne.getCount()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,8 +211,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
if (rand <= recipe.getSecondChance()) {
|
if (rand <= recipe.getSecondChance()) {
|
||||||
if (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput))) {
|
if (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput))) {
|
||||||
this.inv.setStackInSlot(theSecondOutput, outputTwo.copy());
|
this.inv.setStackInSlot(theSecondOutput, outputTwo.copy());
|
||||||
}
|
} else if (this.inv.getStackInSlot(theSecondOutput).getItem() == outputTwo.getItem()) {
|
||||||
else if(this.inv.getStackInSlot(theSecondOutput).getItem() == outputTwo.getItem()){
|
|
||||||
this.inv.setStackInSlot(theSecondOutput, StackUtil.grow(this.inv.getStackInSlot(theSecondOutput), outputTwo.getCount()));
|
this.inv.setStackInSlot(theSecondOutput, StackUtil.grow(this.inv.getStackInSlot(theSecondOutput), outputTwo.getCount()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,11 +232,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IButto
|
||||||
return this.secondCrushTime * i / this.getMaxCrushTime();
|
return this.secondCrushTime * i / this.getMaxCrushTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
|
||||||
return !automation || (slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
||||||
if (buttonID == 0) {
|
if (buttonID == 0) {
|
||||||
|
|
|
@ -10,15 +10,20 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
|
@ -26,10 +31,6 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor {
|
public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor {
|
||||||
|
|
||||||
|
@ -131,8 +132,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
for (EnumFacing facing : EnumFacing.values()) {
|
for (EnumFacing facing : EnumFacing.values()) {
|
||||||
IItemHandler normal = null;
|
IItemHandler normal = null;
|
||||||
if(tile.getClass() == TileEntityFurnace.class)
|
if (tile.getClass() == TileEntityFurnace.class) normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||||
normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
|
||||||
else if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) {
|
else if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) {
|
||||||
normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
||||||
}
|
}
|
||||||
|
@ -227,14 +227,11 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
|
|
||||||
if (this.sideToPut >= 6) {
|
if (this.sideToPut >= 6) {
|
||||||
this.sideToPut = -1;
|
this.sideToPut = -1;
|
||||||
}
|
} else if (this.sideToPut < -1) {
|
||||||
else if(this.sideToPut < -1){
|
|
||||||
this.sideToPut = 5;
|
this.sideToPut = 5;
|
||||||
}
|
} else if (this.sideToPull >= 6) {
|
||||||
else if(this.sideToPull >= 6){
|
|
||||||
this.sideToPull = -1;
|
this.sideToPull = -1;
|
||||||
}
|
} else if (this.sideToPull < -1) {
|
||||||
else if(this.sideToPull < -1){
|
|
||||||
this.sideToPull = 5;
|
this.sideToPull = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,12 +307,12 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || i == 0;
|
return (slot, stack, automation) -> !automation || slot == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
public IRemover getRemover() {
|
||||||
return !automation || slot == 0;
|
return (slot, automation) -> !automation || slot == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,8 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -67,12 +69,12 @@ public abstract class TileEntityInventoryBase extends TileEntityBase {
|
||||||
return this.inv;
|
return this.inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean automation) {
|
public IAcceptor getAcceptor() {
|
||||||
return true;
|
return ItemStackHandlerAA.ACCEPT_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation) {
|
public IRemover getRemover() {
|
||||||
return true;
|
return ItemStackHandlerAA.REMOVE_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxStackSize(int slot) {
|
public int getMaxStackSize(int slot) {
|
||||||
|
@ -112,13 +114,13 @@ public abstract class TileEntityInventoryBase extends TileEntityBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAccept(int slot, ItemStack stack, boolean fromAutomation) {
|
public IAcceptor getAcceptor() {
|
||||||
return TileEntityInventoryBase.this.canInsert(slot, stack, fromAutomation);
|
return TileEntityInventoryBase.this.getAcceptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRemove(int slot, boolean byAutomation) {
|
public IRemover getRemover() {
|
||||||
return TileEntityInventoryBase.this.canExtract(slot, this.getStackInSlot(slot), byAutomation);
|
return TileEntityInventoryBase.this.getRemover();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -39,14 +41,11 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase{
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (item.isRepairable() && item.getMaxDamage(stack) > 0) {
|
if (item.isRepairable() && item.getMaxDamage(stack) > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
String reg = item.getRegistryName().toString();
|
String reg = item.getRegistryName().toString();
|
||||||
if (reg != null) {
|
if (reg != null) {
|
||||||
for (String strg : ConfigStringListValues.REPAIRER_EXTRA_WHITELIST.getValue()) {
|
for (String strg : ConfigStringListValues.REPAIRER_EXTRA_WHITELIST.getValue()) {
|
||||||
if(reg.equals(strg)){
|
if (reg.equals(strg)) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +82,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase{
|
||||||
this.inv.setStackInSlot(SLOT_OUTPUT, input.copy());
|
this.inv.setStackInSlot(SLOT_OUTPUT, input.copy());
|
||||||
this.inv.setStackInSlot(SLOT_INPUT, StackUtil.getEmpty());
|
this.inv.setStackInSlot(SLOT_INPUT, StackUtil.getEmpty());
|
||||||
this.nextRepairTick = 0;
|
this.nextRepairTick = 0;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (this.storage.getEnergyStored() >= ENERGY_USE) {
|
if (this.storage.getEnergyStored() >= ENERGY_USE) {
|
||||||
this.nextRepairTick++;
|
this.nextRepairTick++;
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
|
@ -102,8 +100,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.nextRepairTick = 0;
|
this.nextRepairTick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +111,8 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || i == SLOT_INPUT;
|
return (slot, stack, automation) -> !automation || slot == SLOT_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
@ -124,15 +121,13 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemDamageToScale(int i) {
|
public int getItemDamageToScale(int i) {
|
||||||
if(StackUtil.isValid(this.inv.getStackInSlot(SLOT_INPUT))){
|
if (StackUtil.isValid(this.inv.getStackInSlot(SLOT_INPUT))) { return (this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage() - this.inv.getStackInSlot(SLOT_INPUT).getItemDamage()) * i / this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage(); }
|
||||||
return (this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage()-this.inv.getStackInSlot(SLOT_INPUT).getItemDamage())*i/this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
public IRemover getRemover() {
|
||||||
return !automation || slot == SLOT_OUTPUT;
|
return (slot, automation) -> !automation || slot == SLOT_OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -195,13 +196,8 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation) {
|
public IAcceptor getAcceptor() {
|
||||||
return !fromAutomation;
|
return (stack, slot, automation) -> !automation;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
|
|
||||||
public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer {
|
public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer {
|
||||||
|
|
||||||
public TileEntityPhantomBreaker() {
|
public TileEntityPhantomBreaker() {
|
||||||
|
@ -17,4 +21,14 @@ public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer{
|
||||||
this.isBreaker = true;
|
this.isBreaker = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAcceptor getAcceptor() {
|
||||||
|
return ItemStackHandlerAA.ACCEPT_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IRemover getRemover() {
|
||||||
|
return ItemStackHandlerAA.REMOVE_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||||
import net.minecraft.item.ItemStack;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
@ -25,8 +26,8 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || this.isBoundThingInRange();
|
return (slot, stack, automation) -> !automation || this.isBoundThingInRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,9 +36,7 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||||
TileEntity tile = this.world.getTileEntity(this.getBoundPosition());
|
TileEntity tile = this.world.getTileEntity(this.getBoundPosition());
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
for (EnumFacing facing : EnumFacing.values()) {
|
for (EnumFacing facing : EnumFacing.values()) {
|
||||||
if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)){
|
if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +49,7 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
public IRemover getRemover() {
|
||||||
return !automation || this.isBoundThingInRange();
|
return (slot, automation) -> !automation || this.isBoundThingInRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -94,8 +97,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
if (this.currentTime <= 0) {
|
if (this.currentTime <= 0) {
|
||||||
this.doWork();
|
this.doWork();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.currentTime = 30;
|
this.currentTime = 30;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,8 +108,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
this.sendUpdate();
|
this.sendUpdate();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (this.boundPosition != null) {
|
if (this.boundPosition != null) {
|
||||||
this.renderParticles();
|
this.renderParticles();
|
||||||
}
|
}
|
||||||
|
@ -141,8 +142,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
int theSlot = StackUtil.findFirstFilled(this.inv);
|
int theSlot = StackUtil.findFirstFilled(this.inv);
|
||||||
if (theSlot == -1) return;
|
if (theSlot == -1) return;
|
||||||
inv.setStackInSlot(theSlot, WorldUtil.useItemAtSide(WorldUtil.getDirectionBySidesInOrder(this.side), this.world, this.boundPosition, inv.getStackInSlot(theSlot)));
|
inv.setStackInSlot(theSlot, WorldUtil.useItemAtSide(WorldUtil.getDirectionBySidesInOrder(this.side), this.world, this.boundPosition, inv.getStackInSlot(theSlot)));
|
||||||
|
@ -190,13 +190,13 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
public IAcceptor getAcceptor() {
|
||||||
return !automation || !this.isBreaker;
|
return ItemStackHandlerAA.ACCEPT_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
public IRemover getRemover() {
|
||||||
return !automation || this.isBreaker;
|
return ItemStackHandlerAA.REMOVE_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,8 +213,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
public void onButtonPressed(int buttonID, EntityPlayer player) {
|
||||||
if (this.side + 1 >= EnumFacing.values().length) {
|
if (this.side + 1 >= EnumFacing.values().length) {
|
||||||
this.side = 0;
|
this.side = 0;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.side++;
|
this.side++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
|
||||||
public class TileEntityPlacer extends TileEntityBreaker {
|
public class TileEntityPlacer extends TileEntityBreaker {
|
||||||
|
|
||||||
public TileEntityPlacer() {
|
public TileEntityPlacer() {
|
||||||
|
@ -17,4 +20,9 @@ public class TileEntityPlacer extends TileEntityBreaker{
|
||||||
this.isPlacer = true;
|
this.isPlacer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAcceptor getAcceptor() {
|
||||||
|
return ItemStackHandlerAA.ACCEPT_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -87,13 +88,8 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int i, ItemStack stack, boolean fromAutomation) {
|
public IAcceptor getAcceptor() {
|
||||||
return !fromAutomation;
|
return (slot, stack, automation) -> !automation;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,10 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience;
|
import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.item.EntityXPOrb;
|
import net.minecraft.entity.item.EntityXPOrb;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -22,8 +25,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor {
|
public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor {
|
||||||
|
|
||||||
private static final int[] XP_MAP = new int[256];
|
private static final int[] XP_MAP = new int[256];
|
||||||
|
@ -162,13 +163,8 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation) {
|
public IAcceptor getAcceptor() {
|
||||||
return slot == 1 && stack.getItem() == InitItems.itemSolidifiedExperience;
|
return (slot, stack, automation) -> slot == 1 && stack.getItem() == InitItems.itemSolidifiedExperience;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -104,6 +104,7 @@ public final class AwfulUtil{
|
||||||
error += ("\n" + i++ + ": " + (k == null ? "null" : (k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ")));
|
error += ("\n" + i++ + ": " + (k == null ? "null" : (k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ")));
|
||||||
}
|
}
|
||||||
error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide();
|
error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide();
|
||||||
|
error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
|
||||||
throw new IllegalStateException(error);
|
throw new IllegalStateException(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,32 @@ import net.minecraftforge.items.ItemStackHandler;
|
||||||
*/
|
*/
|
||||||
public class ItemStackHandlerAA extends ItemStackHandler {
|
public class ItemStackHandlerAA extends ItemStackHandler {
|
||||||
|
|
||||||
public ItemStackHandlerAA(int slots) {
|
public static final IAcceptor ACCEPT_TRUE = (a, b, c) -> true;
|
||||||
|
public static final IRemover REMOVE_TRUE = (a, b) -> true;
|
||||||
|
public static final IAcceptor ACCEPT_FALSE = (a, b, c) -> false;
|
||||||
|
public static final IRemover REMOVE_FALSE = (a, b) -> false;
|
||||||
|
|
||||||
|
IAcceptor acceptor;
|
||||||
|
IRemover remover;
|
||||||
|
|
||||||
|
public ItemStackHandlerAA(NonNullList<ItemStack> stacks, IAcceptor acceptor, IRemover remover) {
|
||||||
|
super(stacks);
|
||||||
|
this.acceptor = acceptor;
|
||||||
|
this.remover = remover;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackHandlerAA(int slots, IAcceptor acceptor, IRemover remover) {
|
||||||
super(slots);
|
super(slots);
|
||||||
|
this.acceptor = acceptor;
|
||||||
|
this.remover = remover;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackHandlerAA(NonNullList<ItemStack> stacks) {
|
||||||
|
this(stacks, ACCEPT_TRUE, REMOVE_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackHandlerAA(int slots) {
|
||||||
|
this(slots, ACCEPT_TRUE, REMOVE_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NonNullList<ItemStack> getItems() {
|
public NonNullList<ItemStack> getItems() {
|
||||||
|
@ -48,11 +72,33 @@ public class ItemStackHandlerAA extends ItemStackHandler {
|
||||||
return super.extractItem(slot, amount, simulate);
|
return super.extractItem(slot, amount, simulate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAccept(int slot, ItemStack stack, boolean fromAutomation) {
|
public final boolean canAccept(int slot, ItemStack stack, boolean automation) {
|
||||||
return true;
|
IAcceptor acceptor = getAcceptor();
|
||||||
|
try {
|
||||||
|
return acceptor.canAccept(slot, stack, automation);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRemove(int slot, boolean byAutomation) {
|
public final boolean canRemove(int slot, boolean automation) {
|
||||||
return true;
|
return getRemover().canRemove(slot, automation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAcceptor getAcceptor() {
|
||||||
|
return acceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRemover getRemover() {
|
||||||
|
return remover;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface IAcceptor {
|
||||||
|
boolean canAccept(int slot, ItemStack stack, boolean automation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface IRemover {
|
||||||
|
boolean canRemove(int slot, boolean automation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
|
|
||||||
public final class StackUtil {
|
public final class StackUtil {
|
||||||
|
|
||||||
|
@ -67,42 +65,6 @@ public final class StackUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if all provided itemstacks will fit in the handler. If you have an AA item handler, use the more sensitive below methods.
|
|
||||||
* @param inv The Item handler
|
|
||||||
* @param stacks The stacks to add
|
|
||||||
* @return If all stacks fit fully. If even one item would not fit, the method returns false.
|
|
||||||
*/
|
|
||||||
public static boolean canAddAll(IItemHandler inv, List<ItemStack> stacks) {
|
|
||||||
|
|
||||||
int slotMax = inv.getSlots();
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
for (ItemStack s : stacks = merge(stacks)) {
|
|
||||||
for (int i = 0; i < slotMax; i++) {
|
|
||||||
s = inv.insertItem(i, s, true);
|
|
||||||
if (s.isEmpty()) break;
|
|
||||||
}
|
|
||||||
if (s.isEmpty()) counter++;
|
|
||||||
}
|
|
||||||
return counter == stacks.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds all itemstacks in a list to an item handler. If you have an AA item handler, use the more sensitive below methods.
|
|
||||||
* @param inv The Item handler
|
|
||||||
* @param stacks The stacks to add
|
|
||||||
*/
|
|
||||||
public static void addAll(IItemHandler inv, List<ItemStack> stacks) {
|
|
||||||
int slotMax = inv.getSlots();
|
|
||||||
for (ItemStack s : stacks) {
|
|
||||||
for (int i = 0; i < slotMax; i++) {
|
|
||||||
s = inv.insertItem(i, s, false);
|
|
||||||
if (s.isEmpty()) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if all provided itemstacks will fit in the AA handler. Use addAll below to actually add the stacks. This is strictly a check function.
|
* Checks if all provided itemstacks will fit in the AA handler. Use addAll below to actually add the stacks. This is strictly a check function.
|
||||||
* @param inv The AA Item handler
|
* @param inv The AA Item handler
|
||||||
|
@ -111,13 +73,11 @@ public final class StackUtil {
|
||||||
* @return If all stacks fit fully. If even one item would not fit, the method returns false.
|
* @return If all stacks fit fully. If even one item would not fit, the method returns false.
|
||||||
*/
|
*/
|
||||||
public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, boolean fromAutomation) {
|
public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, boolean fromAutomation) {
|
||||||
|
|
||||||
int slotMax = inv.getSlots();
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
ItemStackHandlerAA dummy = testDummy(inv, 0, inv.getSlots());
|
||||||
for (ItemStack s : stacks = merge(stacks)) {
|
for (ItemStack s : stacks) {
|
||||||
for (int i = 0; i < slotMax; i++) {
|
for (int i = 0; i < dummy.getSlots(); i++) {
|
||||||
s = inv.insertItem(i, s, true, fromAutomation);
|
s = dummy.insertItem(i, s, false, fromAutomation);
|
||||||
if (s.isEmpty()) break;
|
if (s.isEmpty()) break;
|
||||||
}
|
}
|
||||||
if (s.isEmpty()) counter++;
|
if (s.isEmpty()) counter++;
|
||||||
|
@ -152,10 +112,10 @@ public final class StackUtil {
|
||||||
*/
|
*/
|
||||||
public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, int slot, int endSlot, boolean fromAutomation) {
|
public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, int slot, int endSlot, boolean fromAutomation) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
ItemStackHandlerAA dummy = testDummy(inv, slot, endSlot);
|
||||||
for (ItemStack s : stacks = merge(stacks)) {
|
for (ItemStack s : stacks) {
|
||||||
for (int i = slot; i < endSlot; i++) {
|
for (int i = 0; i < dummy.getSlots(); i++) {
|
||||||
s = inv.insertItem(i, s, true, fromAutomation);
|
s = dummy.insertItem(i, s, false, fromAutomation);
|
||||||
if (s.isEmpty()) break;
|
if (s.isEmpty()) break;
|
||||||
}
|
}
|
||||||
if (s.isEmpty()) counter++;
|
if (s.isEmpty()) counter++;
|
||||||
|
@ -249,31 +209,14 @@ public final class StackUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines every stack in the given list into larger stacks when possible.
|
* Constructs a clone of the given item handler, from the given slots. The new item handler will have the provided slot as slot 0.
|
||||||
|
* This is used for testing the ability to add all itemstacks, and should not be used for anything else.
|
||||||
*/
|
*/
|
||||||
public static List<ItemStack> merge(List<ItemStack> stacks) {
|
public static ItemStackHandlerAA testDummy(ItemStackHandlerAA inv, int slot, int endSlot) {
|
||||||
if (stacks.isEmpty()) return stacks;
|
NonNullList<ItemStack> stacks = NonNullList.withSize(endSlot - slot, getEmpty());
|
||||||
|
for (int i = slot; i < endSlot; i++)
|
||||||
ItemStack[] array = stacks.toArray(new ItemStack[0]);
|
stacks.set(i - slot, inv.getStackInSlot(i).copy());
|
||||||
List<ItemStack> list = new ArrayList<>();
|
return new ItemStackHandlerAA(stacks, inv.getAcceptor(), inv.getRemover());
|
||||||
|
|
||||||
while (!array[array.length - 1].isEmpty()) {
|
|
||||||
ItemStack merged = ItemStack.EMPTY;
|
|
||||||
for (int i = 0; i < array.length; i++) {
|
|
||||||
ItemStack stack = array[i];
|
|
||||||
if (merged.isEmpty()) {
|
|
||||||
merged = stack.copy();
|
|
||||||
array[i] = ItemStack.EMPTY;
|
|
||||||
} else if (ItemHandlerHelper.canItemStacksStack(merged, stack)) {
|
|
||||||
merged.grow(stack.getCount());
|
|
||||||
array[i] = ItemStack.EMPTY;
|
|
||||||
} else break;
|
|
||||||
}
|
|
||||||
list.add(merged);
|
|
||||||
merged = ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue