diff --git a/src/main/java/resonantinduction/core/Settings.java b/src/main/java/resonantinduction/core/Settings.java index ee24b79b..a2308ce6 100644 --- a/src/main/java/resonantinduction/core/Settings.java +++ b/src/main/java/resonantinduction/core/Settings.java @@ -32,7 +32,6 @@ public class Settings public static int FURNACE_WATTAGE = 50000; public static boolean SOUND_FXS = true; public static boolean SHINY_SILVER = true; - public static boolean REPLACE_FURNACE = true; public static int MAX_CONTRACTOR_DISTANCE = 200; /** @@ -47,7 +46,6 @@ public class Settings SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS); SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER); MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE); - REPLACE_FURNACE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Replace vanilla furnace", REPLACE_FURNACE).getBoolean(REPLACE_FURNACE); LEVITATOR_ACCELERATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", Settings.LEVITATOR_ACCELERATION).getDouble(Settings.LEVITATOR_ACCELERATION); LEVITATOR_MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", Settings.LEVITATOR_MAX_REACH).getInt(Settings.LEVITATOR_MAX_REACH); diff --git a/src/main/java/resonantinduction/electrical/Electrical.java b/src/main/java/resonantinduction/electrical/Electrical.java index d4e95bfb..2b9709fc 100644 --- a/src/main/java/resonantinduction/electrical/Electrical.java +++ b/src/main/java/resonantinduction/electrical/Electrical.java @@ -27,6 +27,8 @@ import resonantinduction.electrical.generator.BlockGenerator; import resonantinduction.electrical.generator.TileGenerator; import resonantinduction.electrical.generator.solar.BlockSolarPanel; import resonantinduction.electrical.generator.solar.TileSolarPanel; +import resonantinduction.electrical.generator.thermopile.BlockThermopile; +import resonantinduction.electrical.generator.thermopile.TileThermopile; import resonantinduction.electrical.levitator.BlockLevitator; import resonantinduction.electrical.levitator.TileLevitator; import resonantinduction.electrical.multimeter.ItemMultimeter; @@ -88,9 +90,9 @@ public class Electrical // Generators public static Block blockSolarPanel; public static Block blockGenerator; + public static Block blockThermopile; // Machines - public static Block blockAdvancedFurnace; // Transport public static Block blockEMLevitator; @@ -113,20 +115,14 @@ public class Electrical // Transport blockEMLevitator = contentRegistry.createTile(BlockLevitator.class, TileLevitator.class); - //blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class); + // blockArmbot = contentRegistry.createTile(BlockArmbot.class, TileArmbot.class); blockEncoder = contentRegistry.createTile(BlockEncoder.class, TileEncoder.class); itemDisk = contentRegistry.createItem(ItemDisk.class); // Generator blockSolarPanel = contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class); blockGenerator = contentRegistry.createTile(BlockGenerator.class, TileGenerator.class); - - if (Settings.REPLACE_FURNACE) - { - blockAdvancedFurnace = BlockAdvancedFurnace.createNew(false); - GameRegistry.registerBlock(blockAdvancedFurnace, "ri_" + blockAdvancedFurnace.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileAdvancedFurnace.class, "ri_" + blockAdvancedFurnace.getUnlocalizedName()); - } + blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class); Settings.save(); @@ -192,8 +188,9 @@ public class Electrical } proxy.postInit(); + /** Inject new furnace tile class */ - replaceTileEntity(TileEntityFurnace.class, TileAdvancedFurnace.class); + //replaceTileEntity(TileEntityFurnace.class, TileAdvancedFurnace.class); } public static void replaceTileEntity(Class findTile, Class replaceTile) diff --git a/src/main/java/resonantinduction/electrical/generator/thermopile/BlockThermopile.java b/src/main/java/resonantinduction/electrical/generator/thermopile/BlockThermopile.java new file mode 100644 index 00000000..4998656c --- /dev/null +++ b/src/main/java/resonantinduction/electrical/generator/thermopile/BlockThermopile.java @@ -0,0 +1,24 @@ +package resonantinduction.electrical.generator.thermopile; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import resonantinduction.core.Reference; +import resonantinduction.core.prefab.block.BlockRI; +import resonantinduction.core.render.RIBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockThermopile extends BlockRI +{ + public BlockThermopile() + { + super("thermopile"); + setTextureName(Reference.PREFIX + "material_metal_top"); + } + + @Override + public TileEntity createNewTileEntity(World world) + { + return new TileThermopile(); + } +} diff --git a/src/main/java/resonantinduction/electrical/generator/thermopile/TileThermopile.java b/src/main/java/resonantinduction/electrical/generator/thermopile/TileThermopile.java new file mode 100644 index 00000000..fe7264ff --- /dev/null +++ b/src/main/java/resonantinduction/electrical/generator/thermopile/TileThermopile.java @@ -0,0 +1,102 @@ +package resonantinduction.electrical.generator.thermopile; + +import net.minecraft.block.Block; +import net.minecraftforge.common.ForgeDirection; +import universalelectricity.api.energy.EnergyStorageHandler; +import universalelectricity.api.vector.Vector3; +import calclavia.lib.prefab.tile.TileElectrical; + +public class TileThermopile extends TileElectrical +{ + private final int MAX_USE_TICKS = 120 * 20; + + /** + * The amount of ticks the thermopile will use the temperature differences before turning all + * adjacent sides to thermal equilibrium. + */ + private int usingTicks = 0; + + public TileThermopile() + { + this.energy = new EnergyStorageHandler(300); + this.ioMap = 728; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + + if (!this.worldObj.isRemote) + { + int heatSources = 0; + int coolingSources = 0; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + Vector3 checkPos = new Vector3(this).translate(dir); + + int blockID = checkPos.getBlockID(worldObj); + + if (blockID == Block.waterStill.blockID) + { + coolingSources++; + } + else if (blockID == Block.ice.blockID) + { + coolingSources += 2; + } + else if (blockID == Block.fire.blockID) + { + heatSources++; + } + else if (blockID == Block.lavaStill.blockID) + { + heatSources += 2; + } + } + + // Max difference would be "3" + int multiplier = (3 - Math.abs(heatSources - coolingSources)); + + if (multiplier > 0 && coolingSources > 0 && heatSources > 0) + { + energy.receiveEnergy(15 * multiplier, true); + + if (++usingTicks >= MAX_USE_TICKS) + { + /** + * Create Thermal Equilibrium + */ + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + Vector3 checkPos = new Vector3(this).translate(dir); + int blockID = checkPos.getBlockID(worldObj); + + if (blockID == Block.waterStill.blockID) + { + checkPos.setBlock(worldObj, 0); + } + else if (blockID == Block.ice.blockID) + { + checkPos.setBlock(worldObj, Block.waterStill.blockID); + } + else if (blockID == Block.fire.blockID) + { + checkPos.setBlock(worldObj, 0); + } + else if (blockID == Block.lavaStill.blockID) + { + checkPos.setBlock(worldObj, Block.stone.blockID); + } + } + + usingTicks = 0; + } + } + + produce(); + } + } + +} diff --git a/src/main/resources/assets/resonantinduction/languages/en_US.properties b/src/main/resources/assets/resonantinduction/languages/en_US.properties index 41add651..3ac41c4a 100644 --- a/src/main/resources/assets/resonantinduction/languages/en_US.properties +++ b/src/main/resources/assets/resonantinduction/languages/en_US.properties @@ -104,6 +104,8 @@ tile.resonantinduction\:encoder.name=Encoder ## Generators tile.resonantinduction\:solarPanel.name=Solar Panel tile.resonantinduction\:generator.name=Electric Generator +tile.resonantinduction\:thermopile.name=Thermopile +tile.resonantinduction\:thermopile.tooltip=Generates a voltage proportional to local temperature difference. #Transport item.resonantinduction\:disk.name=Program Disk