mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Work on Formulaic Assemblicator, many fixes
This commit is contained in:
1 parent
f31e32fcf2
commit
6f4e73d15e
12 files changed
+302
-23
No files matched your search
@@ -0,0 +1,9 @@
|
||||
package mekanism.client.gui;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiFormulaicAssemblicator {
|
||||
|
||||
}
|
||||
@@ -27,19 +27,19 @@ public class ContainerDigitalMiner extends Container
|
||||
|
||||
addSlotToContainer(new SlotDischarge(tentity, 27, 152, 6));
|
||||
|
||||
int slotX;
|
||||
int slotY;
|
||||
|
||||
for(slotX = 0; slotX < 3; slotX++)
|
||||
for(slotY = 0; slotY < 3; slotY++)
|
||||
{
|
||||
for(int slotY = 0; slotY < 9; slotY++)
|
||||
for(int slotX = 0; slotX < 9; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18));
|
||||
addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; slotX++)
|
||||
for(slotY = 0; slotY < 9; slotY++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206));
|
||||
addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206));
|
||||
}
|
||||
|
||||
tileEntity.open(inventory.player);
|
||||
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.inventory.slot.SlotSpecific;
|
||||
import mekanism.common.item.ItemCraftingFormula;
|
||||
import mekanism.common.tile.TileEntityFormulaicAssemblicator;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
|
||||
public class ContainerFormulaicAssemblicator extends Container
|
||||
{
|
||||
private TileEntityFormulaicAssemblicator tileEntity;
|
||||
|
||||
public ContainerFormulaicAssemblicator(InventoryPlayer inventory, TileEntityFormulaicAssemblicator tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new SlotDischarge(tentity, 1, 155, 76));
|
||||
addSlotToContainer(new SlotSpecific(tentity, 2, 6, 26, ItemCraftingFormula.class));
|
||||
|
||||
int slotY;
|
||||
|
||||
for(slotY = 0; slotY < 2; slotY++)
|
||||
{
|
||||
for(int slotX = 0; slotX < 9; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(tentity, slotX + slotY * 9 + 3, 8 + slotX * 18, 98 + slotY * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotY = 0; slotY < 3; slotY++)
|
||||
{
|
||||
for(int slotX = 0; slotX < 3; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(tentity, slotX + slotY * 9 + 27, 26 + slotX * 18, 17 + slotY * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotY = 0; slotY < 3; slotY++)
|
||||
{
|
||||
for(int slotX = 0; slotX < 2; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(tentity, slotX + slotY * 9 + 21, 116 + slotX * 18, 17 + slotY * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotY = 0; slotY < 3; slotY++)
|
||||
{
|
||||
for(int slotX = 0; slotX < 9; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotY = 0; slotY < 9; slotY++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206));
|
||||
}
|
||||
|
||||
tileEntity.open(inventory.player);
|
||||
tileEntity.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
|
||||
tileEntity.close(entityplayer);
|
||||
tileEntity.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 2)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 2, 3, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(FluidContainerRegistry.isEmptyContainer(slotStack))
|
||||
{
|
||||
if(slotID != 0)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 0)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 3 && slotID <= 29)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 29)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 29, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -202,11 +202,6 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
|
||||
return true;
|
||||
}
|
||||
|
||||
if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -219,9 +214,12 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int newCount = stack.stackTagCompound.getInteger("newCount");
|
||||
stack.stackTagCompound.removeTag("newCount");
|
||||
|
||||
ItemStack ret = stack.copy();
|
||||
ret.stackTagCompound.setInteger("itemCount", stack.stackTagCompound.getInteger("newCount"));
|
||||
ret.stackTagCompound.setInteger("itemCount", newCount);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
@@ -18,11 +20,29 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCraftingFormula extends ItemMekanism
|
||||
{
|
||||
public IIcon[] icons = new IIcon[3];
|
||||
|
||||
public ItemCraftingFormula()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register)
|
||||
{
|
||||
icons[0] = register.registerIcon("mekanism:CraftingFormula");
|
||||
icons[1] = register.registerIcon("mekanism:CraftingFormulaInvalid");
|
||||
icons[2] = register.registerIcon("mekanism:CraftingFormulaEncoded");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int pass)
|
||||
{
|
||||
return getInventory(stack) == null ? icons[0] : (isInvalid(stack) ? icons[1] : icons[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
|
||||
|
||||
@@ -71,15 +71,18 @@ public class ItemProxy extends Item
|
||||
public void registerIcons(IIconRegister register) {}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
public void onUpdate(ItemStack stacks, World world, Entity entity, int j, boolean flag)
|
||||
{
|
||||
if (par3Entity instanceof EntityPlayer)
|
||||
if(entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) par3Entity;
|
||||
for (int i = 0; i < player.inventory.mainInventory.length; i++)
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++)
|
||||
{
|
||||
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i].getItem() == this)
|
||||
player.inventory.mainInventory[i] = null;
|
||||
if(player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i].getItem() == this)
|
||||
{
|
||||
player.inventory.mainInventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mekanism.common.recipe;
|
||||
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.block.BlockBasic.BasicType;
|
||||
import mekanism.common.inventory.InventoryBin;
|
||||
import mekanism.common.item.ItemBlockBasic;
|
||||
import mekanism.common.item.ItemProxy;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
@@ -39,7 +39,7 @@ public class BinRecipe implements IRecipe
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemStack.getItem() instanceof ItemBlockBasic && itemStack.getItemDamage() == 6 && itemStack.stackSize == 1;
|
||||
return BasicType.get(itemStack) == BasicType.BIN && itemStack.stackSize <= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,7 +99,7 @@ public class BinRecipe implements IRecipe
|
||||
}
|
||||
|
||||
binInv.add(addStack);
|
||||
|
||||
|
||||
return bin;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -9,6 +9,7 @@ import mekanism.api.IConfigCardAccess;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
@@ -17,6 +18,9 @@ import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.content.assemblicator.RecipeFormula;
|
||||
import mekanism.common.item.ItemCraftingFormula;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
@@ -384,6 +388,48 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
{
|
||||
return side != 0 && side != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
|
||||
{
|
||||
if(slotID == 1)
|
||||
{
|
||||
return ChargeUtils.canBeOutputted(itemstack, false);
|
||||
}
|
||||
else if(slotID >= 21 && slotID <= 26)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
|
||||
{
|
||||
if(slotID >= 3 && slotID <= 20)
|
||||
{
|
||||
if(formula == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return formula.isIngredient(worldObj, itemstack);
|
||||
}
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
@@ -439,6 +485,21 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
autoMode = dataStream.readBoolean();
|
||||
operatingTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
ItemStack[] inv = new ItemStack[9];
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
inv[i] = PacketHandler.readStack(dataStream);
|
||||
}
|
||||
|
||||
formula = new RecipeFormula(inv);
|
||||
}
|
||||
else {
|
||||
formula = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -450,6 +511,19 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
data.add(operatingTicks);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
if(formula != null)
|
||||
{
|
||||
data.add(true);
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
data.add(formula.input[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
public enum GasMode
|
||||
{
|
||||
IDLE,
|
||||
DUMPING,
|
||||
DUMPING_EXCESS
|
||||
DUMPING_EXCESS,
|
||||
DUMPING
|
||||
}
|
||||
|
||||
/** The type of gas stored in this tank. */
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Reference in new issue
Block a user