some slight code refactoring, fun with enums

This commit is contained in:
Boblet 2021-12-14 16:12:03 +01:00
parent bb513f3b9f
commit 9e97a5caf5
11 changed files with 289 additions and 69 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
@ -154,43 +155,42 @@ public class BlockBobble extends BlockContainer {
public static enum BobbleType { public static enum BobbleType {
NONE("null", "null", null, null, false), NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK),
//vault tec bobbleheads STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS),
STRENGTH("Strength", "Strength", null, "It's essential to give your arguments impact.", false), PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH),
PERCEPTION("Perception", "Perception", null, "Only through observation will you perceive weakness.", false), ENDURANCE( "Endurance", "Endurance", null, "Always be ready to take one for the team.", false, ScrapType.BRIDGE_SOUTH),
ENDURANCE("Endurance", "Endurance", null, "Always be ready to take one for the team.", false), CHARISMA( "Charisma", "Charisma", null, "Nothing says pizzaz like a winning smile.", false, ScrapType.BRIDGE_IO),
CHARISMA("Charisma", "Charisma", null, "Nothing says pizzaz like a winning smile.", false), INTELLIGENCE( "Intelligence", "Intelligence", null, "It takes the smartest individuals to realize$there's always more to learn.", false, ScrapType.BRIDGE_BUS),
INTELLIGENCE("Intelligence", "Intelligence", null, "It takes the smartest individuals to realize$there's always more to learn.", false), AGILITY( "Agility", "Agility", null, "Never be afraid to dodge the sensitive issues.", false, ScrapType.BRIDGE_CHIPSET),
AGILITY("Agility", "Agility", null, "Never be afraid to dodge the sensitive issues.", false), LUCK( "Luck", "Luck", null, "There's only one way to give 110%.", false, ScrapType.BRIDGE_CMOS),
LUCK("Luck", "Luck", null, "There's only one way to give 110%.", false), BOB( "Robert \"The Bobcat\" Katzinsky", "HbMinecraft", "Hbm's Nuclear Tech Mod", "I know where you live, " + System.getProperty("user.name"), false, ScrapType.CPU_SOCKET),
//contributor bobbles FRIZZLE( "Frooz", "Frooz", "Weapon models", "BLOOD IS FUEL", true, ScrapType.CPU_CLOCK),
BOB("Robert \"The Bobcat\" Katzinsky", "HbMinecraft", "Hbm's Nuclear Tech Mod", "I know where you live, " + System.getProperty("user.name"), false), PU238( "Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false, ScrapType.CPU_REGISTER),
FRIZZLE("Frooz", "Frooz", "Weapon models", "BLOOD IS FUEL", true), VT( "VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true, ScrapType.CPU_EXT),
PU238("Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false), DOC( "The Doctor", "Doctor17PH", "Russian localization, lunar miner", "Perhaps the moon rocks were too expensive", true, ScrapType.CPU_CACHE),
VT("VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true), BLUEHAT( "The Blue Hat", "The Blue Hat", "Textures", "there's a listening device in this bobblehead$don't touch it thanks", true, ScrapType.MEM_16K_A),
DOC("The Doctor", "Doctor17PH", "Russian localization, lunar miner", "Perhaps the moon rocks were too expensive", true), PHEO( "Pheo", "Pheonix", "Deuterium machines, tantalium textures, Reliant Rocket", "RUN TO THE BEDROOM, ON THE SUITCASE ON THE LEFT,$YOU'LL FIND MY FAVORITE AXE", true, ScrapType.MEM_16K_B),
BLUEHAT("The Blue Hat", "The Blue Hat", "Textures", "there's a listening device in this bobblehead$don't touch it thanks", true), ADAM29( "Adam29", "Adam29", "Ethanol, liquid petroleum gas", "You know, nukes are really quite beatiful.$It's like watching a star be born for a split second.", true, ScrapType.MEM_16K_C),
PHEO("Pheo", "Pheonix", "Deuterium machines, tantalium textures, Reliant Rocket", "RUN TO THE BEDROOM, ON THE SUITCASE ON THE LEFT,$YOU'LL FIND MY FAVORITE AXE", true), UFFR( "UFFR", "UFFR", "All sorts of things from his PR", "fried shrimp", false, ScrapType.MEM_SOCKET),
ADAM29("Adam29", "Adam29", "Ethanol, liquid petroleum gas", "You know, nukes are really quite beatiful.$It's like watching a star be born for a split second.", true), VAER( "vaer", "vaer", "ZIRNOX", "taken de family out to the weekend cigarette festival", true, ScrapType.MEM_16K_D),
UFFR("UFFR", "UFFR", "All sorts of things from his PR", "fried shrimp", false), NOS( "Dr Nostalgia", "Dr Nostalgia", "SSG and Vortex models", "Take a picture, I'ma pose, paparazzi$I've been drinking, moving like a zombie", true, ScrapType.BOARD_TRANSISTOR),
VAER("vaer", "vaer", "ZIRNOX", "taken de family out to the weekend cigarette festival", true), DRILLGON( "Drillgon200", "Drillgon200", "1.12 Port", null, false, ScrapType.CPU_LOGIC),
NOS("Dr Nostalgia", "Dr Nostalgia", "SSG and Vortex models", "Take a picture, I'ma pose, paparazzi$I've been drinking, moving like a zombie", true), CIRNO( "Cirno", "Cirno", "being a dumb ice fairy", "No brain. Head empty.", true, ScrapType.BOARD_BLANK);
DRILLGON("Drillgon200", "Drillgon200", "1.12 Port", null, false),
//testing garbage. why is she so dumb?
CIRNO("Cirno", "Cirno", "being a dumb ice fairy", "No brain. Head empty.", true);
public String name; //the title of the tooltip public String name; //the title of the tooltip
public String label; //the name engraved in the socket public String label; //the name engraved in the socket
public String contribution; //what contributions this person has made, if applicable public String contribution; //what contributions this person has made, if applicable
public String inscription; //the flavor text public String inscription; //the flavor text
public boolean skinLayers; public boolean skinLayers;
public ScrapType scrap;
private BobbleType(String name, String label, String contribution, String inscription, boolean layers) { private BobbleType(String name, String label, String contribution, String inscription, boolean layers, ScrapType scrap) {
this.name = name; this.name = name;
this.label = label; this.label = label;
this.contribution = contribution; this.contribution = contribution;
this.inscription = inscription; this.inscription = inscription;
this.skinLayers = layers; this.skinLayers = layers;
this.scrap = scrap;
} }
} }
} }

View File

@ -10,6 +10,7 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.handler.imc.IMCCrystallizer; import com.hbm.handler.imc.IMCCrystallizer;
import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -79,6 +80,10 @@ public class CrystallizerRecipes {
recipes.put(new ComparableStack(ModItems.powder_impure_osmiridium), new ItemStack(ModItems.crystal_osmiridium)); recipes.put(new ComparableStack(ModItems.powder_impure_osmiridium), new ItemStack(ModItems.crystal_osmiridium));
for(int i = 0; i < ScrapType.values().length; i++) {
recipes.put(new ComparableStack(ModItems.scrap_plastic, 1, i), new ItemStack(ModItems.circuit_star_piece, 1, i));
}
List<ItemStack> quartz = OreDictionary.getOres("crystalCertusQuartz"); List<ItemStack> quartz = OreDictionary.getOres("crystalCertusQuartz");
if(quartz != null && !quartz.isEmpty()) { if(quartz != null && !quartz.isEmpty()) {

View File

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockBobble.BobbleType;
import com.hbm.interfaces.Untested; import com.hbm.interfaces.Untested;
import com.hbm.inventory.RecipesCommon; import com.hbm.inventory.RecipesCommon;
import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.RecipesCommon.ComparableStack;
@ -302,6 +303,14 @@ public class ShredderRecipes {
ShredderRecipes.setRecipe(new ItemStack(Blocks.wool, 1, i), new ItemStack(Items.string, 4)); ShredderRecipes.setRecipe(new ItemStack(Blocks.wool, 1, i), new ItemStack(Items.string, 4));
} }
/*
* Shredding bobbleheads
*/
for(int i = 0; i < BobbleType.values().length; i++) {
BobbleType type = BobbleType.values()[i];
ShredderRecipes.setRecipe(new ItemStack(ModBlocks.bobblehead, 1, i), new ItemStack(ModItems.scrap_plastic, 1, type.scrap.ordinal()));
}
/* /*
* GC COMPAT * GC COMPAT
*/ */

View File

@ -0,0 +1,88 @@
package com.hbm.items;
import java.util.List;
import com.hbm.lib.RefStrings;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
public class ItemEnumMulti extends Item {
//hell yes, now we're thinking with enums!
private Class<? extends Enum> theEnum;
private boolean multiTexture;
public ItemEnumMulti(Class<? extends Enum> theEnum, boolean multiTexture) {
this.setHasSubtypes(true);
this.theEnum = theEnum;
this.multiTexture = multiTexture;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < theEnum.getEnumConstants().length; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public Item setUnlocalizedName(String unlocalizedName) {
super.setUnlocalizedName(unlocalizedName);
this.setTextureName(RefStrings.MODID + ":"+ unlocalizedName);
return this;
}
private IIcon[] icons;
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg) {
if(multiTexture) {
Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length];
for(int i = 0; i < icons.length; i++) {
Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getIconString() + "." + num.name().toLowerCase());
}
} else {
this.itemIcon = reg.registerIcon(this.getIconString());
}
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
if(multiTexture) {
Enum[] enums = theEnum.getEnumConstants();
Enum num = EnumUtil.grabEnumSafely(theEnum, meta);
return this.icons[num.ordinal()];
} else {
return this.itemIcon;
}
}
/*
* Returns null when the wrong enum is passed. Only really used for recipes anyway so it's good.
*/
public ItemStack stackFromEnum(int count, Enum num) {
if(num.getClass() != this.theEnum)
return null;
return new ItemStack(this, count, num.ordinal());
}
public ItemStack stackFromEnum(Enum num) {
return stackFromEnum(1, num);
}
}

View File

@ -15,6 +15,7 @@ import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.items.machine.ItemRBMKRod.EnumBurnFunc; import com.hbm.items.machine.ItemRBMKRod.EnumBurnFunc;
import com.hbm.items.machine.ItemStamp.StampType; import com.hbm.items.machine.ItemStamp.StampType;
import com.hbm.items.special.*; import com.hbm.items.special.*;
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.items.tool.*; import com.hbm.items.tool.*;
import com.hbm.items.tool.ItemToolAbility.EnumToolType; import com.hbm.items.tool.ItemToolAbility.EnumToolType;
import com.hbm.items.weapon.*; import com.hbm.items.weapon.*;
@ -506,6 +507,9 @@ public class ModItems {
public static Item circuit_bismuth; public static Item circuit_bismuth;
public static Item circuit_tantalium_raw; public static Item circuit_tantalium_raw;
public static Item circuit_tantalium; public static Item circuit_tantalium;
public static ItemEnumMulti circuit_star_piece;
public static ItemEnumMulti circuit_star_component;
public static Item circuit_star;
public static Item mechanism_revolver_1; public static Item mechanism_revolver_1;
public static Item mechanism_revolver_2; public static Item mechanism_revolver_2;
@ -1137,6 +1141,7 @@ public class ModItems {
public static ItemRBMKPellet rbmk_pellet_zfb_am_mix; public static ItemRBMKPellet rbmk_pellet_zfb_am_mix;
public static ItemRBMKPellet rbmk_pellet_drx; public static ItemRBMKPellet rbmk_pellet_drx;
public static Item scrap_plastic;
public static Item scrap; public static Item scrap;
public static Item scrap_nuclear; public static Item scrap_nuclear;
public static Item trinitite; public static Item trinitite;
@ -3058,6 +3063,9 @@ public class ModItems {
circuit_bismuth = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("circuit_bismuth").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_bismuth"); circuit_bismuth = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("circuit_bismuth").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_bismuth");
circuit_tantalium_raw = new Item().setUnlocalizedName("circuit_tantalium_raw").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_tantalium_raw"); circuit_tantalium_raw = new Item().setUnlocalizedName("circuit_tantalium_raw").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_tantalium_raw");
circuit_tantalium = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("circuit_tantalium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_tantalium"); circuit_tantalium = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("circuit_tantalium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_tantalium");
circuit_star_piece = (ItemEnumMulti) new ItemEnumMulti(ScrapType.class, true).setUnlocalizedName("circuit_star_piece").setCreativeTab(null);
circuit_star_component = (ItemEnumMulti) new ItemCircuitStarComponent().setUnlocalizedName("circuit_star_component").setCreativeTab(null);
circuit_star = new ItemCustomLore().setRarity(EnumRarity.uncommon).setUnlocalizedName("circuit_star").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_star");
circuit_targeting_tier1 = new Item().setUnlocalizedName("circuit_targeting_tier1").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_targeting_tier1"); circuit_targeting_tier1 = new Item().setUnlocalizedName("circuit_targeting_tier1").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_targeting_tier1");
circuit_targeting_tier2 = new Item().setUnlocalizedName("circuit_targeting_tier2").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_targeting_tier2"); circuit_targeting_tier2 = new Item().setUnlocalizedName("circuit_targeting_tier2").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_targeting_tier2");
circuit_targeting_tier3 = new Item().setUnlocalizedName("circuit_targeting_tier3").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_targeting_tier3"); circuit_targeting_tier3 = new Item().setUnlocalizedName("circuit_targeting_tier3").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_targeting_tier3");
@ -3862,6 +3870,7 @@ public class ModItems {
nuclear_waste_tiny = new ItemNuclearWaste().setUnlocalizedName("nuclear_waste_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_tiny"); nuclear_waste_tiny = new ItemNuclearWaste().setUnlocalizedName("nuclear_waste_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_tiny");
nuclear_waste_vitrified = new ItemNuclearWaste().setUnlocalizedName("nuclear_waste_vitrified").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_vitrified"); nuclear_waste_vitrified = new ItemNuclearWaste().setUnlocalizedName("nuclear_waste_vitrified").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_vitrified");
nuclear_waste_vitrified_tiny = new ItemNuclearWaste().setUnlocalizedName("nuclear_waste_vitrified_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_vitrified_tiny"); nuclear_waste_vitrified_tiny = new ItemNuclearWaste().setUnlocalizedName("nuclear_waste_vitrified_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_vitrified_tiny");
scrap_plastic = new ItemPlasticScrap().setUnlocalizedName("scrap_plastic").setTextureName(RefStrings.MODID + ":scrap_plastic");
scrap = new Item().setUnlocalizedName("scrap").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":scrap"); scrap = new Item().setUnlocalizedName("scrap").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":scrap");
scrap_nuclear = new Item().setUnlocalizedName("scrap_nuclear").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":scrap_nuclear"); scrap_nuclear = new Item().setUnlocalizedName("scrap_nuclear").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":scrap_nuclear");
containment_box = new ItemLeadBox().setUnlocalizedName("containment_box").setCreativeTab(null).setTextureName(RefStrings.MODID + ":containment_box"); containment_box = new ItemLeadBox().setUnlocalizedName("containment_box").setCreativeTab(null).setTextureName(RefStrings.MODID + ":containment_box");
@ -6121,6 +6130,9 @@ public class ModItems {
GameRegistry.registerItem(circuit_bismuth, circuit_bismuth.getUnlocalizedName()); GameRegistry.registerItem(circuit_bismuth, circuit_bismuth.getUnlocalizedName());
GameRegistry.registerItem(circuit_tantalium_raw, circuit_tantalium_raw.getUnlocalizedName()); GameRegistry.registerItem(circuit_tantalium_raw, circuit_tantalium_raw.getUnlocalizedName());
GameRegistry.registerItem(circuit_tantalium, circuit_tantalium.getUnlocalizedName()); GameRegistry.registerItem(circuit_tantalium, circuit_tantalium.getUnlocalizedName());
GameRegistry.registerItem(circuit_star_piece, circuit_star_piece.getUnlocalizedName());
GameRegistry.registerItem(circuit_star_component, circuit_star_component.getUnlocalizedName());
GameRegistry.registerItem(circuit_star, circuit_star.getUnlocalizedName());
//Military Circuits //Military Circuits
GameRegistry.registerItem(circuit_targeting_tier1, circuit_targeting_tier1.getUnlocalizedName()); GameRegistry.registerItem(circuit_targeting_tier1, circuit_targeting_tier1.getUnlocalizedName());
@ -6805,6 +6817,7 @@ public class ModItems {
GameRegistry.registerItem(debris_element, debris_element.getUnlocalizedName()); GameRegistry.registerItem(debris_element, debris_element.getUnlocalizedName());
GameRegistry.registerItem(undefined, undefined.getUnlocalizedName()); GameRegistry.registerItem(undefined, undefined.getUnlocalizedName());
GameRegistry.registerItem(scrap_plastic, scrap_plastic.getUnlocalizedName());
GameRegistry.registerItem(scrap, scrap.getUnlocalizedName()); GameRegistry.registerItem(scrap, scrap.getUnlocalizedName());
GameRegistry.registerItem(scrap_nuclear, scrap_nuclear.getUnlocalizedName()); GameRegistry.registerItem(scrap_nuclear, scrap_nuclear.getUnlocalizedName());
GameRegistry.registerItem(trinitite, trinitite.getUnlocalizedName()); GameRegistry.registerItem(trinitite, trinitite.getUnlocalizedName());

View File

@ -0,0 +1,16 @@
package com.hbm.items.special;
import com.hbm.items.ItemEnumMulti;
public class ItemCircuitStarComponent extends ItemEnumMulti {
public ItemCircuitStarComponent() {
super(CircuitComponentType.class, true);
}
public static enum CircuitComponentType {
CHIPSET,
CPU,
RAM
}
}

View File

@ -12,77 +12,76 @@ import net.minecraft.world.World;
public class ItemHot extends Item { public class ItemHot extends Item {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon hotIcon; public IIcon hotIcon;
protected static int heat; protected static int heat;
public ItemHot(int heat) { public ItemHot(int heat) {
this.heat = heat; this.heat = heat;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg) { public void registerIcons(IIconRegister reg) {
super.registerIcons(reg); super.registerIcons(reg);
this.hotIcon = reg.registerIcon(this.getIconString() + "_hot"); this.hotIcon = reg.registerIcon(this.getIconString() + "_hot");
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta) {
return this.itemIcon; return this.itemIcon;
} }
public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean bool) { public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean bool) {
if(!world.isRemote && stack.hasTagCompound()) { if(!world.isRemote && stack.hasTagCompound()) {
int h = stack.stackTagCompound.getInteger("heat"); int h = stack.stackTagCompound.getInteger("heat");
if(h > 0) { if(h > 0) {
stack.stackTagCompound.setInteger("heat", h - 1); stack.stackTagCompound.setInteger("heat", h - 1);
} else { } else {
stack.stackTagCompound = null; stack.stackTagCompound = null;
} }
} }
} }
public static ItemStack heatUp(ItemStack stack) { public static ItemStack heatUp(ItemStack stack) {
if(!(stack.getItem() instanceof ItemHot)) if(!(stack.getItem() instanceof ItemHot))
return stack; return stack;
if(!stack.hasTagCompound()) if(!stack.hasTagCompound())
stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("heat", getMaxHeat(stack)); stack.stackTagCompound.setInteger("heat", getMaxHeat(stack));
return stack; return stack;
} }
public static ItemStack heatUp(ItemStack stack, double d) { public static ItemStack heatUp(ItemStack stack, double d) {
if(!(stack.getItem() instanceof ItemHot)) if(!(stack.getItem() instanceof ItemHot))
return stack; return stack;
if(!stack.hasTagCompound()) if(!stack.hasTagCompound())
stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("heat", (int)(d * getMaxHeat(stack))); stack.stackTagCompound.setInteger("heat", (int) (d * getMaxHeat(stack)));
return stack; return stack;
} }
public static double getHeat(ItemStack stack) { public static double getHeat(ItemStack stack) {
if(!(stack.getItem() instanceof ItemHot)) if(!(stack.getItem() instanceof ItemHot))
return 0; return 0;
if(!stack.hasTagCompound()) if(!stack.hasTagCompound())
return 0; return 0;
int h = stack.stackTagCompound.getInteger("heat"); int h = stack.stackTagCompound.getInteger("heat");
return (double)h / (double)heat; return (double) h / (double) heat;
} }
public static int getMaxHeat(ItemStack stack) { public static int getMaxHeat(ItemStack stack) {
return heat; return heat;
} }

View File

@ -0,0 +1,43 @@
package com.hbm.items.special;
import com.hbm.items.ItemEnumMulti;
import net.minecraft.item.Item;
public class ItemPlasticScrap extends ItemEnumMulti {
public ItemPlasticScrap() {
super(ScrapType.class, false);
this.setCreativeTab(null);
}
public static enum ScrapType {
//GENERAL BOARD
BOARD_BLANK,
BOARD_TRANSISTOR,
//CHIPSET
BRIDGE_NORTH,
BRIDGE_SOUTH,
BRIDGE_IO,
BRIDGE_BUS,
BRIDGE_CHIPSET,
BRIDGE_CMOS,
BRIDGE_BIOS,
//CPU
CPU_REGISTER,
CPU_CLOCK,
CPU_LOGIC,
CPU_CACHE,
CPU_EXT,
CPU_SOCKET,
//RAM
MEM_SOCKET,
MEM_16K_A,
MEM_16K_B,
MEM_16K_C,
MEM_16K_D
}
}

View File

@ -13,6 +13,8 @@ import com.hbm.inventory.OreDictManager;
import static com.hbm.inventory.OreDictManager.*; import static com.hbm.inventory.OreDictManager.*;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemBattery; import com.hbm.items.machine.ItemBattery;
import com.hbm.items.special.ItemCircuitStarComponent.CircuitComponentType;
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.util.EnchantmentUtil; import com.hbm.util.EnchantmentUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -881,6 +883,41 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.rbmk_boiler, 1), new Object[] { "CPC", "CRC", "CPC", 'C', ModItems.board_copper, 'P', ModItems.pipes_steel, 'R', ModBlocks.rbmk_blank }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_boiler, 1), new Object[] { "CPC", "CRC", "CPC", 'C', ModItems.board_copper, 'P', ModItems.pipes_steel, 'R', ModBlocks.rbmk_blank });
addRecipeAuto(new ItemStack(ModBlocks.rbmk_cooler, 1), new Object[] { "IGI", "GCG", "IGI", 'C', ModBlocks.rbmk_blank, 'I', ModItems.plate_polymer, 'G', ModBlocks.steel_grate }); addRecipeAuto(new ItemStack(ModBlocks.rbmk_cooler, 1), new Object[] { "IGI", "GCG", "IGI", 'C', ModBlocks.rbmk_blank, 'I', ModItems.plate_polymer, 'G', ModBlocks.steel_grate });
} }
addShapelessAuto(ModItems.circuit_star_component.stackFromEnum(CircuitComponentType.CHIPSET), new Object[] {
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_BIOS),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_BUS),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_CHIPSET),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_CMOS),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_IO),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_NORTH),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BRIDGE_SOUTH)
});
addShapelessAuto(ModItems.circuit_star_component.stackFromEnum(CircuitComponentType.CPU), new Object[] {
ModItems.circuit_star_piece.stackFromEnum(ScrapType.CPU_CACHE),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.CPU_CLOCK),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.CPU_EXT),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.CPU_LOGIC),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.CPU_REGISTER),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.CPU_SOCKET)
});
addShapelessAuto(ModItems.circuit_star_component.stackFromEnum(CircuitComponentType.RAM), new Object[] {
ModItems.circuit_star_piece.stackFromEnum(ScrapType.MEM_SOCKET),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.MEM_16K_A),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.MEM_16K_B),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.MEM_16K_C),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.MEM_16K_D)
});
addShapelessAuto(new ItemStack(ModItems.circuit_star), new Object[] {
ModItems.circuit_star_component.stackFromEnum(CircuitComponentType.CHIPSET),
ModItems.circuit_star_component.stackFromEnum(CircuitComponentType.CPU),
ModItems.circuit_star_component.stackFromEnum(CircuitComponentType.RAM),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BOARD_TRANSISTOR),
ModItems.circuit_star_piece.stackFromEnum(ScrapType.BOARD_BLANK)
});
} }
public static void crumple() { public static void crumple() {

View File

@ -0,0 +1,10 @@
package com.hbm.util;
public class EnumUtil {
public static <T extends Enum> T grabEnumSafely(Class<? extends Enum> theEnum, int index) {
Enum[] values = theEnum.getEnumConstants();
index = Math.abs(index % values.length);
return (T)values[index];
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B