Finish up some PRC stuff
This commit is contained in:
parent
676773eff7
commit
9e76b3b473
3 changed files with 50 additions and 29 deletions
|
@ -4,6 +4,7 @@ import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
|||
import mekanism.common.inventory.slot.SlotMachineUpgrade;
|
||||
import mekanism.common.inventory.slot.SlotOutput;
|
||||
import mekanism.common.item.ItemMachineUpgrade;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.tile.TileEntityPRC;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
|
||||
|
@ -93,6 +94,22 @@ public class ContainerPRC extends Container
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(RecipeHandler.isInPressurizedRecipe(slotStack))
|
||||
{
|
||||
if(slotID != 0)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof ItemMachineUpgrade)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3)
|
||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.common.recipe;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.AdvancedInput;
|
||||
import mekanism.api.ChanceOutput;
|
||||
|
@ -503,6 +504,22 @@ public final class RecipeHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean isInPressurizedRecipe(ItemStack stack)
|
||||
{
|
||||
if(stack != null)
|
||||
{
|
||||
for(PressurizedReactants key : (Set<PressurizedReactants>)Recipe.PRESSURIZED_REACTION_CHAMBER.get().keySet())
|
||||
{
|
||||
if(key.containsType(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static enum Recipe
|
||||
{
|
||||
ENRICHMENT_CHAMBER(new HashMap<ItemStack, ItemStack>()),
|
||||
|
|
|
@ -15,12 +15,9 @@ import mekanism.api.gas.GasTransmission;
|
|||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.item.ItemMachineUpgrade;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
|
@ -133,7 +130,11 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
|
|||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
|
||||
{
|
||||
if(slotID == 1)
|
||||
if(slotID == 0)
|
||||
{
|
||||
return RecipeHandler.isInPressurizedRecipe(itemstack);
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
@ -177,16 +178,16 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
|
|||
|
||||
PressurizedProducts products = recipe.products;
|
||||
|
||||
if(products.getOptionalOutput() != null)
|
||||
if(products.getItemOutput() != null)
|
||||
{
|
||||
if(inventory[2] != null)
|
||||
{
|
||||
if(!inventory[2].isItemEqual(products.getOptionalOutput()))
|
||||
if(!inventory[2].isItemEqual(products.getItemOutput()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(inventory[2].stackSize + products.getOptionalOutput().stackSize > inventory[2].getMaxStackSize())
|
||||
if(inventory[2].stackSize + products.getItemOutput().stackSize > inventory[2].getMaxStackSize())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -299,35 +300,21 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
|
|||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
/*
|
||||
if(nbtTags.hasKey("fluidTank"))
|
||||
{
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
|
||||
}
|
||||
|
||||
leftTank.read(nbtTags.getCompoundTag("leftTank"));
|
||||
rightTank.read(nbtTags.getCompoundTag("rightTank"));
|
||||
|
||||
dumpLeft = nbtTags.getBoolean("dumpLeft");
|
||||
dumpRight = nbtTags.getBoolean("dumpRight");
|
||||
*/ }
|
||||
inputFluidTank.readFromNBT(nbtTags.getCompoundTag("inputFluidTank"));
|
||||
inputGasTank.read(nbtTags.getCompoundTag("inputGasTank"));
|
||||
outputGasTank.read(nbtTags.getCompoundTag("outputGasTank"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
/*
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
nbtTags.setCompoundTag("leftTank", leftTank.write(new NBTTagCompound()));
|
||||
nbtTags.setCompoundTag("rightTank", rightTank.write(new NBTTagCompound()));
|
||||
|
||||
nbtTags.setBoolean("dumpLeft", dumpLeft);
|
||||
nbtTags.setBoolean("dumpRight", dumpRight);
|
||||
*/ }
|
||||
nbtTags.setCompoundTag("inputFluidTank", inputFluidTank.writeToNBT(new NBTTagCompound()));
|
||||
nbtTags.setCompoundTag("inputGasTank", inputGasTank.write(new NBTTagCompound()));
|
||||
nbtTags.setCompoundTag("outputGasTank", outputGasTank.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
|
|
Loading…
Reference in a new issue