From b7a0854cae0d1f939c939ede3025b6e7dd3c9ed2 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Wed, 19 Sep 2018 18:24:35 +0300 Subject: [PATCH] MOre work on solar panels. Blockstate json isn't ready yet. --- src/main/java/techreborn/TechReborn.java | 4 +- .../generator/solarpanel/BlockSolarPanel.java | 10 ++- .../generator/solarpanel/EnumPanelType.java | 87 ------------------ .../techreborn/config/ConfigTechReborn.java | 28 +++--- src/main/java/techreborn/init/ModBlocks.java | 26 ------ .../java/techreborn/init/ModTileEntities.java | 1 - src/main/java/techreborn/init/TRContent.java | 42 ++++++++- .../init/recipes/CraftingTableRecipes.java | 20 ++--- .../generator/TileCreativeSolarPanel.java | 90 ------------------- .../tiles/generator/TileSolarPanel.java | 86 ++++++++---------- .../chests/abandoned_mineshaft.json | 2 +- .../loot_tables/chests/desert_pyramid.json | 2 +- .../loot_tables/chests/end_city_treasure.json | 4 +- .../loot_tables/chests/igloo_chest.json | 2 +- .../loot_tables/chests/jungle_temple.json | 2 +- .../loot_tables/chests/nether_bridge.json | 4 +- .../loot_tables/chests/simple_dungeon.json | 2 +- .../chests/stronghold_corridor.json | 4 +- .../chests/stronghold_crossing.json | 4 +- .../chests/stronghold_library.json | 4 +- .../chests/village_blacksmith.json | 2 +- .../loot_tables/chests/woodland_mansion.json | 4 +- 22 files changed, 125 insertions(+), 305 deletions(-) delete mode 100644 src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java delete mode 100644 src/main/java/techreborn/tiles/generator/TileCreativeSolarPanel.java diff --git a/src/main/java/techreborn/TechReborn.java b/src/main/java/techreborn/TechReborn.java index 8d46049a5..a72346e9e 100644 --- a/src/main/java/techreborn/TechReborn.java +++ b/src/main/java/techreborn/TechReborn.java @@ -201,7 +201,7 @@ public class TechReborn { localName.append(StringUtils.toFirstCapital(word)); } } - System.out.println("item.techreborn." + item.getRegistryName().getPath() + ".name=" + localName); +// System.out.println("item.techreborn." + item.getRegistryName().getPath() + ".name=" + localName); } } for (Block item : ForgeRegistries.BLOCKS.getValues()) { @@ -216,7 +216,7 @@ public class TechReborn { localName.append(StringUtils.toFirstCapital(word)); } } - System.out.println("tile.techreborn." + item.getRegistryName().getPath() + ".name=" + localName); +// System.out.println("tile.techreborn." + item.getRegistryName().getPath() + ".name=" + localName); } } } diff --git a/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java b/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java index 3c72c2579..48dd7dfd2 100644 --- a/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java +++ b/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java @@ -31,23 +31,27 @@ import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import reborncore.common.blocks.BlockMachineBase; import techreborn.TechReborn; +import techreborn.init.TRContent.SolarPanels; +import techreborn.tiles.generator.TileSolarPanel; import techreborn.utils.TechRebornCreativeTab; /** * Created by modmuss50 on 25/02/2016. */ public class BlockSolarPanel extends BlockMachineBase { + + public final SolarPanels panelType; - public BlockSolarPanel() { + public BlockSolarPanel(SolarPanels panel) { super(); + this.panelType = panel; setCreativeTab(TechRebornCreativeTab.instance); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/generators")); } @Override public TileEntity createNewTileEntity(final World world, final int meta) { - // TODO: FIx me - return null; + return new TileSolarPanel(); } @Override diff --git a/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java b/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java deleted file mode 100644 index 0ed4e9a23..000000000 --- a/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.blocks.generator.solarpanel; - -import net.minecraft.util.IStringSerializable; -import reborncore.api.power.EnumPowerTier; -import techreborn.config.ConfigTechReborn; - -public enum EnumPanelType implements IStringSerializable { - - Basic("basic", EnumPowerTier.MICRO), - Hybrid("hybrid", EnumPowerTier.LOW), - Advanced("advanced", EnumPowerTier.MEDIUM), - Ultimate("ultimate", EnumPowerTier.HIGH), - Quantum("quantum", EnumPowerTier.EXTREME), - CREATIVE("creative", EnumPowerTier.EXTREME); - - private String friendlyName; - // Generation of EU during Day - public int generationRateD = 1; - // Generation of EU during Night - public int generationRateN = 0; - // Internal EU storage of solar panel - public int internalCapacity = 1000; - public EnumPowerTier powerTier; - - EnumPanelType(String friendlyName, EnumPowerTier tier) { - this.friendlyName = friendlyName; - this.powerTier = tier; - // TODO: Fix me - switch (friendlyName) { - case "basic": - this.generationRateD = ConfigTechReborn.basicGenerationRateD; - this.generationRateN = ConfigTechReborn.basicGenerationRateN; - break; - - case "hybrid": - this.generationRateD = ConfigTechReborn.hybridGenerationRateD; - this.generationRateN = ConfigTechReborn.hybridGenerationRateN; - break; - - case "advanced": - this.generationRateD = ConfigTechReborn.advancedGenerationRateD; - this.generationRateN = ConfigTechReborn.advancedGenerationRateN; - break; - - case "ultimate": - this.generationRateD = ConfigTechReborn.ultimateGenerationRateD; - this.generationRateN = ConfigTechReborn.ultimateGenerationRateN; - break; - - case "quantum": - this.generationRateD = ConfigTechReborn.quantumGenerationRateD; - this.generationRateN = ConfigTechReborn.quantumGenerationRateN; - break; - } - - this.internalCapacity = (this.generationRateD * 1000); - } - - @Override - public String getName() { - return friendlyName; - } -} \ No newline at end of file diff --git a/src/main/java/techreborn/config/ConfigTechReborn.java b/src/main/java/techreborn/config/ConfigTechReborn.java index 1e30b15fc..e697f380e 100644 --- a/src/main/java/techreborn/config/ConfigTechReborn.java +++ b/src/main/java/techreborn/config/ConfigTechReborn.java @@ -93,34 +93,34 @@ public class ConfigTechReborn { @ConfigRegistry(config = "items", category = "power", key = "clockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (FE)") public static int CloackingDeviceUsage = 10; - @ConfigRegistry(config = "generators", category = "solarPanelBasic", key = "basicDayRate", comment = "Generation rate during day for Basic Solar Panel (Value in EU)") + @ConfigRegistry(config = "generators", category = "solarPanelBasic", key = "basicDayRate", comment = "Generation rate during day for Basic Solar Panel (Value in FE)") public static int basicGenerationRateD = 1; - @ConfigRegistry(config = "generators", category = "solarPanelBasic", key = "basicNightRate", comment = "Generation rate during night for Basic Solar Panel (Value in EU)") + @ConfigRegistry(config = "generators", category = "solarPanelBasic", key = "basicNightRate", comment = "Generation rate during night for Basic Solar Panel (Value in FE)") public static int basicGenerationRateN = 0; - @ConfigRegistry(config = "generators", category = "solarPanelHybrid", key = "hybridDayRate", comment = "Generation rate during day for Hybrid Solar Panel (Value in EU)") - public static int hybridGenerationRateD = 16; + @ConfigRegistry(config = "generators", category = "solarPanelAdvanced", key = "advancedDayRate", comment = "Generation rate during day for Advanced Solar Panel (Value in FE)") + public static int advancedGenerationRateD = 16; - @ConfigRegistry(config = "generators", category = "solarPanelHybrid", key = "hybridNightRate", comment = "Generation rate during night for Hybrid Solar Panel (Value in EU)") - public static int hybridGenerationRateN = 0; + @ConfigRegistry(config = "generators", category = "solarPanelAdvanced", key = "advancedNightRate", comment = "Generation rate during night for Advanced Solar Panel (Value in FE)") + public static int advancedGenerationRateN = 0; - @ConfigRegistry(config = "generators", category = "solarPanelAdvanced", key = "advancedDayRate", comment = "Generation rate during day for Advanced Solar Panel (Value in EU)") - public static int advancedGenerationRateD = 64; + @ConfigRegistry(config = "generators", category = "solarPanelIndustrial", key = "industrialDayRate", comment = "Generation rate during day for Industrial Solar Panel (Value in FE)") + public static int industrialGenerationRateD = 64; - @ConfigRegistry(config = "generators", category = "solarPanelAdvanced", key = "advancedNightRate", comment = "Generation rate during night for Advanced Solar Panel (Value in EU)") - public static int advancedGenerationRateN = 2; + @ConfigRegistry(config = "generators", category = "solarPanelIndustrial", key = "industrialNightRate", comment = "Generation rate during night for Industrial Solar Panel (Value in FE)") + public static int industrialGenerationRateN = 2; - @ConfigRegistry(config = "generators", category = "solarPanelUltimate", key = "ultimateDayRate", comment = "Generation rate during day for Ultimate Solar Panel (Value in EU)") + @ConfigRegistry(config = "generators", category = "solarPanelUltimate", key = "ultimateDayRate", comment = "Generation rate during day for Ultimate Solar Panel (Value in FE)") public static int ultimateGenerationRateD = 256; - @ConfigRegistry(config = "generators", category = "solarPanelUltimate", key = "ultimateNightRate", comment = "Generation rate during night for Ultimate Solar Panel (Value in EU)") + @ConfigRegistry(config = "generators", category = "solarPanelUltimate", key = "ultimateNightRate", comment = "Generation rate during night for Ultimate Solar Panel (Value in FE)") public static int ultimateGenerationRateN = 16; - @ConfigRegistry(config = "generators", category = "solarPanelQuantum", key = "quantumDayRate", comment = "Generation rate during day for Quantum Solar Panel (Value in EU)") + @ConfigRegistry(config = "generators", category = "solarPanelQuantum", key = "quantumDayRate", comment = "Generation rate during day for Quantum Solar Panel (Value in FE)") public static int quantumGenerationRateD = 1024; - @ConfigRegistry(config = "generators", category = "solarPanelQuantum", key = "quantumNightRate", comment = "Generation rate during night for Quantum Solar Panel (Value in EU)") + @ConfigRegistry(config = "generators", category = "solarPanelQuantum", key = "quantumNightRate", comment = "Generation rate during night for Quantum Solar Panel (Value in FE)") public static int quantumGenerationRateN = 64; @ConfigRegistry(config = "world", category = "loot", key = "enableOverworldLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to OverWorld loot chests.") diff --git a/src/main/java/techreborn/init/ModBlocks.java b/src/main/java/techreborn/init/ModBlocks.java index c022bd8ee..49501e62a 100644 --- a/src/main/java/techreborn/init/ModBlocks.java +++ b/src/main/java/techreborn/init/ModBlocks.java @@ -34,7 +34,6 @@ import techreborn.TechReborn; import techreborn.blocks.*; import techreborn.blocks.cable.BlockCable; import techreborn.blocks.generator.*; -import techreborn.blocks.generator.solarpanel.BlockSolarPanel; import techreborn.blocks.lighting.BlockLamp; import techreborn.blocks.storage.*; import techreborn.blocks.tier0.BlockIronAlloyFurnace; @@ -107,13 +106,6 @@ public class ModBlocks { public static Block LIGHTNING_ROD; public static Block PLASMA_GENERATOR; public static Block SEMI_FLUID_GENERATOR; - public static Block SOLAR_PANEL_BASIC; - public static Block SOLAR_PANEL_ADVANCED; - public static Block SOLAR_PANEL_INDUSTRIAL; - public static Block SOLAR_PANEL_ULTIMATE; - public static Block SOLAR_PANEL_QUANTUM; - public static Block SOLAR_PANEL_CREATIVE; - public static Block SOLID_FUEL_GENEREATOR; public static Block THERMAL_GENERATOR; public static Block WATER_MILL; @@ -286,24 +278,6 @@ public class ModBlocks { SEMI_FLUID_GENERATOR = new BlockSemiFluidGenerator(); registerBlock(SEMI_FLUID_GENERATOR, "semi_fluid_generator"); - SOLAR_PANEL_BASIC = new BlockSolarPanel(); - registerBlock(SOLAR_PANEL_BASIC, "solar_panel_basic"); - - SOLAR_PANEL_ADVANCED = new BlockSolarPanel(); - registerBlock(SOLAR_PANEL_ADVANCED, "solar_panel_advanced"); - - SOLAR_PANEL_INDUSTRIAL = new BlockSolarPanel(); - registerBlock(SOLAR_PANEL_INDUSTRIAL, "solar_panel_industrial"); - - SOLAR_PANEL_ULTIMATE = new BlockSolarPanel(); - registerBlock(SOLAR_PANEL_ULTIMATE, "solar_panel_ultimate"); - - SOLAR_PANEL_QUANTUM = new BlockSolarPanel(); - registerBlock(SOLAR_PANEL_QUANTUM, "solar_panel_quantum"); - - SOLAR_PANEL_CREATIVE = new BlockSolarPanel(); - registerBlock(SOLAR_PANEL_CREATIVE, "solar_panel_creative"); - SOLID_FUEL_GENEREATOR = new BlockSolidFuelGenerator(); registerBlock(SOLID_FUEL_GENEREATOR, "solid_fuel_generator"); diff --git a/src/main/java/techreborn/init/ModTileEntities.java b/src/main/java/techreborn/init/ModTileEntities.java index 32f6fddf0..764838fef 100644 --- a/src/main/java/techreborn/init/ModTileEntities.java +++ b/src/main/java/techreborn/init/ModTileEntities.java @@ -96,7 +96,6 @@ public enum ModTileEntities { COMPRESSOR(TileCompressor.class, "compressor"), ELECTRIC_FURNACE(TileElectricFurnace.class, "electric_furnace"), SOLAR_PANEL(TileSolarPanel.class, "solar_panel"), - CREATIVE_SOLAR_PANEL(TileCreativeSolarPanel.class, "creative_solar_panel"), CREATIVE_QUANTUM_TANK(TileCreativeQuantumTank.class, "creative_quantum_tank"), CREATIVE_QUANTUM_CHEST(TileCreativeQuantumChest.class, "creative_quantum_chest"), WATER_MILL(TileWaterMill.class, "water_mill"), diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 1fccec255..c788ddc94 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -12,6 +12,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import reborncore.RebornRegistry; +import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IUpgrade; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegister; @@ -21,7 +22,9 @@ import techreborn.blocks.BlockMachineCasing; import techreborn.blocks.BlockMachineFrame; import techreborn.blocks.BlockOre; import techreborn.blocks.BlockStorage; +import techreborn.blocks.generator.solarpanel.BlockSolarPanel; import techreborn.blocks.tier1.BlockElectricFurnace; +import techreborn.config.ConfigTechReborn; import techreborn.items.ItemUpgrade; import techreborn.utils.InitUtils; @@ -37,6 +40,7 @@ public class TRContent { RebornRegistry.registerBlock(value.frame); RebornRegistry.registerBlock(value.casing); }); + Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block)); } public static void registerItems() { @@ -79,6 +83,10 @@ public class TRContent { ResourceLocation platesRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/plate"); Arrays.stream(Plates.values()).forEach(value -> ModelLoader.setCustomModelResourceLocation(value.item, 0, new ModelResourceLocation(platesRL, "type=" + value.name))); + + ResourceLocation upgradeRL = new ResourceLocation(TechReborn.MOD_ID, "items/misc/upgrades"); + Arrays.stream(Upgrades.values()).forEach(value -> ModelLoader.setCustomModelResourceLocation(value.item, 0, + new ModelResourceLocation(upgradeRL, "type=" + value.name))); ResourceLocation oresRL = new ResourceLocation(TechReborn.MOD_ID, "ore"); for (Ores value : Ores.values()) { @@ -119,10 +127,36 @@ public class TRContent { } }); } - - ResourceLocation upgradeRL = new ResourceLocation(TechReborn.MOD_ID, "items/misc/upgrades"); - Arrays.stream(Upgrades.values()).forEach(value -> ModelLoader.setCustomModelResourceLocation(value.item, 0, - new ModelResourceLocation(upgradeRL, "type=" + value.name))); + } + + public static enum SolarPanels { + BASIC(EnumPowerTier.MICRO, ConfigTechReborn.basicGenerationRateD, ConfigTechReborn.basicGenerationRateN), + ADVANCED(EnumPowerTier.LOW, ConfigTechReborn.advancedGenerationRateD, ConfigTechReborn.advancedGenerationRateN), + INDUSTRIAL(EnumPowerTier.MEDIUM, ConfigTechReborn.industrialGenerationRateD, ConfigTechReborn.industrialGenerationRateN), + ULTIMATE(EnumPowerTier.HIGH, ConfigTechReborn.ultimateGenerationRateD, ConfigTechReborn.ultimateGenerationRateN), + QUANTUM(EnumPowerTier.EXTREME, ConfigTechReborn.quantumGenerationRateD, ConfigTechReborn.quantumGenerationRateN), + CREATIVE(EnumPowerTier.INFINITE, Integer.MAX_VALUE, Integer.MAX_VALUE); + + public final String name; + public final Block block; + // Generation of EU during Day + public int generationRateD = 1; + // Generation of EU during Night + public int generationRateN = 0; + // Internal EU storage of solar panel + public int internalCapacity = 1000; + public final EnumPowerTier powerTier; + + private SolarPanels(EnumPowerTier tier, int generationRateD, int generationRateN) { + name = this.toString().toLowerCase(); + powerTier = tier; + block = new BlockSolarPanel(this); + this.generationRateD = generationRateD; + this.generationRateN = generationRateN; + + InitUtils.setup(block, "solar_panel_" + name); + } + } public static enum Ores implements IItemProvider { diff --git a/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java b/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java index 9f7cc62da..8021a6224 100644 --- a/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java +++ b/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java @@ -141,16 +141,16 @@ public class CraftingTableRecipes extends RecipeMethods { registerShaped(getStack(ModBlocks.PLAYER_DETECTOR, true), " D ", "CFC", " D ", 'D', "circuitStorage", 'C', "circuitAdvanced", 'F', getStack(ModBlocks.COMPUTER_CUBE)); registerShaped(getStack(ModBlocks.DRAGON_EGG_SYPHON), "CTC", "PSP", "CBC", 'C', "circuitMaster", 'T', getStack(ModBlocks.MEDIUM_VOLTAGE_SU), 'P', "plateIridiumAlloy", 'S', "craftingSuperconductor", 'B', getStack(TRItems.LAPOTRONIC_ORB)); registerShaped(getStack(ModBlocks.PLASMA_GENERATOR), "PPP", "PTP", "CGC", 'P', "plateTungstensteel", 'T', getStack(ModBlocks.HV_TRANSFORMER), 'C', "circuitMaster", 'G', getStack(ModBlocks.SOLID_FUEL_GENEREATOR)); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 0), "DLD", "LDL", "CGC", 'D', "dustCoal", 'L', "paneGlass", 'G', getStack(ModBlocks.SOLID_FUEL_GENEREATOR), 'C', "circuitBasic"); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 1), "DLD", "LDL", "CPC", 'D', "dustCoal", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 0)); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 1), "DLD", "LDL", "CPC", 'D', "dustCoal", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', "machineBlockBasic"); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 2), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 1)); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 2), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', "machineBlockBasic"); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 3), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitAdvanced", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 2)); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 3), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitAdvanced", 'P', "machineBlockAdvanced"); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitMaster", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 3)); - registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitMaster", 'P', "machineBlockElite"); - registerShaped(getStack(ModBlocks.ALARM, 1, 0), "ICI", "SRS", "ICI", 'I', "ingotIron", 'C', getMaterial("copper", Type.CABLE), 'S', getMaterial("insulatedcopper", Type.CABLE), 'R', "blockRedstone" ); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 0), "DLD", "LDL", "CGC", 'D', "dustCoal", 'L', "paneGlass", 'G', getStack(ModBlocks.SOLID_FUEL_GENEREATOR), 'C', "circuitBasic"); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 1), "DLD", "LDL", "CPC", 'D', "dustCoal", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 0)); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 1), "DLD", "LDL", "CPC", 'D', "dustCoal", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', "machineBlockBasic"); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 2), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 1)); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 2), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "blockGlass", 'C', "circuitAdvanced", 'P', "machineBlockBasic"); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 3), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitAdvanced", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 2)); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 3), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitAdvanced", 'P', "machineBlockAdvanced"); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitMaster", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 3)); +// registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', "glassReinforced", 'C', "circuitMaster", 'P', "machineBlockElite"); +// registerShaped(getStack(ModBlocks.ALARM, 1, 0), "ICI", "SRS", "ICI", 'I', "ingotIron", 'C', getMaterial("copper", Type.CABLE), 'S', getMaterial("insulatedcopper", Type.CABLE), 'R', "blockRedstone" ); registerShaped(getStack(ModBlocks.FLUID_REPLICATOR), "PCP", "CFC", "ESR", 'P', "plateTungstensteel", 'F', "machineBlockElite", 'C', "circuitMaster", 'E', getStack(ModBlocks.INDUSTRIAL_ELECTROLYZER), 'S', "craftingSuperconductor",'R', getStack(ModBlocks.CHEMICAL_REACTOR)); registerShaped(getStack(ModBlocks.HV_TRANSFORMER), " H ", " M ", " H ", 'M', getStack(ModBlocks.MV_TRANSFORMER), 'H', EnumCableType.IHV.getStack()); registerShaped(getStack(ModBlocks.MV_TRANSFORMER), " G ", " M ", " G ", 'M', "machineBlockBasic", 'G', EnumCableType.IGOLD.getStack()); diff --git a/src/main/java/techreborn/tiles/generator/TileCreativeSolarPanel.java b/src/main/java/techreborn/tiles/generator/TileCreativeSolarPanel.java deleted file mode 100644 index dc8139025..000000000 --- a/src/main/java/techreborn/tiles/generator/TileCreativeSolarPanel.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.tiles.generator; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import reborncore.api.IToolDrop; -import reborncore.api.power.EnumPowerTier; -import reborncore.common.powerSystem.TilePowerAcceptor; -import techreborn.init.ModBlocks; - -/** - * Created by modmuss50 on 25/02/2016. - */ -public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDrop { - - boolean shouldMakePower = false; - boolean lastTickSate = false; - - int powerToAdd; - - @Override - public void update() { - super.update(); - setEnergy(getMaxPower()); - } - - @Override - public double getBaseMaxPower() { - return 1_000_000; - } - - @Override - public boolean canAcceptEnergy(final EnumFacing direction) { - return false; - } - - @Override - public boolean canProvideEnergy(final EnumFacing direction) { - return true; - } - - @Override - public double getBaseMaxOutput() { - return 16_192; - } - - @Override - public double getBaseMaxInput() { - return 0; - } - - @Override - public EnumPowerTier getBaseTier() { - return EnumPowerTier.INFINITE; - } - - @Override - public ItemStack getToolDrop(final EntityPlayer p0) { - return new ItemStack(ModBlocks.SOLAR_PANEL); - } - - @Override - public boolean handleTierWithPower() { - return false; - } -} diff --git a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java index e85d5e9db..da3cb1d8b 100644 --- a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java +++ b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java @@ -24,9 +24,9 @@ package techreborn.tiles.generator; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.text.TextFormatting; import reborncore.api.IToolDrop; @@ -34,29 +34,22 @@ import reborncore.api.power.EnumPowerTier; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.StringUtils; -import techreborn.TechReborn; import techreborn.blocks.generator.solarpanel.BlockSolarPanel; -import techreborn.blocks.generator.solarpanel.EnumPanelType; -import techreborn.init.ModBlocks; +import techreborn.init.TRContent.SolarPanels; import java.util.List; public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { boolean canSeeSky = false; - boolean lastSate = false; - int powerToAdd; - EnumPanelType panel; + boolean lastState = false; + SolarPanels panel; - //This is left here to allow the world to create a new instance of it when loading, do not remove this. - public TileSolarPanel() { - super(); - } - - public TileSolarPanel(EnumPanelType panel) { - this.panel = panel; + public boolean isSunOut() { + return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaytime(); } + // TilePowerAcceptor @Override public void update() { super.update(); @@ -65,13 +58,12 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { } if (world.getTotalWorldTime() % 20 == 0) { canSeeSky = world.canBlockSeeSky(pos.up()); - if (lastSate != isSunOut()) { - world.setBlockState(pos, - world.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, isSunOut())); - lastSate = isSunOut(); + if (lastState != isSunOut()) { + world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, isSunOut())); + lastState = isSunOut(); } - } + int powerToAdd; if (isSunOut()) { powerToAdd = panel.generationRateD; } else if (canSeeSky) { @@ -83,10 +75,6 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { addEnergy(powerToAdd); } - public boolean isSunOut() { - return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaytime(); - } - @Override public double getBaseMaxPower() { return panel.internalCapacity; @@ -122,44 +110,42 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { return getTier(); } - @Override - public ItemStack getToolDrop(final EntityPlayer playerIn) { - return new ItemStack(ModBlocks.SOLAR_PANEL, 1, panel.ordinal()); - } - - @Override - public void readFromNBT(NBTTagCompound tag) { - if (tag.hasKey("panelType")) { - panel = EnumPanelType.values()[tag.getInteger("panelType")]; - } else { - TechReborn.LOGGER.warn("A solar panel has failed to load from NBT, it will not work correctly. Please break and replace it to fix the issue. BlockPos:" + pos.toString()); - panel = EnumPanelType.Basic; - } - super.readFromNBT(tag); - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound tag) { - tag.setInteger("panelType", panel.ordinal()); - return super.writeToNBT(tag); - } - @Override public void checkTier() { - //Nope + // Nope } + // TODO: Translate @Override public void addInfo(List info, boolean isRealTile) { info.add(TextFormatting.GRAY + "Internal Energy Storage: " + TextFormatting.GOLD - + PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower())); + + PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower())); info.add(TextFormatting.GRAY + "Generation Rate Day: " + TextFormatting.GOLD - + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)); + + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)); info.add(TextFormatting.GRAY + "Generation Rate Night: " + TextFormatting.GOLD - + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)); + + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)); - info.add(TextFormatting.GRAY + "Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getTier().toString())); + info.add(TextFormatting.GRAY + "Tier: " + TextFormatting.GOLD + + StringUtils.toFirstCapitalAllLowercase(getTier().toString())); + } + + // TileMachineBase + @Override + public void onLoad() { + super.onLoad(); + Block panelBlock = world.getBlockState(pos).getBlock(); + if (panelBlock instanceof BlockSolarPanel) { + BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock; + panel = solarPanelBlock.panelType; + } + } + + // IToolDrop + @Override + public ItemStack getToolDrop(final EntityPlayer playerIn) { + // return new ItemStack(ModBlocks.SOLAR_PANEL, 1, panel.ordinal()); + return null; } } \ No newline at end of file diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/abandoned_mineshaft.json b/src/main/resources/assets/techreborn/loot_tables/chests/abandoned_mineshaft.json index c22541d21..90f6dba61 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/abandoned_mineshaft.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/abandoned_mineshaft.json @@ -111,7 +111,7 @@ }, { "type": "item", - "name": "techreborn:machineblockbasic", + "name": "techreborn:basic_machine_frame", "entryName": "basic_frame", "weight": 5 }, diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/desert_pyramid.json b/src/main/resources/assets/techreborn/loot_tables/chests/desert_pyramid.json index c22541d21..90f6dba61 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/desert_pyramid.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/desert_pyramid.json @@ -111,7 +111,7 @@ }, { "type": "item", - "name": "techreborn:machineblockbasic", + "name": "techreborn:basic_machine_frame", "entryName": "basic_frame", "weight": 5 }, diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/end_city_treasure.json b/src/main/resources/assets/techreborn/loot_tables/chests/end_city_treasure.json index 857153cdb..15fe3239c 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/end_city_treasure.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/end_city_treasure.json @@ -99,8 +99,8 @@ }, { "type": "item", - "name": "techreborn:machineblockelite", - "entryName": "highly_advanced_frame", + "name": "techreborn:industrial_machine_frame", + "entryName": "tier3_machine_block", "weight": 30 }, { diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/igloo_chest.json b/src/main/resources/assets/techreborn/loot_tables/chests/igloo_chest.json index c22541d21..90f6dba61 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/igloo_chest.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/igloo_chest.json @@ -111,7 +111,7 @@ }, { "type": "item", - "name": "techreborn:machineblockbasic", + "name": "techreborn:basic_machine_frame", "entryName": "basic_frame", "weight": 5 }, diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/jungle_temple.json b/src/main/resources/assets/techreborn/loot_tables/chests/jungle_temple.json index c22541d21..90f6dba61 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/jungle_temple.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/jungle_temple.json @@ -111,7 +111,7 @@ }, { "type": "item", - "name": "techreborn:machineblockbasic", + "name": "techreborn:basic_machine_frame", "entryName": "basic_frame", "weight": 5 }, diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/nether_bridge.json b/src/main/resources/assets/techreborn/loot_tables/chests/nether_bridge.json index 3c4afac8d..0c2e97b42 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/nether_bridge.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/nether_bridge.json @@ -114,8 +114,8 @@ }, { "type": "item", - "name": "techreborn:machineblockadvanced", - "entryName": "reinforced_frame", + "name": "techreborn:advanced_machine_frame", + "entryName": "tier2_machine_block", "weight": 30 }, { diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/simple_dungeon.json b/src/main/resources/assets/techreborn/loot_tables/chests/simple_dungeon.json index c22541d21..90f6dba61 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/simple_dungeon.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/simple_dungeon.json @@ -111,7 +111,7 @@ }, { "type": "item", - "name": "techreborn:machineblockbasic", + "name": "techreborn:basic_machine_frame", "entryName": "basic_frame", "weight": 5 }, diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_corridor.json b/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_corridor.json index 3c4afac8d..0c2e97b42 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_corridor.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_corridor.json @@ -114,8 +114,8 @@ }, { "type": "item", - "name": "techreborn:machineblockadvanced", - "entryName": "reinforced_frame", + "name": "techreborn:advanced_machine_frame", + "entryName": "tier2_machine_block", "weight": 30 }, { diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_crossing.json b/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_crossing.json index 3c4afac8d..0c2e97b42 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_crossing.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_crossing.json @@ -114,8 +114,8 @@ }, { "type": "item", - "name": "techreborn:machineblockadvanced", - "entryName": "reinforced_frame", + "name": "techreborn:advanced_machine_frame", + "entryName": "tier2_machine_block", "weight": 30 }, { diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_library.json b/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_library.json index 3c4afac8d..0c2e97b42 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_library.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/stronghold_library.json @@ -114,8 +114,8 @@ }, { "type": "item", - "name": "techreborn:machineblockadvanced", - "entryName": "reinforced_frame", + "name": "techreborn:advanced_machine_frame", + "entryName": "tier2_machine_block", "weight": 30 }, { diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/village_blacksmith.json b/src/main/resources/assets/techreborn/loot_tables/chests/village_blacksmith.json index c22541d21..90f6dba61 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/village_blacksmith.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/village_blacksmith.json @@ -111,7 +111,7 @@ }, { "type": "item", - "name": "techreborn:machineblockbasic", + "name": "techreborn:basic_machine_frame", "entryName": "basic_frame", "weight": 5 }, diff --git a/src/main/resources/assets/techreborn/loot_tables/chests/woodland_mansion.json b/src/main/resources/assets/techreborn/loot_tables/chests/woodland_mansion.json index 857153cdb..15fe3239c 100644 --- a/src/main/resources/assets/techreborn/loot_tables/chests/woodland_mansion.json +++ b/src/main/resources/assets/techreborn/loot_tables/chests/woodland_mansion.json @@ -99,8 +99,8 @@ }, { "type": "item", - "name": "techreborn:machineblockelite", - "entryName": "highly_advanced_frame", + "name": "techreborn:industrial_machine_frame", + "entryName": "tier3_machine_block", "weight": 30 }, {