diff --git a/common/mekanism/client/nei/ChanceMachineRecipeHandler.java b/common/mekanism/client/nei/ChanceMachineRecipeHandler.java new file mode 100644 index 000000000..ea8c05c95 --- /dev/null +++ b/common/mekanism/client/nei/ChanceMachineRecipeHandler.java @@ -0,0 +1,143 @@ +package mekanism.client.nei; + +import static codechicken.core.gui.GuiDraw.changeTexture; +import static codechicken.core.gui.GuiDraw.drawTexturedModalRect; +import static codechicken.core.gui.GuiDraw.drawString; + +import java.awt.Rectangle; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import mekanism.api.ChanceOutput; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; + +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; + +public abstract class ChanceMachineRecipeHandler extends TemplateRecipeHandler +{ + private int ticksPassed; + + public abstract String getRecipeId(); + + public abstract Set> getRecipes(); + + @Override + public void drawBackground(int i) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(12, 0, 28, 5, 144, 68); + } + + @Override + public void drawExtras(int i) + { + CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + + float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; + drawProgressBar(63, 34, 176, 0, 24, 7, f, 0); + f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + drawProgressBar(149, 12, 176, 7, 4, 52, f, 3); + + if(recipe.output.hasSecondary()) + { + drawString(Math.round(recipe.output.secondaryChance*100) + "%", 116, 52, 0x404040); + } + } + + @Override + public void onUpdate() + { + super.onUpdate(); + ticksPassed++; + } + + @Override + public void loadTransferRects() + { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0])); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) + { + if(outputId.equals(getRecipeId())) + { + for(Map.Entry irecipe : getRecipes()) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) + { + for(Map.Entry irecipe : getRecipes()) + { + if(irecipe.getValue().hasPrimary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().primaryOutput, result)) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + else if(irecipe.getValue().hasSecondary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().secondaryOutput, result)) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + for(Map.Entry irecipe : getRecipes()) + { + if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } + + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe + { + public PositionedStack input; + public ChanceOutput output; + + @Override + public PositionedStack getIngredient() + { + return input; + } + + @Override + public PositionedStack getResult() + { + return new PositionedStack(output.primaryOutput, 100, 30); + } + + @Override + public PositionedStack getOtherStack() + { + return new PositionedStack(output.secondaryOutput, 116, 30); + } + + public CachedIORecipe(ItemStack itemstack, ChanceOutput chance) + { + input = new PositionedStack(itemstack, 40, 12); + output = chance; + } + + public CachedIORecipe(Map.Entry recipe) + { + this((ItemStack)recipe.getKey(), (ChanceOutput)recipe.getValue()); + } + } +} diff --git a/common/mekanism/client/nei/NEIMekanismConfig.java b/common/mekanism/client/nei/NEIMekanismConfig.java index 5081c44f4..861b756cf 100644 --- a/common/mekanism/client/nei/NEIMekanismConfig.java +++ b/common/mekanism/client/nei/NEIMekanismConfig.java @@ -9,6 +9,7 @@ import mekanism.client.gui.GuiElectrolyticSeparator; import mekanism.client.gui.GuiEnrichmentChamber; import mekanism.client.gui.GuiMetallurgicInfuser; import mekanism.client.gui.GuiOsmiumCompressor; +import mekanism.client.gui.GuiPrecisionSawmill; import mekanism.client.gui.GuiPurificationChamber; import mekanism.client.gui.GuiRotaryCondensentrator; import mekanism.common.Mekanism; @@ -56,6 +57,9 @@ public class NEIMekanismConfig implements IConfigureNEI API.registerRecipeHandler(new ElectrolyticSeparatorRecipeHandler()); API.registerUsageHandler(new ElectrolyticSeparatorRecipeHandler()); + API.registerRecipeHandler(new PrecisionSawmillRecipeHandler()); + API.registerUsageHandler(new PrecisionSawmillRecipeHandler()); + API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6); API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6); API.setGuiOffset(GuiCrusher.class, 16, 6); @@ -67,6 +71,7 @@ public class NEIMekanismConfig implements IConfigureNEI API.setGuiOffset(GuiChemicalInfuser.class, ChemicalInfuserRecipeHandler.xOffset, ChemicalInfuserRecipeHandler.yOffset); API.setGuiOffset(GuiRotaryCondensentrator.class, RotaryCondensentratorRecipeHandler.xOffset, RotaryCondensentratorRecipeHandler.yOffset); API.setGuiOffset(GuiElectrolyticSeparator.class, ElectrolyticSeparatorRecipeHandler.xOffset, ElectrolyticSeparatorRecipeHandler.yOffset); + API.setGuiOffset(GuiPrecisionSawmill.class, 16, 6); API.hideItem(Mekanism.boundingBlockID); API.hideItem(Mekanism.ItemProxy.itemID); diff --git a/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java b/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java new file mode 100644 index 000000000..589cecbc5 --- /dev/null +++ b/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java @@ -0,0 +1,45 @@ +package mekanism.client.nei; + +import java.util.Set; + +import mekanism.client.gui.GuiPrecisionSawmill; +import mekanism.common.recipe.RecipeHandler.Recipe; + +public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler +{ + @Override + public String getRecipeName() + { + return "Precision Sawmill"; + } + + @Override + public String getRecipeId() + { + return "mekanism.precisionsawmill"; + } + + @Override + public String getOverlayIdentifier() + { + return "precisionsawmill"; + } + + @Override + public Set getRecipes() + { + return Recipe.PRECISION_SAWMILL.get().entrySet(); + } + + @Override + public String getGuiTexture() + { + return "mekanism:gui/GuiPrecisionSawmill.png"; + } + + @Override + public Class getGuiClass() + { + return GuiPrecisionSawmill.class; + } +} diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 257495c2e..54f4dcf5f 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -246,6 +246,7 @@ public class Mekanism public static Item ElectrolyticCore; public static Item CompressedRedstone; public static Item Sawdust; + public static Item Salt; //Blocks public static Block BasicBlock; @@ -710,6 +711,7 @@ public class Mekanism ElectrolyticCore = new ItemMekanism(configuration.getItem("ElectrolyticCore", 11228).getInt()).setUnlocalizedName("ElectrolyticCore"); CompressedRedstone = new ItemMekanism(configuration.getItem("CompressedRedstone", 11229).getInt()).setUnlocalizedName("CompressedRedstone"); Sawdust = new ItemMekanism(configuration.getItem("Sawdust", 11230).getInt()).setUnlocalizedName("Sawdust"); + Salt = new ItemMekanism(configuration.getItem("Salt", 11231).getInt()).setUnlocalizedName("Salt"); configuration.save(); @@ -744,6 +746,7 @@ public class Mekanism GameRegistry.registerItem(ElectrolyticCore, "ElectrolyticCore"); GameRegistry.registerItem(CompressedRedstone, "CompressedRedstone"); GameRegistry.registerItem(Sawdust, "Sawdust"); + GameRegistry.registerItem(Salt, "Salt"); } /** @@ -783,10 +786,14 @@ public class Mekanism OreDictionary.registerOre("universalCable", new ItemStack(PartTransmitter, 8, 0)); OreDictionary.registerOre("battery", EnergyTablet.getUnchargedItem()); - //GregoriousT, should I use "sawdust" or "dustSaw"? I'll use both. - OreDictionary.registerOre("sawdust", Sawdust); + //GregoriousT, should I use "itemDust" or "dustSaw"? I'll use both. + OreDictionary.registerOre("itemSawdust", Sawdust); OreDictionary.registerOre("dustSaw", Sawdust); + //Same question Greg... + OreDictionary.registerOre("itemSalt", Salt); + OreDictionary.registerOre("dustSalt", Salt); + OreDictionary.registerOre("dustIron", new ItemStack(Dust, 1, 0)); OreDictionary.registerOre("dustGold", new ItemStack(Dust, 1, 1)); OreDictionary.registerOre("dustOsmium", new ItemStack(Dust, 1, 2)); diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index de1021fb0..4b92c0bd2 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -421,34 +421,14 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds } else if(blockID == Mekanism.machineBlock2ID) { - if(meta == 2) + if(meta == 3 || meta == 5) { if(side == 3) { - return icons[2][0]; + return icons[meta][0]; } else { - return icons[2][2]; - } - } - else if(meta == 3) - { - if(side == 3) - { - return icons[3][0]; - } - else { - return icons[3][2]; - } - } - else if(meta == 4) - { - if(side == 3) - { - return icons[4][0]; - } - else { - return icons[4][2]; + return icons[meta][2]; } } } diff --git a/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOff.png b/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOff.png index 28ffbcba2..2b3866889 100644 Binary files a/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOff.png and b/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOff.png differ diff --git a/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOn.png b/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOn.png index cde0d5cab..ad6cfc582 100644 Binary files a/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOn.png and b/resources/assets/mekanism/textures/blocks/ChemicalInjectionChamberFrontOn.png differ diff --git a/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOff.png b/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOff.png index e60f23f27..bf970210c 100644 Binary files a/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOff.png and b/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOff.png differ diff --git a/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png b/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png index 80c6ee22f..994930caf 100644 Binary files a/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png and b/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png differ diff --git a/resources/assets/mekanism/textures/items/Salt.png b/resources/assets/mekanism/textures/items/Salt.png index 45c19c1ee..6e0e4a7d1 100644 Binary files a/resources/assets/mekanism/textures/items/Salt.png and b/resources/assets/mekanism/textures/items/Salt.png differ