Loads more work on Formulaic Assemblicators. Seem to be about polished!

This commit is contained in:
aidancbrady 2016-03-15 19:07:22 -04:00
parent 779c2c49e7
commit 9c8e392638
7 changed files with 119 additions and 57 deletions

View file

@ -14,14 +14,18 @@ import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiTransporterConfigTab; import mekanism.client.gui.element.GuiTransporterConfigTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerFormulaicAssemblicator; import mekanism.common.inventory.container.ContainerFormulaicAssemblicator;
import mekanism.common.item.ItemCraftingFormula;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityFormulaicAssemblicator; import mekanism.common.tile.TileEntityFormulaicAssemblicator;
import mekanism.common.util.LangUtils; import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -63,30 +67,24 @@ public class GuiFormulaicAssemblicator extends GuiMekanism
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
if(!tileEntity.autoMode) if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59)
{ {
/*if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) drawCreativeTabHoveringText(LangUtils.localize("gui.encodeFormula"), xAxis, yAxis);
{
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 0, 14, 14);
}
if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)
{
drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 0, 16, 16);
}
if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91)
{
drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 0, 16, 16);
}*/
} }
if(tileEntity.formula != null) if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)
{ {
if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) drawCreativeTabHoveringText(LangUtils.localize("gui.craftSingle"), xAxis, yAxis);
{ }
} if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91)
{
drawCreativeTabHoveringText(LangUtils.localize("gui.craftAvailable"), xAxis, yAxis);
}
if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91)
{
drawCreativeTabHoveringText(LangUtils.localize("gui.autoModeToggle") + " " + LangUtils.transOnOff(!tileEntity.autoMode), xAxis, yAxis);
} }
super.drawGuiContainerForegroundLayer(mouseX, mouseY); super.drawGuiContainerForegroundLayer(mouseX, mouseY);
@ -104,14 +102,17 @@ public class GuiFormulaicAssemblicator extends GuiMekanism
int xAxis = mouseX - guiWidth; int xAxis = mouseX - guiWidth;
int yAxis = mouseY - guiHeight; int yAxis = mouseY - guiHeight;
if(!tileEntity.autoMode) if(!tileEntity.autoMode && tileEntity.isRecipe)
{ {
if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) if(canEncode())
{ {
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 0, 14, 14); if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59)
} {
else { drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 0, 14, 14);
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 14, 14, 14); }
else {
drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 14, 14, 14);
}
} }
if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)
@ -150,9 +151,48 @@ public class GuiFormulaicAssemblicator extends GuiMekanism
drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 32, 16, 16); drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 32, 16, 16);
} }
if(tileEntity.operatingTicks > 0)
{
int display = (int)((double)tileEntity.operatingTicks*22/(double)tileEntity.ticksRequired);
drawTexturedModalRect(guiWidth + 86, guiHeight + 43, 176, 48, display, 16);
}
if(tileEntity.isRecipe)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png"));
drawTexturedModalRect(guiWidth + 90, guiHeight + 25, 2, 39, 14, 12);
}
if(tileEntity.formula != null)
{
for(int i = 0; i < 9; i++)
{
ItemStack stack = tileEntity.formula.input[i];
if(stack != null)
{
Slot slot = (Slot)inventorySlots.inventorySlots.get(i+20);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
MekanismRenderer.blendOn();
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), stack, guiWidth + slot.xDisplayPosition, guiHeight + slot.yDisplayPosition);
MekanismRenderer.blendOff();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
}
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
} }
private boolean canEncode()
{
return tileEntity.formula == null && tileEntity.inventory[2] != null && tileEntity.inventory[2].getItem() instanceof ItemCraftingFormula &&
((ItemCraftingFormula)tileEntity.inventory[2].getItem()).getInventory(tileEntity.inventory[2]) == null;
}
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int button) protected void mouseClicked(int mouseX, int mouseY, int button)
{ {
@ -163,14 +203,17 @@ public class GuiFormulaicAssemblicator extends GuiMekanism
int xAxis = (mouseX - (width - xSize) / 2); int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2); int yAxis = (mouseY - (height - ySize) / 2);
if(!tileEntity.autoMode) if(!tileEntity.autoMode && tileEntity.isRecipe)
{ {
if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) if(canEncode())
{ {
ArrayList data = new ArrayList(); if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59)
data.add(1); {
ArrayList data = new ArrayList();
data.add(1);
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
}
} }
if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91)

View file

@ -522,6 +522,9 @@ public class Mekanism
MachineType.FORMULAIC_ASSEMBLICATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 5), new Object[] { MachineType.FORMULAIC_ASSEMBLICATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 5), new Object[] {
"STS", "BIB", "SCS", Character.valueOf('S'), "ingotSteel", Character.valueOf('T'), Blocks.crafting_table, Character.valueOf('B'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('I'), new ItemStack(MekanismBlocks.MachineBlock, 1, 8), Character.valueOf('C'), Blocks.chest "STS", "BIB", "SCS", Character.valueOf('S'), "ingotSteel", Character.valueOf('T'), Blocks.crafting_table, Character.valueOf('B'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('I'), new ItemStack(MekanismBlocks.MachineBlock, 1, 8), Character.valueOf('C'), Blocks.chest
})); }));
CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe(new ItemStack(MekanismItems.CraftingFormula), new Object[] {
Items.paper, MekanismUtils.getControlCircuit(BaseTier.BASIC)
}));
//Energy Cube recipes //Energy Cube recipes
CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] { CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] {

View file

@ -11,10 +11,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -60,21 +56,6 @@ public class ContainerFormulaicAssemblicator extends Container
{ {
return !tileEntity.autoMode; return !tileEntity.autoMode;
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getBackgroundIconIndex()
{
if(tileEntity.formula != null)
{
ItemStack stack = tileEntity.formula.input[getSlotIndex()-27];
GL11.glColor4f(1, 1, 1, 0.4F);
return stack != null ? stack.getIconIndex() : null;
}
return null;
}
}); });
} }
} }

View file

@ -36,7 +36,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
public double energyPerTick = BASE_ENERGY_PER_TICK; public double energyPerTick = BASE_ENERGY_PER_TICK;
public int BASE_TICKS_REQUIRED = 100; public int BASE_TICKS_REQUIRED = 40;
public int ticksRequired = BASE_TICKS_REQUIRED; public int ticksRequired = BASE_TICKS_REQUIRED;
@ -134,17 +134,38 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
{ {
toggleAutoMode(); toggleAutoMode();
} }
else if(formula != null)
if(formula == null)
{ {
moveItemsToGrid(); if(autoMode)
{
toggleAutoMode();
}
for(int i = 0; i < 9; i++)
{
dummyInv.setInventorySlotContents(i, inventory[27+i]);
}
isRecipe = MekanismUtils.findMatchingRecipe(dummyInv, worldObj) != null;
}
else {
isRecipe = formula.matches(worldObj, inventory, 27);
} }
if(autoMode && formula != null && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) || MekanismUtils.canFunction(this))) if(autoMode && formula != null && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) || MekanismUtils.canFunction(this)))
{ {
boolean canOperate = true; boolean canOperate = true;
if(formula.matches(worldObj, inventory, 27)) if(!formula.matches(worldObj, inventory, 27))
{ {
canOperate = moveItemsToGrid();
}
if(canOperate)
{
isRecipe = true;
if(operatingTicks == ticksRequired) if(operatingTicks == ticksRequired)
{ {
if(doSingleCraft()) if(doSingleCraft())
@ -231,6 +252,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
} }
} }
if(formula != null)
{
moveItemsToGrid();
}
markDirty(); markDirty();
return true; return true;
@ -243,7 +269,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
{ {
if(formula != null) if(formula != null)
{ {
boolean canOperate = false; boolean canOperate = true;
if(!formula.matches(worldObj, inventory, 27)) if(!formula.matches(worldObj, inventory, 27))
{ {

View file

@ -1,5 +1,6 @@
package mekanism.common.util; package mekanism.common.util;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -267,8 +268,12 @@ public class RecipeUtils
public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world) public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world)
{ {
for(IRecipe recipe : (List<IRecipe>)CraftingManager.getInstance().getRecipeList()) List<IRecipe> list = new ArrayList<IRecipe>(CraftingManager.getInstance().getRecipeList());
for(Iterator<IRecipe> iter = list.iterator(); iter.hasNext();)
{ {
IRecipe recipe = iter.next();
if(recipe.matches(inv, world)) if(recipe.matches(inv, world))
{ {
return recipe; return recipe;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -532,6 +532,10 @@ gui.maxSteam=Max Steam
gui.heatTransfer=Heat Transfer gui.heatTransfer=Heat Transfer
gui.superheaters=Superheaters gui.superheaters=Superheaters
gui.boilCapacity=Boil Capacity gui.boilCapacity=Boil Capacity
gui.encodeFormula=Encode Formula
gui.autoModeToggle=Turn Auto-Mode
gui.craftSingle=Craft Single Item
gui.craftAvailable=Craft Available Items
gui.reactor.injectionRate=Injection Rate gui.reactor.injectionRate=Injection Rate