From 7a005f7494b1906639330bef55b7b4bfb651a806 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Fri, 21 Sep 2018 19:44:30 +0300 Subject: [PATCH] Sorting and renaming for cables and panels. Still not rendering --- .../techreborn/blocks/cable/BlockCable.java | 6 ---- .../techreborn/client/RegisterItemJsons.java | 25 ++------------- src/main/java/techreborn/init/ModBlocks.java | 1 - src/main/java/techreborn/init/OreDict.java | 1 - .../techreborn/init/SubItemRetriever.java | 2 -- src/main/java/techreborn/init/TRContent.java | 31 ++++++++++++++----- .../init/recipes/RecipeMethods.java | 1 - .../techreborn/blockstates/cable_thin.json | 10 +----- ...dvanced.json => advanced_solar_panel.json} | 0 ...anel_basic.json => basic_solar_panel.json} | 0 ...reative.json => creative_solar_panel.json} | 0 ...trial.json => industrial_solar_panel.json} | 0 ..._quantum.json => quantum_solar_panel.json} | 0 ...ltimate.json => ultimate_solar_panel.json} | 0 14 files changed, 27 insertions(+), 50 deletions(-) rename src/main/resources/assets/techreborn/blockstates/machines/generators/{solar_panel_advanced.json => advanced_solar_panel.json} (100%) rename src/main/resources/assets/techreborn/blockstates/machines/generators/{solar_panel_basic.json => basic_solar_panel.json} (100%) rename src/main/resources/assets/techreborn/blockstates/machines/generators/{solar_panel_creative.json => creative_solar_panel.json} (100%) rename src/main/resources/assets/techreborn/blockstates/machines/generators/{solar_panel_industrial.json => industrial_solar_panel.json} (100%) rename src/main/resources/assets/techreborn/blockstates/machines/generators/{solar_panel_quantum.json => quantum_solar_panel.json} (100%) rename src/main/resources/assets/techreborn/blockstates/machines/generators/{solar_panel_ultimate.json => ultimate_solar_panel.json} (100%) diff --git a/src/main/java/techreborn/blocks/cable/BlockCable.java b/src/main/java/techreborn/blocks/cable/BlockCable.java index 85cdf1bb4..2c5174f21 100644 --- a/src/main/java/techreborn/blocks/cable/BlockCable.java +++ b/src/main/java/techreborn/blocks/cable/BlockCable.java @@ -28,10 +28,8 @@ import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -40,20 +38,17 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.energy.CapabilityEnergy; import reborncore.api.ToolManager; -import reborncore.common.RebornCoreConfig; import reborncore.common.blocks.BlockWrenchEventHandler; import reborncore.common.items.WrenchHelper; import reborncore.common.registration.RebornRegister; import reborncore.common.registration.impl.ConfigRegistry; import techreborn.TechReborn; -import techreborn.init.ModBlocks; import techreborn.init.ModSounds; import techreborn.init.TRContent; import techreborn.tiles.cable.TileCable; @@ -61,7 +56,6 @@ import techreborn.utils.TechRebornCreativeTab; import techreborn.utils.damageSources.ElectrialShockSource; import javax.annotation.Nullable; -import java.security.InvalidParameterException; /** * Created by modmuss50 on 19/05/2017. diff --git a/src/main/java/techreborn/client/RegisterItemJsons.java b/src/main/java/techreborn/client/RegisterItemJsons.java index b729c03bc..28c18a785 100644 --- a/src/main/java/techreborn/client/RegisterItemJsons.java +++ b/src/main/java/techreborn/client/RegisterItemJsons.java @@ -128,29 +128,10 @@ public class RegisterItemJsons { } register(ModBlocks.RUBBER_SAPLING, "misc/rubber_sapling"); - - for (TRContent.Cables cableType : TRContent.Cables.values()) { - BlockCable blockCable = cableType.block; - - registerBlockstateMultiItem(Item.getItemFromBlock(blockCable), cableType.name().toLowerCase(), "cable_inv"); - - ModelLoader.setCustomStateMapper(blockCable, new DefaultStateMapper() { - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state) { - Map, Comparable> map = Maps.newLinkedHashMap(state.getProperties()); - BlockCable cable = (BlockCable) state.getBlock(); - String property = this.getPropertyString(map) + ",type=" + cable.type.name().toLowerCase(); - return new ModelResourceLocation(new ResourceLocation(TechReborn.MOD_ID, "cable_" + (cable.type.cableThickness > 10 ? "thick" : "thin")), property); - } - }); - } - - } private static void registerBlocks() { register(ModBlocks.REFINED_IRON_FENCE, "iron_fence"); - } private static void register(Item item, int meta, String name) { @@ -163,13 +144,12 @@ public class RegisterItemJsons { register(item, 0, name); } - @SuppressWarnings("unused") private static void register(Block block, int meta, String name) { register(Item.getItemFromBlock(block), meta, name); } private static void register(Block block, String name) { - register(Item.getItemFromBlock(block), 0, name); + register(block, 0, name); } @SuppressWarnings("unused") @@ -192,8 +172,7 @@ public class RegisterItemJsons { } private static void registerBlockstateMultiItem(Item item, String variantName, String path) { - ResourceLocation loc = new ResourceLocation(TechReborn.MOD_ID, path); - ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(loc, "type=" + variantName)); + registerBlockstateMultiItem(item, 0, variantName, path); } private static void registerBlockstateMultiItem(Item item, int meta, String variantName, String path) { diff --git a/src/main/java/techreborn/init/ModBlocks.java b/src/main/java/techreborn/init/ModBlocks.java index 0275dbde7..d80090709 100644 --- a/src/main/java/techreborn/init/ModBlocks.java +++ b/src/main/java/techreborn/init/ModBlocks.java @@ -32,7 +32,6 @@ import net.minecraft.util.ResourceLocation; import reborncore.RebornRegistry; import techreborn.TechReborn; import techreborn.blocks.*; -import techreborn.blocks.cable.BlockCable; import techreborn.blocks.generator.*; import techreborn.blocks.lighting.BlockLamp; import techreborn.blocks.storage.*; diff --git a/src/main/java/techreborn/init/OreDict.java b/src/main/java/techreborn/init/OreDict.java index c0464750c..2e4a8c14b 100644 --- a/src/main/java/techreborn/init/OreDict.java +++ b/src/main/java/techreborn/init/OreDict.java @@ -29,7 +29,6 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import reborncore.common.util.OreUtil; -import techreborn.blocks.cable.BlockCable; public class OreDict { diff --git a/src/main/java/techreborn/init/SubItemRetriever.java b/src/main/java/techreborn/init/SubItemRetriever.java index 4ce8e88c6..bd8587658 100644 --- a/src/main/java/techreborn/init/SubItemRetriever.java +++ b/src/main/java/techreborn/init/SubItemRetriever.java @@ -26,8 +26,6 @@ package techreborn.init; import net.minecraft.item.ItemStack; import techreborn.api.ISubItemRetriever; -import techreborn.blocks.BlockOre; -import techreborn.blocks.BlockStorage; import techreborn.items.*; /** diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 807c0a584..fde8f8926 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -129,6 +129,20 @@ public class TRContent { } }); } + + ResourceLocation cableRL = new ResourceLocation(TechReborn.MOD_ID, "cable_inv"); + for (Cables value : Cables.values()) { + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(value.block), 0, new ModelResourceLocation(cableRL, "type=" + value.name)); + ModelLoader.setCustomStateMapper(value.block, new DefaultStateMapper() { + @Override + protected ModelResourceLocation getModelResourceLocation(IBlockState state) { + return new ModelResourceLocation(new ResourceLocation(TechReborn.MOD_ID, "cable_" + (value.cableThickness == 5 ? "thick" : "thin")), "type=" + value.name); + } + }); + + + + } } public static enum SolarPanels { @@ -141,6 +155,7 @@ public class TRContent { public final String name; public final Block block; + // Generation of EU during Day public int generationRateD = 1; // Generation of EU during Night @@ -158,7 +173,7 @@ public class TRContent { // Buffer for 2 mins of work internalCapacity = generationRateD * 2_400; - InitUtils.setup(block, "solar_panel_" + name); + InitUtils.setup(block, name + "_solar_panel"); } } @@ -173,17 +188,19 @@ public class TRContent { INSULATED_GOLD(512, 10.0, false, EnumPowerTier.HIGH), INSULATED_HV(2048, 10.0, false, EnumPowerTier.EXTREME); + public final String name; + public final BlockCable block; + public int transferRate; public int defaultTransferRate; public double cableThickness; public boolean canKill; public boolean defaultCanKill; public EnumPowerTier tier; - - public final BlockCable block; - - Cables(int transferRate, double cableThickness, boolean canKill, - EnumPowerTier tier) { + + + Cables(int transferRate, double cableThickness, boolean canKill, EnumPowerTier tier) { + name = this.toString().toLowerCase(); this.transferRate = transferRate; this.defaultTransferRate = transferRate; this.cableThickness = cableThickness / 2; @@ -191,7 +208,7 @@ public class TRContent { this.defaultCanKill = canKill; this.tier = tier; this.block = new BlockCable(this); - InitUtils.setup(block, "cable_" + this.name().toLowerCase()); + InitUtils.setup(block, name + "_cable"); } } diff --git a/src/main/java/techreborn/init/recipes/RecipeMethods.java b/src/main/java/techreborn/init/recipes/RecipeMethods.java index 72e0864d4..3ecb3f8ce 100644 --- a/src/main/java/techreborn/init/recipes/RecipeMethods.java +++ b/src/main/java/techreborn/init/recipes/RecipeMethods.java @@ -31,7 +31,6 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.oredict.OreDictionary; import reborncore.common.util.OreUtil; import reborncore.common.util.StringUtils; -import techreborn.blocks.cable.BlockCable; import techreborn.items.*; /** diff --git a/src/main/resources/assets/techreborn/blockstates/cable_thin.json b/src/main/resources/assets/techreborn/blockstates/cable_thin.json index 99d741bf6..f0dd72c88 100644 --- a/src/main/resources/assets/techreborn/blockstates/cable_thin.json +++ b/src/main/resources/assets/techreborn/blockstates/cable_thin.json @@ -8,15 +8,7 @@ } }, "variants": { - "inventory": [ - { - "transform": "forge:default-block", - "model": "techreborn:cable", - "textures": { - "cable": "techreborn:blocks/cables/copper_cable" - } - } - ], + "inventory": [{} ], "down": { "true": { "submodel": { diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_advanced.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/advanced_solar_panel.json similarity index 100% rename from src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_advanced.json rename to src/main/resources/assets/techreborn/blockstates/machines/generators/advanced_solar_panel.json diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_basic.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/basic_solar_panel.json similarity index 100% rename from src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_basic.json rename to src/main/resources/assets/techreborn/blockstates/machines/generators/basic_solar_panel.json diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_creative.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/creative_solar_panel.json similarity index 100% rename from src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_creative.json rename to src/main/resources/assets/techreborn/blockstates/machines/generators/creative_solar_panel.json diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_industrial.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/industrial_solar_panel.json similarity index 100% rename from src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_industrial.json rename to src/main/resources/assets/techreborn/blockstates/machines/generators/industrial_solar_panel.json diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_quantum.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/quantum_solar_panel.json similarity index 100% rename from src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_quantum.json rename to src/main/resources/assets/techreborn/blockstates/machines/generators/quantum_solar_panel.json diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_ultimate.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/ultimate_solar_panel.json similarity index 100% rename from src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel_ultimate.json rename to src/main/resources/assets/techreborn/blockstates/machines/generators/ultimate_solar_panel.json