More Assemblicator work, added Crafting Formula item
This commit is contained in:
parent
a247a80d53
commit
f31e32fcf2
8 changed files with 261 additions and 28 deletions
|
@ -4,8 +4,10 @@ import mekanism.common.item.ItemAlloy;
|
|||
import mekanism.common.item.ItemAtomicDisassembler;
|
||||
import mekanism.common.item.ItemBalloon;
|
||||
import mekanism.common.item.ItemClump;
|
||||
import mekanism.common.item.ItemConfigurationCard;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.item.ItemControlCircuit;
|
||||
import mekanism.common.item.ItemCraftingFormula;
|
||||
import mekanism.common.item.ItemCrystal;
|
||||
import mekanism.common.item.ItemDictionary;
|
||||
import mekanism.common.item.ItemDirtyDust;
|
||||
|
@ -13,7 +15,6 @@ import mekanism.common.item.ItemDust;
|
|||
import mekanism.common.item.ItemElectricBow;
|
||||
import mekanism.common.item.ItemEnergized;
|
||||
import mekanism.common.item.ItemFactoryInstaller;
|
||||
import mekanism.common.item.ItemConfigurationCard;
|
||||
import mekanism.common.item.ItemFlamethrower;
|
||||
import mekanism.common.item.ItemFreeRunners;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
|
@ -82,6 +83,7 @@ public class MekanismItems
|
|||
public static final Item Dictionary = new ItemDictionary().setUnlocalizedName("Dictionary");
|
||||
public static final ItemGaugeDropper GaugeDropper = (ItemGaugeDropper)new ItemGaugeDropper().setUnlocalizedName("GaugeDropper");
|
||||
public static final Item ConfigurationCard = new ItemConfigurationCard().setUnlocalizedName("ConfigurationCard");
|
||||
public static final Item CraftingFormula = new ItemCraftingFormula().setUnlocalizedName("CraftingFormula");
|
||||
public static final Item PartTransmitter = new ItemPartTransmitter().setUnlocalizedName("MultipartTransmitter");
|
||||
public static final Item GlowPanel = new ItemGlowPanel().setUnlocalizedName("GlowPanel");
|
||||
public static final ItemScubaTank ScubaTank = (ItemScubaTank)new ItemScubaTank().setUnlocalizedName("ScubaTank");
|
||||
|
@ -153,6 +155,7 @@ public class MekanismItems
|
|||
GameRegistry.registerItem(FreeRunners, "FreeRunners");
|
||||
GameRegistry.registerItem(ArmoredJetpack, "ArmoredJetpack");
|
||||
GameRegistry.registerItem(ConfigurationCard, "ConfigurationCard");
|
||||
GameRegistry.registerItem(CraftingFormula, "CraftingFormula");
|
||||
GameRegistry.registerItem(SeismicReader, "SeismicReader");
|
||||
GameRegistry.registerItem(Substrate, "Substrate");
|
||||
GameRegistry.registerItem(Polyethene, "Polyethene");
|
||||
|
|
|
@ -155,6 +155,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* 2:2: Ambient Accumulator
|
||||
* 2:3: Oredictionificator
|
||||
* 2:4: Resistive Heater
|
||||
* 2:5: Formulaic Assemblicator
|
||||
*
|
||||
* @author AidanBrady
|
||||
*
|
||||
|
@ -227,6 +228,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
|||
icons[0][0] = BASE_ICON;
|
||||
icons[2][0] = BASE_ICON;
|
||||
icons[4][0] = BASE_ICON;
|
||||
icons[5][0] = BASE_ICON;
|
||||
MekanismRenderer.loadDynamicTextures(register, MachineType.OREDICTIONIFICATOR.name, icons[3], DefIcon.getAll(register.registerIcon("mekanism:OredictionificatorSide")));
|
||||
break;
|
||||
}
|
||||
|
@ -1225,7 +1227,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
|||
|
||||
for(MachineType type : MachineType.values())
|
||||
{
|
||||
if(type != AMBIENT_ACCUMULATOR && type != FORMULAIC_ASSEMBLICATOR)
|
||||
if(type != AMBIENT_ACCUMULATOR)
|
||||
{
|
||||
ret.add(type);
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* 2:2: Ambient Accumulator
|
||||
* 2:3: Oredictionificator
|
||||
* 2:4: Resistive Heater
|
||||
* 2:5: Formulaic Assemblicator
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
|
|
172
src/main/java/mekanism/common/item/ItemCraftingFormula.java
Normal file
172
src/main/java/mekanism/common/item/ItemCraftingFormula.java
Normal file
|
@ -0,0 +1,172 @@
|
|||
package mekanism.common.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.LangUtils;
|
||||
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.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCraftingFormula extends ItemMekanism
|
||||
{
|
||||
public ItemCraftingFormula()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
|
||||
{
|
||||
ItemStack[] inv = getInventory(itemstack);
|
||||
|
||||
if(inv != null)
|
||||
{
|
||||
addIngredientDetails(inv, list);
|
||||
}
|
||||
}
|
||||
|
||||
private void addIngredientDetails(ItemStack[] inv, List list)
|
||||
{
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
|
||||
for(ItemStack stack : inv)
|
||||
{
|
||||
if(stack != null)
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
for(ItemStack iterStack : stacks)
|
||||
{
|
||||
if(InventoryUtils.canStack(stack, iterStack))
|
||||
{
|
||||
iterStack.stackSize += stack.stackSize;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.add(EnumColor.GREY + LangUtils.localize("tooltip.ingredients") + ":");
|
||||
|
||||
for(ItemStack stack : stacks)
|
||||
{
|
||||
list.add(EnumColor.GREY + " - " + stack.getDisplayName() + " (" + stack.stackSize + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(player.isSneaking() && !world.isRemote)
|
||||
{
|
||||
setInventory(stack, null);
|
||||
setInvalid(stack, false);
|
||||
|
||||
((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack)
|
||||
{
|
||||
return getInventory(stack) != null ? 1 : 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
if(getInventory(stack) == null)
|
||||
{
|
||||
return super.getItemStackDisplayName(stack);
|
||||
}
|
||||
|
||||
return super.getItemStackDisplayName(stack) + " " + (isInvalid(stack) ? EnumColor.DARK_RED + "(" + LangUtils.localize("tooltip.invalid")
|
||||
: EnumColor.DARK_GREEN + "(" + LangUtils.localize("tooltip.encoded")) + ")";
|
||||
}
|
||||
|
||||
public boolean isInvalid(ItemStack stack)
|
||||
{
|
||||
if(stack.stackTagCompound == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return stack.stackTagCompound.getBoolean("invalid");
|
||||
}
|
||||
|
||||
public void setInvalid(ItemStack stack, boolean invalid)
|
||||
{
|
||||
if(stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.stackTagCompound.setBoolean("invalid", invalid);
|
||||
}
|
||||
|
||||
public ItemStack[] getInventory(ItemStack stack)
|
||||
{
|
||||
if(stack.stackTagCompound == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagList tagList = stack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND);
|
||||
ItemStack[] inventory = new ItemStack[9];
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < 9)
|
||||
{
|
||||
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setInventory(ItemStack stack, ItemStack[] inv)
|
||||
{
|
||||
if(stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < 9; slotCount++)
|
||||
{
|
||||
if(inv[slotCount] != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
inv[slotCount].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
stack.stackTagCompound.setTag("Items", tagList);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -16,6 +17,8 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidContainerItem
|
||||
{
|
||||
|
@ -67,20 +70,23 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidCo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(player.isSneaking() && !world.isRemote)
|
||||
{
|
||||
setGas(stack, null);
|
||||
setFluid(stack, null);
|
||||
|
||||
((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
|
||||
|
||||
return true;
|
||||
return stack;
|
||||
}
|
||||
|
||||
return false;
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
|
||||
{
|
||||
GasStack gasStack = getGas(itemstack);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package mekanism.common.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemRecipeFormula extends ItemMekanism
|
||||
{
|
||||
public ItemRecipeFormula()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ import mekanism.common.base.ISideConfiguration;
|
|||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.content.assemblicator.RecipeFormula;
|
||||
import mekanism.common.item.ItemRecipeFormula;
|
||||
import mekanism.common.item.ItemCraftingFormula;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
|
@ -43,6 +43,8 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
|
||||
public boolean autoMode = false;
|
||||
|
||||
public int pulseOperations;
|
||||
|
||||
public RecipeFormula formula;
|
||||
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
@ -83,15 +85,49 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
{
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(inventory[2] != null && inventory[2].getItem() instanceof ItemRecipeFormula)
|
||||
if(controlType != RedstoneControl.PULSE)
|
||||
{
|
||||
pulseOperations = 0;
|
||||
}
|
||||
else if(MekanismUtils.canFunction(this))
|
||||
{
|
||||
pulseOperations++;
|
||||
}
|
||||
|
||||
if(inventory[2] != null && inventory[2].getItem() instanceof ItemCraftingFormula)
|
||||
{
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem();
|
||||
|
||||
if(item.getInventory(inventory[2]) != null && !item.isInvalid(inventory[2]))
|
||||
{
|
||||
RecipeFormula itemFormula = new RecipeFormula(item.getInventory(inventory[2]));
|
||||
|
||||
if(itemFormula.isValidFormula(worldObj))
|
||||
{
|
||||
if(formula != null && !formula.isFormulaEqual(worldObj, itemFormula))
|
||||
{
|
||||
itemFormula = formula;
|
||||
operatingTicks = 0;
|
||||
}
|
||||
else if(formula == null)
|
||||
{
|
||||
formula = itemFormula;
|
||||
}
|
||||
}
|
||||
else {
|
||||
formula = null;
|
||||
item.setInvalid(inventory[2], true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
formula = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
formula = null;
|
||||
}
|
||||
|
||||
if(autoMode && formula != null)
|
||||
if(autoMode && formula != null && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) || MekanismUtils.canFunction(this)))
|
||||
{
|
||||
boolean canOperate = true;
|
||||
|
||||
|
@ -104,9 +140,14 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
{
|
||||
if(operatingTicks == ticksRequired)
|
||||
{
|
||||
if(MekanismUtils.canFunction(this))
|
||||
if(doSingleCraft())
|
||||
{
|
||||
doSingleCraft();
|
||||
operatingTicks = 0;
|
||||
|
||||
if(pulseOperations > 0)
|
||||
{
|
||||
pulseOperations--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -150,6 +191,8 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
}
|
||||
}
|
||||
|
||||
markDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -191,6 +234,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
if(inventory[i] != null)
|
||||
{
|
||||
inventory[i] = tryMoveToInput(inventory[i]);
|
||||
markDirty();
|
||||
|
||||
if(inventory[i] != null)
|
||||
{
|
||||
|
@ -212,6 +256,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
inventory[j] = null;
|
||||
}
|
||||
|
||||
markDirty();
|
||||
found = true;
|
||||
|
||||
break;
|
||||
|
@ -246,6 +291,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
inventory[i] = tryMoveToInput(inventory[i]);
|
||||
}
|
||||
|
||||
markDirty();
|
||||
autoMode = true;
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +363,20 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
|
||||
private void encodeFormula()
|
||||
{
|
||||
|
||||
if(inventory[2] != null && inventory[2].getItem() instanceof ItemCraftingFormula)
|
||||
{
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem();
|
||||
|
||||
if(item.getInventory(inventory[2]) == null)
|
||||
{
|
||||
RecipeFormula formula = new RecipeFormula(inventory, 27);
|
||||
|
||||
if(formula.isValidFormula(worldObj))
|
||||
{
|
||||
item.setInventory(inventory[2], formula.input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -334,6 +393,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
autoMode = nbtTags.getBoolean("autoMode");
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
pulseOperations = nbtTags.getInteger("pulseOperations");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -344,6 +404,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
|||
nbtTags.setBoolean("autoMode", autoMode);
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setInteger("pulseOperations", pulseOperations);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,6 +48,7 @@ item.Substrate.name=Substrate
|
|||
item.Flamethrower.name=Flamethrower
|
||||
item.GaugeDropper.name=Gauge Dropper
|
||||
item.BioFuel.name=Bio Fuel
|
||||
item.CraftingFormula.name=Crafting Formula
|
||||
|
||||
//Control Circuits
|
||||
item.BasicControlCircuit.name=Basic Control Circuit
|
||||
|
@ -719,6 +720,9 @@ tooltip.speed=Speed
|
|||
tooltip.and=and
|
||||
tooltip.heat=Heat
|
||||
tooltip.itemAmount=Item amount
|
||||
tooltip.invalid=Invalid
|
||||
tooltip.encoded=Encoded
|
||||
tooltip.ingredients=Ingredients
|
||||
|
||||
tooltip.portableTank.bucketMode=Bucket Mode
|
||||
|
||||
|
@ -797,6 +801,7 @@ tooltip.SolarNeutronActivator=A machine that directs the neutron radiation of th
|
|||
tooltip.Oredictionificator=A machine used to unify and translate between various items and blocks using the Ore Dictionary.
|
||||
tooltip.Factory=A machine that serves as an upgrade to regular machinery, allowing for multiple processing operations to occur at once.
|
||||
tooltip.ResistiveHeater=A condensed, coiled resistor capable of converting electrical energy directly into heat energy.
|
||||
tooltip.FormulaicAssemblicator=A machine that uses energy to rapidly craft items and blocks from Recipe Formulas. Doubles as an advanced crafting bench.
|
||||
|
||||
tooltip.HeatGenerator=A generator that uses the heat of lava or other burnable resources to produce energy.
|
||||
tooltip.SolarGenerator=A generator that uses the power of the sun to produce energy.
|
||||
|
|
Loading…
Reference in a new issue