mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
configurable chemplant recipes
This commit is contained in:
parent
9328cbbd20
commit
a77291528c
@ -1,9 +1,14 @@
|
||||
package com.hbm.inventory.recipes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.GeneralConfig;
|
||||
import com.hbm.inventory.FluidStack;
|
||||
@ -12,13 +17,15 @@ import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.recipes.loader.SerializableRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ChemplantRecipes {
|
||||
public class ChemplantRecipes extends SerializableRecipe {
|
||||
|
||||
/**
|
||||
* Nice order: The order in which the ChemRecipe are added to the recipes list
|
||||
@ -28,7 +35,8 @@ public class ChemplantRecipes {
|
||||
public static HashMap<Integer, ChemRecipe> indexMapping = new HashMap();
|
||||
public static List<ChemRecipe> recipes = new ArrayList();
|
||||
|
||||
public static void register() {
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
|
||||
registerFuelProcessing();
|
||||
//6-30, formerly oil cracking, coal liquefaction and solidifciation
|
||||
@ -366,7 +374,6 @@ public class ChemplantRecipes {
|
||||
.inputItems(new OreDictStack(DIAMOND.dust(), 1))
|
||||
.inputFluids(new FluidStack(Fluids.XPJUICE, 500))
|
||||
.outputFluids(new FluidStack(Fluids.ENDERJUICE, 100)));
|
||||
|
||||
}
|
||||
|
||||
public static void registerFuelProcessing() {
|
||||
@ -473,4 +480,64 @@ public class ChemplantRecipes {
|
||||
return this.duration;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "hbmChemplant.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRecipeObject() {
|
||||
return this.recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readRecipe(JsonElement recipe) {
|
||||
JsonObject obj = (JsonObject) recipe;
|
||||
int id = obj.get("id").getAsInt();
|
||||
String name = obj.get("name").getAsString();
|
||||
int duration = obj.get("duration").getAsInt();
|
||||
|
||||
recipes.add(new ChemRecipe(id, name, duration)
|
||||
.inputFluids( this.readFluidArray( (JsonArray) obj.get("fluidInput")))
|
||||
.inputItems( this.readAStackArray( (JsonArray) obj.get("itemInput")))
|
||||
.outputFluids( this.readFluidArray( (JsonArray) obj.get("fluidOutput")))
|
||||
.outputItems( this.readItemStackArray( (JsonArray) obj.get("itemOutput"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
|
||||
try {
|
||||
ChemRecipe chem = (ChemRecipe) recipe;
|
||||
writer.name("id").value(chem.id);
|
||||
writer.name("name").value(chem.name);
|
||||
writer.name("duration").value(chem.duration);
|
||||
//Fluid IN
|
||||
writer.name("fluidInput").beginArray();
|
||||
for(FluidStack input : chem.inputFluids) { if(input != null) this.writeFluidStack(input, writer); }
|
||||
writer.endArray();
|
||||
//Item IN
|
||||
writer.name("itemInput").beginArray();
|
||||
for(AStack input : chem.inputs) { if(input != null) this.writeAStack(input, writer); }
|
||||
writer.endArray();
|
||||
//Fluid OUT
|
||||
writer.name("fluidOutput").beginArray();
|
||||
for(FluidStack output : chem.outputFluids) { if(output != null) this.writeFluidStack(output, writer); }
|
||||
writer.endArray();
|
||||
//Item OUT
|
||||
MainRegistry.logger.info("Trying to write output items");
|
||||
writer.name("itemOutput").beginArray();
|
||||
for(ItemStack output : chem.outputs) { if(output != null) this.writeItemStack(output, writer); }
|
||||
writer.endArray();
|
||||
} catch(Exception ex) {
|
||||
MainRegistry.logger.error(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecipes() {
|
||||
this.indexMapping.clear();
|
||||
this.recipes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,13 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.inventory.FluidStack;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.recipes.ChemplantRecipes;
|
||||
import com.hbm.inventory.recipes.FuelPoolRecipes;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -34,6 +38,7 @@ public abstract class SerializableRecipe {
|
||||
*/
|
||||
|
||||
public static void registerAllHandlers() {
|
||||
recipeHandlers.add(new ChemplantRecipes());
|
||||
recipeHandlers.add(new FuelPoolRecipes());
|
||||
}
|
||||
|
||||
@ -98,10 +103,9 @@ public abstract class SerializableRecipe {
|
||||
|
||||
/* Try to pry all recipes from our list */
|
||||
if(recipeObject instanceof Collection) {
|
||||
recipeList.addAll((Collection) recipeList);
|
||||
}
|
||||
|
||||
if(recipeObject instanceof HashMap) {
|
||||
recipeList.addAll((Collection) recipeObject);
|
||||
|
||||
} else if(recipeObject instanceof HashMap) {
|
||||
recipeList.addAll(((HashMap) recipeObject).entrySet());
|
||||
}
|
||||
|
||||
@ -154,10 +158,20 @@ public abstract class SerializableRecipe {
|
||||
return new OreDictStack(dict, stacksize);
|
||||
}
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading recipe array " + array.toString());
|
||||
MainRegistry.logger.error("Error reading stack array " + array.toString());
|
||||
return new ComparableStack(ModItems.nothing);
|
||||
}
|
||||
|
||||
protected static AStack[] readAStackArray(JsonArray array) {
|
||||
try {
|
||||
AStack[] items = new AStack[array.size()];
|
||||
for(int i = 0; i < items.length; i++) { items[i] = readAStack((JsonArray) array.get(i)); }
|
||||
return items;
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading stack array " + array.toString());
|
||||
return new AStack[0];
|
||||
}
|
||||
|
||||
protected static void writeAStack(AStack astack, JsonWriter writer) throws IOException {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
@ -185,10 +199,20 @@ public abstract class SerializableRecipe {
|
||||
int meta = array.size() > 2 ? array.get(2).getAsInt() : 0;
|
||||
return new ItemStack(item, stacksize, meta);
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading recipe array " + array.toString());
|
||||
MainRegistry.logger.error("Error reading stack array " + array.toString());
|
||||
return new ItemStack(ModItems.nothing);
|
||||
}
|
||||
|
||||
protected static ItemStack[] readItemStackArray(JsonArray array) {
|
||||
try {
|
||||
ItemStack[] items = new ItemStack[array.size()];
|
||||
for(int i = 0; i < items.length; i++) { items[i] = readItemStack((JsonArray) array.get(i)); }
|
||||
return items;
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading stack array " + array.toString());
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
protected static void writeItemStack(ItemStack stack, JsonWriter writer) throws IOException {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
@ -198,4 +222,33 @@ public abstract class SerializableRecipe {
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
|
||||
protected static FluidStack readFluidStack(JsonArray array) {
|
||||
try {
|
||||
FluidType type = Fluids.fromName(array.get(0).getAsString());
|
||||
int fill = array.get(1).getAsInt();
|
||||
return new FluidStack(type, fill);
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading fluid array " + array.toString());
|
||||
return new FluidStack(Fluids.NONE, 0);
|
||||
}
|
||||
|
||||
protected static FluidStack[] readFluidArray(JsonArray array) {
|
||||
try {
|
||||
FluidStack[] fluids = new FluidStack[array.size()];
|
||||
for(int i = 0; i < fluids.length; i++) { fluids[i] = readFluidStack((JsonArray) array.get(i)); }
|
||||
return fluids;
|
||||
} catch(Exception ex) { }
|
||||
MainRegistry.logger.error("Error reading fluid array " + array.toString());
|
||||
return new FluidStack[0];
|
||||
}
|
||||
|
||||
protected static void writeFluidStack(FluidStack stack, JsonWriter writer) throws IOException {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
writer.value(stack.type.getName()); //fluid type
|
||||
writer.value(stack.fill); //amount in mB
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3466,32 +3466,6 @@ public class ModItems {
|
||||
protection_charm = new ItemModCharm().setUnlocalizedName("protection_charm").setTextureName(RefStrings.MODID + ":protection_charm");
|
||||
meteor_charm = new ItemModCharm().setUnlocalizedName("meteor_charm").setTextureName(RefStrings.MODID + ":meteor_charm");
|
||||
|
||||
can_empty = new Item().setUnlocalizedName("can_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_empty");
|
||||
can_smart = new ItemEnergy().setUnlocalizedName("can_smart").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_smart");
|
||||
can_creature = new ItemEnergy().setUnlocalizedName("can_creature").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_creature");
|
||||
can_redbomb = new ItemEnergy().setUnlocalizedName("can_redbomb").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_redbomb");
|
||||
can_mrsugar = new ItemEnergy().setUnlocalizedName("can_mrsugar").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_mrsugar");
|
||||
can_overcharge = new ItemEnergy().setUnlocalizedName("can_overcharge").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_overcharge");
|
||||
can_luna = new ItemEnergy().setUnlocalizedName("can_luna").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_luna");
|
||||
can_bepis = new ItemEnergy().setUnlocalizedName("can_bepis").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_bepis");
|
||||
can_breen = new ItemEnergy().setUnlocalizedName("can_breen").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_breen");
|
||||
can_mug = new ItemEnergy().setUnlocalizedName("can_mug").setContainerItem(ModItems.can_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_mug");
|
||||
bottle_empty = new Item().setUnlocalizedName("bottle_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_empty");
|
||||
bottle_nuka = new ItemEnergy().setUnlocalizedName("bottle_nuka").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_nuka");
|
||||
bottle_cherry = new ItemEnergy().setUnlocalizedName("bottle_cherry").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_cherry");
|
||||
bottle_quantum = new ItemEnergy().setUnlocalizedName("bottle_quantum").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_quantum");
|
||||
bottle_sparkle = new ItemEnergy().setUnlocalizedName("bottle_sparkle").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_sparkle");
|
||||
bottle_rad = new ItemEnergy().setUnlocalizedName("bottle_rad").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_rad");
|
||||
bottle2_empty = new Item().setUnlocalizedName("bottle2_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_empty");
|
||||
bottle2_korl = new ItemEnergy().setUnlocalizedName("bottle2_korl").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_korl");
|
||||
bottle2_fritz = new ItemEnergy().setUnlocalizedName("bottle2_fritz").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_fritz");
|
||||
bottle2_korl_special = new ItemEnergy().setUnlocalizedName("bottle2_korl_special").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_korl");
|
||||
bottle2_fritz_special = new ItemEnergy().setUnlocalizedName("bottle2_fritz_special").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_fritz");
|
||||
bottle2_sunset = new ItemEnergy().setUnlocalizedName("bottle2_sunset").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_sunset");
|
||||
chocolate_milk = new ItemEnergy().setUnlocalizedName("chocolate_milk").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":chocolate_milk");
|
||||
coffee = new ItemEnergy().setUnlocalizedName("coffee").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coffee");
|
||||
coffee_radium = new ItemEnergy().setUnlocalizedName("coffee_radium").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coffee_radium");
|
||||
chocolate = new ItemPill(0).setUnlocalizedName("chocolate").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":chocolate");
|
||||
cap_nuka = new Item().setUnlocalizedName("cap_nuka").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_nuka");
|
||||
cap_quantum = new Item().setUnlocalizedName("cap_quantum").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_quantum");
|
||||
cap_sparkle = new Item().setUnlocalizedName("cap_sparkle").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_sparkle");
|
||||
@ -3501,6 +3475,33 @@ public class ModItems {
|
||||
cap_sunset = new Item().setUnlocalizedName("cap_sunset").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_sunset");
|
||||
cap_star = new Item().setUnlocalizedName("cap_star").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_star");
|
||||
ring_pull = new Item().setUnlocalizedName("ring_pull").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":ring_pull");
|
||||
|
||||
can_empty = new Item().setUnlocalizedName("can_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":can_empty");
|
||||
can_smart = new ItemEnergy().makeCan().setUnlocalizedName("can_smart").setTextureName(RefStrings.MODID + ":can_smart");
|
||||
can_creature = new ItemEnergy().makeCan().setUnlocalizedName("can_creature").setTextureName(RefStrings.MODID + ":can_creature");
|
||||
can_redbomb = new ItemEnergy().makeCan().setUnlocalizedName("can_redbomb").setTextureName(RefStrings.MODID + ":can_redbomb");
|
||||
can_mrsugar = new ItemEnergy().makeCan().setUnlocalizedName("can_mrsugar").setTextureName(RefStrings.MODID + ":can_mrsugar");
|
||||
can_overcharge = new ItemEnergy().makeCan().setUnlocalizedName("can_overcharge").setTextureName(RefStrings.MODID + ":can_overcharge");
|
||||
can_luna = new ItemEnergy().makeCan().setUnlocalizedName("can_luna").setTextureName(RefStrings.MODID + ":can_luna");
|
||||
can_bepis = new ItemEnergy().makeCan().setUnlocalizedName("can_bepis").setTextureName(RefStrings.MODID + ":can_bepis");
|
||||
can_breen = new ItemEnergy().makeCan().setUnlocalizedName("can_breen").setTextureName(RefStrings.MODID + ":can_breen");
|
||||
can_mug = new ItemEnergy().makeCan().setUnlocalizedName("can_mug").setTextureName(RefStrings.MODID + ":can_mug");
|
||||
bottle_empty = new Item().setUnlocalizedName("bottle_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_empty");
|
||||
bottle_nuka = new ItemEnergy().makeBottle(bottle_empty, cap_nuka).setUnlocalizedName("bottle_nuka").setTextureName(RefStrings.MODID + ":bottle_nuka");
|
||||
bottle_cherry = new ItemEnergy().makeBottle(bottle_empty, cap_nuka).setUnlocalizedName("bottle_cherry").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_cherry");
|
||||
bottle_quantum = new ItemEnergy().makeBottle(bottle_empty, cap_quantum).setUnlocalizedName("bottle_quantum").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_quantum");
|
||||
bottle_sparkle = new ItemEnergy().makeBottle(bottle_empty, cap_sparkle).setUnlocalizedName("bottle_sparkle").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_sparkle");
|
||||
bottle_rad = new ItemEnergy().makeBottle(bottle_empty, cap_rad).setUnlocalizedName("bottle_rad").setContainerItem(ModItems.bottle_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle_rad");
|
||||
bottle2_empty = new Item().setUnlocalizedName("bottle2_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_empty");
|
||||
bottle2_korl = new ItemEnergy().makeBottle(bottle2_empty, cap_korl).setUnlocalizedName("bottle2_korl").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_korl");
|
||||
bottle2_fritz = new ItemEnergy().makeBottle(bottle2_empty, cap_fritz).setUnlocalizedName("bottle2_fritz").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_fritz");
|
||||
bottle2_korl_special = new ItemEnergy().makeBottle(bottle2_empty, cap_korl).setUnlocalizedName("bottle2_korl_special").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_korl");
|
||||
bottle2_fritz_special = new ItemEnergy().makeBottle(bottle2_empty, cap_fritz).setUnlocalizedName("bottle2_fritz_special").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_fritz");
|
||||
bottle2_sunset = new ItemEnergy().makeBottle(bottle2_empty, cap_sunset).setUnlocalizedName("bottle2_sunset").setContainerItem(ModItems.bottle2_empty).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bottle2_sunset");
|
||||
chocolate_milk = new ItemEnergy().setUnlocalizedName("chocolate_milk").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":chocolate_milk");
|
||||
coffee = new ItemEnergy().setUnlocalizedName("coffee").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coffee");
|
||||
coffee_radium = new ItemEnergy().setUnlocalizedName("coffee_radium").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":coffee_radium");
|
||||
chocolate = new ItemPill(0).setUnlocalizedName("chocolate").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":chocolate");
|
||||
|
||||
canned_beef = new ItemLemon(8, 5, false).setUnlocalizedName("canned_beef").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":canned_beef");
|
||||
canned_tuna = new ItemLemon(4, 5, false).setUnlocalizedName("canned_tuna").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":canned_tuna");
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import com.hbm.config.VersatileConfig;
|
||||
import com.hbm.explosion.ExplosionLarge;
|
||||
import com.hbm.extprop.HbmLivingProps;
|
||||
import com.hbm.interfaces.Spaghetti;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.util.ContaminationUtil;
|
||||
@ -23,6 +24,27 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
public class ItemEnergy extends Item {
|
||||
|
||||
private Item container = null;
|
||||
private Item cap = null;
|
||||
private boolean requiresOpener = false;
|
||||
|
||||
public ItemEnergy makeCan() {
|
||||
this.container = ModItems.can_empty;
|
||||
this.cap = ModItems.ring_pull;
|
||||
this.requiresOpener = false;
|
||||
this.setContainerItem(this.container);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemEnergy makeBottle(Item bottle, Item cap) {
|
||||
this.container = bottle;
|
||||
this.cap = cap;
|
||||
this.requiresOpener = true;
|
||||
this.setContainerItem(this.container);
|
||||
this.setCreativeTab(MainRegistry.consumableTab);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
|
||||
@ -78,6 +100,10 @@ public class ItemEnergy extends Item {
|
||||
if(this == ModItems.can_breen) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 30 * 20, 0));
|
||||
}
|
||||
if(this == ModItems.can_mug) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 3 * 60 * 20, 2));
|
||||
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60 * 20, 2));
|
||||
}
|
||||
if(this == ModItems.chocolate_milk) {
|
||||
ExplosionLarge.explode(world, player.posX, player.posY, player.posZ, 50, true, false, false);
|
||||
}
|
||||
@ -160,82 +186,20 @@ public class ItemEnergy extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
if(!player.capabilities.isCreativeMode && this != ModItems.chocolate_milk) {
|
||||
if(this == ModItems.can_creature || this == ModItems.can_mrsugar || this == ModItems.can_overcharge || this == ModItems.can_redbomb || this == ModItems.can_smart || this == ModItems.can_luna || this == ModItems.can_bepis || this == ModItems.can_breen) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.ring_pull));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.can_empty);
|
||||
}
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.can_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle_cherry || this == ModItems.bottle_nuka) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_nuka));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle_empty);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle_quantum) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_quantum));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle_empty);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle2_korl || this == ModItems.bottle2_korl_special) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_korl));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle2_empty);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle2_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle2_fritz || this == ModItems.bottle2_fritz_special) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_fritz));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle2_empty);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle2_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle_sparkle) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_sparkle));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle_empty);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle_rad) {
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_rad));
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle_empty);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle_empty));
|
||||
}
|
||||
|
||||
if(this == ModItems.bottle2_sunset) {
|
||||
|
||||
if(world.rand.nextInt(10) == 0)
|
||||
if(this.cap != null) {
|
||||
|
||||
if(this == ModItems.bottle2_sunset && world.rand.nextInt(20) == 0)
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_star));
|
||||
else
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.cap_sunset));
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(this.cap));
|
||||
}
|
||||
if(this.container != null) {
|
||||
if(stack.stackSize <= 0) {
|
||||
return new ItemStack(ModItems.bottle2_empty);
|
||||
return new ItemStack(this.container);
|
||||
}
|
||||
|
||||
player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle2_empty));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(this.container));
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,17 +216,14 @@ public class ItemEnergy extends Item {
|
||||
return EnumAction.drink;
|
||||
}
|
||||
|
||||
@Spaghetti("cover yourself in oil")
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
|
||||
|
||||
if(VersatileConfig.hasPotionSickness(p_77659_3_))
|
||||
return p_77659_1_;
|
||||
|
||||
if(!(this == ModItems.can_creature || this == ModItems.can_mrsugar || this == ModItems.can_overcharge ||
|
||||
this == ModItems.can_redbomb || this == ModItems.can_smart || this == ModItems.chocolate_milk ||
|
||||
this == ModItems.can_luna || this == ModItems.can_bepis || this == ModItems.can_breen ||
|
||||
this == ModItems.coffee || this == ModItems.coffee_radium))
|
||||
if(!p_77659_3_.inventory.hasItem(ModItems.bottle_opener))
|
||||
|
||||
if(!this.requiresOpener || p_77659_3_.inventory.hasItem(ModItems.bottle_opener))
|
||||
return p_77659_1_;
|
||||
|
||||
p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
|
||||
|
||||
@ -960,7 +960,7 @@ public class MainRegistry {
|
||||
TileEntityNukeFurnace.registerFuels();
|
||||
BreederRecipes.registerRecipes();
|
||||
AssemblerRecipes.loadRecipes();
|
||||
ChemplantRecipes.register();
|
||||
//ChemplantRecipes.register(); //moved to SerializableRecipe
|
||||
CyclotronRecipes.register();
|
||||
HadronRecipes.register();
|
||||
MagicRecipes.register();
|
||||
@ -975,6 +975,7 @@ public class MainRegistry {
|
||||
LiquefactionRecipes.register();
|
||||
SolidificationRecipes.register();
|
||||
|
||||
//the good stuff
|
||||
SerializableRecipe.registerAllHandlers();
|
||||
SerializableRecipe.initialize();
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@ import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implements IFluidAcceptor, IFluidSource, IEnergyUser, IFluidStandardTransceiver {
|
||||
@ -139,17 +138,17 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen
|
||||
|
||||
@Override
|
||||
public void setFluidFill(int i, FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
if(type == tanks[0].getTankType())
|
||||
tanks[0].setFill(i);
|
||||
else if(type.name().equals(tanks[1].getTankType().name()))
|
||||
else if(type == tanks[1].getTankType())
|
||||
tanks[1].setFill(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidFill(FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
if(type == tanks[0].getTankType())
|
||||
return tanks[0].getFill();
|
||||
else if(type.name().equals(tanks[1].getTankType().name()))
|
||||
else if(type == tanks[1].getTankType())
|
||||
return tanks[1].getFill();
|
||||
|
||||
return 0;
|
||||
@ -157,7 +156,7 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen
|
||||
|
||||
@Override
|
||||
public int getMaxFluidFill(FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
if(type == tanks[0].getTankType())
|
||||
return tanks[0].getMaxFill();
|
||||
|
||||
return 0;
|
||||
|
||||
@ -4,7 +4,8 @@ import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -18,9 +19,9 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
|
||||
public static final long maxPower = 1000000;
|
||||
|
||||
public TileEntityDeuteriumTower() {
|
||||
tanks = new FluidTank[2];
|
||||
super();
|
||||
tanks[0] = new FluidTank(Fluids.WATER, 50000, 0);
|
||||
tanks[1] = new FluidTank(Fluids.HEAVYWATER, 5000, 0);
|
||||
tanks[1] = new FluidTank(Fluids.HEAVYWATER, 5000, 1);
|
||||
}
|
||||
|
||||
public void fillFluidInit(FluidType type) {
|
||||
@ -75,26 +76,26 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
|
||||
|
||||
protected void updateConnections() {
|
||||
|
||||
for(BlockPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), ForgeDirection.UNKNOWN);
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
public void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
|
||||
|
||||
for(BlockPos pos : getConPos()) {
|
||||
this.trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), ForgeDirection.UNKNOWN);
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
public void sendFluidToAll(FluidType type, TileEntity te) {
|
||||
|
||||
for(BlockPos pos : getConPos()) {
|
||||
this.sendFluid(type, worldObj, pos.getX(), pos.getY(), pos.getZ(), ForgeDirection.UNKNOWN);
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.sendFluid(type, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
private BlockPos[] getConPos() {
|
||||
private DirPos[] getConPos() {
|
||||
|
||||
int offsetX = 0;
|
||||
int offsetZ = 0;
|
||||
@ -109,15 +110,15 @@ public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
|
||||
offsetZ = dir.offsetZ;
|
||||
}
|
||||
|
||||
return new BlockPos[] {
|
||||
new BlockPos(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 1),
|
||||
new BlockPos(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 0),
|
||||
new BlockPos(this.xCoord + offsetX * 1, this.yCoord, this.zCoord - offsetZ * 2),
|
||||
new BlockPos(this.xCoord + offsetX * 0, this.yCoord, this.zCoord - offsetZ * 2),
|
||||
new BlockPos(this.xCoord + offsetX * 1, this.yCoord, this.zCoord + offsetZ * 1),
|
||||
new BlockPos(this.xCoord + offsetX * 0, this.yCoord, this.zCoord + offsetZ * 1),
|
||||
new BlockPos(this.xCoord - offsetX * 1, this.yCoord, this.zCoord + offsetZ * 0),
|
||||
new BlockPos(this.xCoord - offsetX * 1, this.yCoord, this.zCoord - offsetZ * 1)
|
||||
return new DirPos[] {
|
||||
new DirPos(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 1, Library.POS_X),
|
||||
new DirPos(this.xCoord + offsetX * 2, this.yCoord, this.zCoord - offsetZ * 0, Library.POS_X),
|
||||
new DirPos(this.xCoord + offsetX * 1, this.yCoord, this.zCoord - offsetZ * 2, Library.NEG_Z),
|
||||
new DirPos(this.xCoord + offsetX * 0, this.yCoord, this.zCoord - offsetZ * 2, Library.NEG_Z),
|
||||
new DirPos(this.xCoord + offsetX * 1, this.yCoord, this.zCoord + offsetZ * 1, Library.POS_Z),
|
||||
new DirPos(this.xCoord + offsetX * 0, this.yCoord, this.zCoord + offsetZ * 1, Library.POS_Z),
|
||||
new DirPos(this.xCoord - offsetX * 1, this.yCoord, this.zCoord + offsetZ * 0, Library.NEG_Z),
|
||||
new DirPos(this.xCoord - offsetX * 1, this.yCoord, this.zCoord - offsetZ * 1, Library.NEG_Z)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user