mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge branch 'HbmMods:master' into locale_update
This commit is contained in:
commit
093d23e700
@ -1,164 +0,0 @@
|
||||
package com.hbm.handler.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.handler.imc.ICompatNHNEI;
|
||||
import com.hbm.inventory.gui.GUIHadron;
|
||||
import com.hbm.inventory.recipes.HadronRecipes;
|
||||
import com.hbm.inventory.recipes.HadronRecipes.HadronRecipe;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HadronRecipeHandler extends TemplateRecipeHandler implements ICompatNHNEI {
|
||||
|
||||
@Override
|
||||
public ItemStack[] getMachinesForRecipe() {
|
||||
return new ItemStack[]{
|
||||
new ItemStack(ModBlocks.hadron_core)};
|
||||
}
|
||||
@Override
|
||||
public String getRecipeID() {
|
||||
return "hadron";
|
||||
}
|
||||
public LinkedList<RecipeTransferRect> transferRectsRec = new LinkedList<RecipeTransferRect>();
|
||||
public LinkedList<RecipeTransferRect> transferRectsGui = new LinkedList<RecipeTransferRect>();
|
||||
public LinkedList<Class<? extends GuiContainer>> guiRec = new LinkedList<Class<? extends GuiContainer>>();
|
||||
public LinkedList<Class<? extends GuiContainer>> guiGui = new LinkedList<Class<? extends GuiContainer>>();
|
||||
|
||||
public class RecipeSet extends TemplateRecipeHandler.CachedRecipe {
|
||||
|
||||
PositionedStack input1;
|
||||
PositionedStack input2;
|
||||
PositionedStack output1;
|
||||
PositionedStack output2;
|
||||
int momentum;
|
||||
boolean analysisOnly;
|
||||
|
||||
public RecipeSet(HadronRecipe recipe) {
|
||||
|
||||
this.input1 = new PositionedStack(recipe.in1.toStack(), 12, 24);
|
||||
this.input2 = new PositionedStack(recipe.in2.toStack(), 30, 24);
|
||||
this.output1 = new PositionedStack(recipe.out1, 84, 24);
|
||||
this.output2 = new PositionedStack(recipe.out2, 102, 24);
|
||||
this.momentum = recipe.momentum;
|
||||
this.analysisOnly = recipe.analysisOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return Arrays.asList(new PositionedStack[] { input1, input2 });
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return Arrays.asList(new PositionedStack[] { output1, output2 });
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return output1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Particle Accelerator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
|
||||
if(outputId.equals("hadron") && getClass() == HadronRecipeHandler.class) {
|
||||
|
||||
List<HadronRecipe> recipes = HadronRecipes.getRecipes();
|
||||
|
||||
for(HadronRecipe recipe : recipes) {
|
||||
this.arecipes.add(new RecipeSet(recipe));
|
||||
}
|
||||
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
|
||||
List<HadronRecipe> recipes = HadronRecipes.getRecipes();
|
||||
|
||||
for(HadronRecipe recipe : recipes) {
|
||||
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.out1, result) || NEIServerUtils.areStacksSameTypeCrafting(recipe.out2, result)) {
|
||||
this.arecipes.add(new RecipeSet(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients) {
|
||||
|
||||
if(inputId.equals("hadron") && getClass() == HadronRecipeHandler.class) {
|
||||
loadCraftingRecipes("hadron", new Object[0]);
|
||||
} else {
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
|
||||
List<HadronRecipe> recipes = HadronRecipes.getRecipes();
|
||||
|
||||
for(HadronRecipe recipe : recipes) {
|
||||
|
||||
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.in1.toStack(), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(recipe.in2.toStack(), ingredient)) {
|
||||
this.arecipes.add(new RecipeSet(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRectsGui = new LinkedList<RecipeTransferRect>();
|
||||
guiGui = new LinkedList<Class<? extends GuiContainer>>();
|
||||
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(58 - 5, 34 - 11, 24, 18), "hadron"));
|
||||
transferRectsGui.add(new RecipeTransferRect(new Rectangle(72 - 5, 28 - 11, 30, 30), "hadron"));
|
||||
guiGui.add(GUIHadron.class);
|
||||
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
|
||||
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
|
||||
RecipeSet rec = (RecipeSet) this.arecipes.get(recipe);
|
||||
|
||||
if(rec.analysisOnly)
|
||||
drawTexturedModalRect(128, 23, 0, 86, 18, 18);
|
||||
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
String mom = String.format(Locale.US, "%,d", rec.momentum);
|
||||
fontRenderer.drawString(mom, -fontRenderer.getStringWidth(mom) / 2 + 30, 42, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return RefStrings.MODID + ":textures/gui/nei/gui_nei_hadron.png";
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.recipes.loader.SerializableRecipe;
|
||||
@ -183,45 +182,10 @@ public class HadronRecipes extends SerializableRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readRecipe(JsonElement recipe) {
|
||||
JsonObject obj = (JsonObject) recipe;
|
||||
int momentum = obj.get("momentum").getAsInt();
|
||||
boolean lineMode = obj.get("lineMode").getAsBoolean();
|
||||
ItemStack[] in = this.readItemStackArray(obj.get("inputs").getAsJsonArray());
|
||||
ItemStack[] out = this.readItemStackArray(obj.get("outputs").getAsJsonArray());
|
||||
|
||||
this.recipes.add(new HadronRecipe(
|
||||
in[0],
|
||||
in[1],
|
||||
momentum,
|
||||
out[0],
|
||||
out[1],
|
||||
lineMode
|
||||
));
|
||||
}
|
||||
public void readRecipe(JsonElement recipe) { }
|
||||
|
||||
@Override
|
||||
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
|
||||
HadronRecipe rec = (HadronRecipe) recipe;
|
||||
|
||||
writer.name("momentum").value(rec.momentum);
|
||||
writer.name("lineMode").value(rec.analysisOnly);
|
||||
|
||||
writer.name("inputs").beginArray();
|
||||
this.writeItemStack(rec.in1.toStack(), writer);
|
||||
this.writeItemStack(rec.in2.toStack(), writer);
|
||||
writer.endArray();
|
||||
|
||||
writer.name("outputs").beginArray();
|
||||
this.writeItemStack(rec.out1, writer);
|
||||
this.writeItemStack(rec.out2, writer);
|
||||
writer.endArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return "Rules: Both in- and output stacks cannot be null. Stacksizes are set to 1 for all stacks.";
|
||||
}
|
||||
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException { }
|
||||
|
||||
@Override
|
||||
public void deleteRecipes() {
|
||||
|
||||
@ -36,7 +36,6 @@ public class NEIRegistry {
|
||||
handlers.add(new CrystallizerRecipeHandler());
|
||||
handlers.add(new BookRecipeHandler());
|
||||
handlers.add(new FusionRecipeHandler());
|
||||
handlers.add(new HadronRecipeHandler());
|
||||
handlers.add(new SILEXRecipeHandler());
|
||||
handlers.add(new FuelPoolHandler());
|
||||
handlers.add(new CrucibleSmeltingHandler());
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
Loading…
x
Reference in New Issue
Block a user