mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
Made the bio reactor accept blocks as well
This commit is contained in:
parent
c4ef288653
commit
936df5fd5f
2 changed files with 20 additions and 5 deletions
|
@ -57,7 +57,7 @@ public class ContainerBioReactor extends Container{
|
||||||
//Other Slots in Inventory excluded
|
//Other Slots in Inventory excluded
|
||||||
if(slot >= inventoryStart){
|
if(slot >= inventoryStart){
|
||||||
//Shift from Inventory
|
//Shift from Inventory
|
||||||
if(TileEntityBioReactor.isValidItem(newStack.getItem())){
|
if(TileEntityBioReactor.isValidItem(newStack)){
|
||||||
if(!this.mergeItemStack(newStack, 0, 8, false)){
|
if(!this.mergeItemStack(newStack, 0, 8, false)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import cofh.api.energy.EnergyStorage;
|
import cofh.api.energy.EnergyStorage;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.IGrowable;
|
import net.minecraft.block.IGrowable;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemFood;
|
import net.minecraft.item.ItemFood;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -49,7 +51,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
ItemStack stack = this.slots[i];
|
ItemStack stack = this.slots[i];
|
||||||
if(stack != null){
|
if(stack != null){
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if(isValidItem(item) && (types == null || !types.contains(item))){
|
if(isValidItem(stack) && (types == null || !types.contains(item))){
|
||||||
if(types == null){
|
if(types == null){
|
||||||
types = new ArrayList<Item>();
|
types = new ArrayList<Item>();
|
||||||
}
|
}
|
||||||
|
@ -110,8 +112,21 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
this.producePerTick = compound.getInteger("ProducePerTick");
|
this.producePerTick = compound.getInteger("ProducePerTick");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidItem(Item item){
|
public static boolean isValidItem(ItemStack stack){
|
||||||
return item instanceof IPlantable || item instanceof IGrowable || item instanceof ItemFood;
|
if(stack != null){
|
||||||
|
Item item = stack.getItem();
|
||||||
|
if(isValid(item)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(item instanceof ItemBlock){
|
||||||
|
return isValid(Block.getBlockFromItem(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isValid(Object o){
|
||||||
|
return o instanceof IPlantable || o instanceof IGrowable || o instanceof ItemFood;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,7 +141,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack){
|
public boolean isItemValidForSlot(int index, ItemStack stack){
|
||||||
return isValidItem(stack.getItem());
|
return isValidItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue