From bf08756a8220f2d5c3f6c10a0b1e4ad723eb5305 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Thu, 13 Mar 2014 20:04:19 +0800 Subject: [PATCH] Added insulation item for wires --- .../java/resonantinduction/archaic/Archaic.java | 3 ++- .../electrical/Electrical.java | 13 ++++++++++--- .../electrical/wire/PartAdvancedWire.java | 12 ++++++++---- .../electrical/wire/PartConductor.java | 1 + .../core/prefab/part/PartColorableMaterial.java | 11 +++++++---- .../core/resource/ItemResourcePart.java | 17 +++++++++++++++++ .../core/resource/ResourceGenerator.java | 10 +++++++++- .../resource/fluid/ItemOreResourceBucket.java | 4 +++- .../assets/resonantinduction/languages | 2 +- 9 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 src/main/java/resonantinduction/core/resource/ItemResourcePart.java diff --git a/archaic/src/main/java/resonantinduction/archaic/Archaic.java b/archaic/src/main/java/resonantinduction/archaic/Archaic.java index 19b46cb84..bba67ada6 100644 --- a/archaic/src/main/java/resonantinduction/archaic/Archaic.java +++ b/archaic/src/main/java/resonantinduction/archaic/Archaic.java @@ -115,7 +115,6 @@ public class Archaic proxy.preInit(); Settings.CONFIGURATION.save(); - TabRI.ITEMSTACK = new ItemStack(blockEngineeringTable); PacketAnnotation.register(TileFirebox.class); PacketAnnotation.register(TileFilter.class); @@ -132,6 +131,8 @@ public class Archaic @EventHandler public void postInit(FMLPostInitializationEvent evt) { + TabRI.ITEMSTACK = new ItemStack(blockEngineeringTable); + // Add recipes GameRegistry.addRecipe(new ShapedOreRecipe(blockEngineeringTable, "P", "C", 'P', Block.pressurePlatePlanks, 'C', Block.workbench)); GameRegistry.addRecipe(new ShapedOreRecipe(blockFilter, "B", "P", "B", 'B', Block.fenceIron, 'P', Item.paper)); diff --git a/electrical/src/main/java/resonantinduction/electrical/Electrical.java b/electrical/src/main/java/resonantinduction/electrical/Electrical.java index c87199644..ba1cc748d 100644 --- a/electrical/src/main/java/resonantinduction/electrical/Electrical.java +++ b/electrical/src/main/java/resonantinduction/electrical/Electrical.java @@ -11,6 +11,7 @@ import resonantinduction.core.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.Settings; import resonantinduction.core.TabRI; +import resonantinduction.core.resource.ItemResourcePart; import resonantinduction.electrical.battery.BlockBattery; import resonantinduction.electrical.battery.ItemBlockBattery; import resonantinduction.electrical.battery.TileBattery; @@ -89,6 +90,7 @@ public class Electrical public static Item itemLevitator; public static Block blockArmbot; public static Item itemDisk; + public static Item itemInsulation; // Quantum public static Block blockQuantumGate; @@ -110,9 +112,11 @@ public class Electrical // Transport itemLevitator = contentRegistry.createItem(ItemLevitator.class); - // blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class); - // blockEncoder = contentRegistry.createTile(BlockEncoder.class, TileEncoder.class); + // blockArmbot = contentRegistry.createTile(BlockArmbot.lass, TileEncoder.clclass, + // TileArmbot.class); + // blockEncoder = contentRegistry.createTile(BlockEncoder.cass); itemDisk = contentRegistry.createItem(ItemDisk.class); + itemInsulation = contentRegistry.createItem("insulation", ItemResourcePart.class); // Generator blockSolarPanel = (BlockSolarPanel) contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class); @@ -122,7 +126,7 @@ public class Electrical // Quantum itemQuantumGlyph = contentRegistry.createItem(ItemQuantumGlyph.class); Settings.CONFIGURATION.save(); - + OreDictionary.registerOre("wire", itemWire); OreDictionary.registerOre("motor", blockMotor); OreDictionary.registerOre("battery", ItemBlockBattery.setTier(new ItemStack(blockBattery, 1, 0), (byte) 0)); @@ -173,6 +177,9 @@ public class Electrical GameRegistry.addRecipe(new ShapedOreRecipe(tierThreeBattery, "RRR", "RIR", "RRR", 'R', tierTwoBattery, 'I', Block.blockDiamond)); /** Wires **/ + GameRegistry.addRecipe(new ShapelessOreRecipe(itemInsulation, Item.slimeBall, new ItemStack(Block.cloth, 2, OreDictionary.WILDCARD_VALUE))); + GameRegistry.addRecipe(new ShapelessOreRecipe(itemInsulation, "slimeball", new ItemStack(Block.cloth, 2, OreDictionary.WILDCARD_VALUE))); + GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.COPPER.getWire(3), "MMM", 'M', "ingotCopper")); GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.TIN.getWire(3), "MMM", 'M', "ingotTin")); GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.IRON.getWire(3), "MMM", 'M', Item.ingotIron)); diff --git a/electrical/src/main/java/resonantinduction/electrical/wire/PartAdvancedWire.java b/electrical/src/main/java/resonantinduction/electrical/wire/PartAdvancedWire.java index a80ab2a16..3d87cada7 100644 --- a/electrical/src/main/java/resonantinduction/electrical/wire/PartAdvancedWire.java +++ b/electrical/src/main/java/resonantinduction/electrical/wire/PartAdvancedWire.java @@ -8,12 +8,14 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockColored; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemShears; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.ForgeDirection; import resonantinduction.core.MultipartUtility; +import resonantinduction.electrical.Electrical; import universalelectricity.api.CompatibilityModule; import universalelectricity.api.energy.IConductor; import calclavia.lib.CustomDamageSource; @@ -26,6 +28,7 @@ import codechicken.multipart.TMultiPart; * @author Calclavia * */ +@Deprecated public abstract class PartAdvancedWire extends PartConductor { public static final int DEFAULT_COLOR = 15; @@ -33,6 +36,7 @@ public abstract class PartAdvancedWire extends PartConductor public EnumWireMaterial material = EnumWireMaterial.COPPER; public boolean isInsulated = false; + protected Item insulationType = Electrical.itemInsulation; /** * INTERNAL USE. @@ -216,13 +220,13 @@ public abstract class PartAdvancedWire extends PartConductor this.setColor(dyeColor); return true; } - else if (itemStack.itemID == Block.cloth.blockID) + else if (itemStack.getItem() == insulationType) { if (this.isInsulated()) { if (!world().isRemote && player.capabilities.isCreativeMode) { - tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)))); + tile().dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color)))); } this.setInsulated(false); @@ -243,7 +247,7 @@ public abstract class PartAdvancedWire extends PartConductor { if (!world().isRemote && !player.capabilities.isCreativeMode) { - tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)))); + tile().dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color)))); } this.setInsulated(false); @@ -268,7 +272,7 @@ public abstract class PartAdvancedWire extends PartConductor if (this.isInsulated) { - drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color))); + drops.add(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color))); } return drops; diff --git a/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java b/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java index 35f741d5b..3f2beb2d0 100644 --- a/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java +++ b/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java @@ -19,6 +19,7 @@ import universalelectricity.api.vector.VectorHelper; import codechicken.multipart.TMultiPart; @UniversalClass +@Deprecated public abstract class PartConductor extends PartAdvanced implements IConductor { private IEnergyNetwork network; diff --git a/src/main/java/resonantinduction/core/prefab/part/PartColorableMaterial.java b/src/main/java/resonantinduction/core/prefab/part/PartColorableMaterial.java index 230a7d5f2..88d008424 100644 --- a/src/main/java/resonantinduction/core/prefab/part/PartColorableMaterial.java +++ b/src/main/java/resonantinduction/core/prefab/part/PartColorableMaterial.java @@ -7,11 +7,13 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockColored; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemShears; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import resonantinduction.core.MultipartUtility; +import resonantinduction.electrical.Electrical; import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataOutput; @@ -27,6 +29,7 @@ public abstract class PartColorableMaterial extends PartAdvanced public M material; public boolean isInsulated = false; public boolean requiresInsulation = true; + protected Item insulationType = Electrical.itemInsulation; /** * Material Methods @@ -136,13 +139,13 @@ public abstract class PartColorableMaterial extends PartAdvanced } else if (requiresInsulation) { - if (itemStack.itemID == Block.cloth.blockID) + if (itemStack.getItem() == insulationType) { if (this.isInsulated()) { if (!world().isRemote && player.capabilities.isCreativeMode) { - tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)))); + tile().dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color)))); } this.setInsulated(false); @@ -163,7 +166,7 @@ public abstract class PartColorableMaterial extends PartAdvanced { if (!world().isRemote && !player.capabilities.isCreativeMode) { - tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)))); + tile().dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color)))); } this.setInsulated(false); @@ -183,7 +186,7 @@ public abstract class PartColorableMaterial extends PartAdvanced if (requiresInsulation && isInsulated) { - drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color))); + drops.add(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color))); } return drops; diff --git a/src/main/java/resonantinduction/core/resource/ItemResourcePart.java b/src/main/java/resonantinduction/core/resource/ItemResourcePart.java new file mode 100644 index 000000000..0c45976e0 --- /dev/null +++ b/src/main/java/resonantinduction/core/resource/ItemResourcePart.java @@ -0,0 +1,17 @@ +package resonantinduction.core.resource; + +import net.minecraft.item.Item; + +/** + * A general item class that does nothing but act as recipe resource item. + * + * @author Calclavia + * + */ +public class ItemResourcePart extends Item +{ + public ItemResourcePart(int par1) + { + super(par1); + } +} diff --git a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java index d19a97206..012e683a5 100644 --- a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java +++ b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java @@ -73,6 +73,7 @@ public class ResourceGenerator implements IVirtualObject static { OreDetectionBlackList.addIngot("ingotRefinedIron"); + OreDetectionBlackList.addIngot("uranium"); SaveManager.registerClass("resourceGenerator", ResourceGenerator.class); SaveManager.register(INSTANCE); } @@ -136,7 +137,14 @@ public class ResourceGenerator implements IVirtualObject if (list.size() > 0) { ItemStack type = list.get(0); - localizedName = type.getDisplayName().replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", ""); + localizedName = type.getDisplayName(); + + if (LanguageUtility.getLocal(localizedName) != null && LanguageUtility.getLocal(localizedName) != "") + { + localizedName = LanguageUtility.getLocal(localizedName); + } + + localizedName.replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", ""); } /** Generate molten fluids */ diff --git a/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java b/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java index 20ed13482..edc7b8731 100644 --- a/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java +++ b/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java @@ -14,6 +14,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.Event; import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; import resonantinduction.core.Reference; import resonantinduction.core.TabRI; import resonantinduction.core.resource.ItemOreResource; @@ -47,6 +48,7 @@ public class ItemOreResourceBucket extends Item public String getItemDisplayName(ItemStack is) { String material = getMaterialFromStack(is); + if (material != null) { String fluidID = isMolten ? ResourceGenerator.materialNameToMolten(material) : ResourceGenerator.materialNameToMixture(material); @@ -56,7 +58,7 @@ public class ItemOreResourceBucket extends Item String fluidName = FluidRegistry.getFluid(fluidID).getLocalizedName(); return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", fluidName).replace(" ", " "); } - + return material; } diff --git a/src/main/resources/assets/resonantinduction/languages b/src/main/resources/assets/resonantinduction/languages index 1614b4d84..ba68b2470 160000 --- a/src/main/resources/assets/resonantinduction/languages +++ b/src/main/resources/assets/resonantinduction/languages @@ -1 +1 @@ -Subproject commit 1614b4d84a023bfac276ced7e0654035e8ecd0b3 +Subproject commit ba68b2470ce81b56a7f9dd201586ccaba32b9764