From 19ccbd681d874eb2aed02db4e1f377a103e8edd3 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Sun, 5 Nov 2017 02:32:06 +0300 Subject: [PATCH] Fixed itemBlock rendering. TOP\Waila are still an issue --- .../generator/solarpanel/BlockSolarPanel.java | 18 ++++----- .../generator/solarpanel/EnumPanelType.java | 36 ++++++++++++----- .../techreborn/client/RegisterItemJsons.java | 5 --- .../itemblocks/ItemBlockSolarPanel.java | 39 +++++++++++++------ .../java/techreborn/utils/IC2ItemCharger.java | 24 ++++++++++++ .../machines/generators/solar_panel.json | 14 ++++--- 6 files changed, 94 insertions(+), 42 deletions(-) diff --git a/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java b/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java index 6985d9e04..16953f8ed 100644 --- a/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java +++ b/src/main/java/techreborn/blocks/generator/solarpanel/BlockSolarPanel.java @@ -24,7 +24,6 @@ package techreborn.blocks.generator.solarpanel; -import com.google.common.collect.Lists; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; @@ -50,26 +49,23 @@ import techreborn.client.TechRebornCreativeTab; import techreborn.lib.ModInfo; import techreborn.tiles.generator.TileSolarPanel; -import java.util.List; - /** * Created by modmuss50 on 25/02/2016. */ public class BlockSolarPanel extends BaseTileBlock { public static final String[] panes = new String[] { - "Basic", "Hybrid", "Advanced", "Ultimate", "Quantum"}; - public static final IProperty TYPE = PropertyEnum.create("type", EnumPanelType.class); + "basic", "hybrid", "advanced", "ultimate", "quantum"}; public static PropertyBool ACTIVE = PropertyBool.create("active"); - private static final List paneList = Lists.newArrayList(panes); + public static final IProperty TYPE = PropertyEnum.create("type", EnumPanelType.class); public BlockSolarPanel() { super(Material.IRON); setCreativeTab(TechRebornCreativeTab.instance); - this.setDefaultState(this.getBlockState().getBaseState().withProperty(TYPE, EnumPanelType.Basic).withProperty(ACTIVE, false)); + this.setDefaultState(this.getBlockState().getBaseState().withProperty(ACTIVE, false).withProperty(TYPE, EnumPanelType.Basic)); setHardness(2.0F); - this.setDefaultState(this.getStateFromMeta(0)); + //this.setDefaultState(this.getStateFromMeta(0)); for (int i = 0; i < panes.length; i++) { - ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("type=" + panes[i] + ",active=false")); + ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("active=false,type=" + panes[i])); } } @@ -80,7 +76,7 @@ public class BlockSolarPanel extends BaseTileBlock { } protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TYPE, ACTIVE); + return new BlockStateContainer(this, ACTIVE, TYPE); } @Override @@ -90,7 +86,7 @@ public class BlockSolarPanel extends BaseTileBlock { active = true; meta -= EnumPanelType.values().length; } - return getDefaultState().withProperty(TYPE, EnumPanelType.values()[meta]).withProperty(ACTIVE, active); + return getDefaultState().withProperty(ACTIVE, active).withProperty(TYPE, EnumPanelType.values()[meta]); } @Override diff --git a/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java b/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java index 89c59de6c..a1b785283 100644 --- a/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java +++ b/src/main/java/techreborn/blocks/generator/solarpanel/EnumPanelType.java @@ -1,3 +1,27 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 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; @@ -10,18 +34,13 @@ public enum EnumPanelType implements IStringSerializable { Ultimate("ultimate", 256, 16, EnumPowerTier.HIGH), Quantum("quantum", 1024, 64, EnumPowerTier.EXTREME); - private int ID; private String friendlyName; - - public int generationRateD = 10; // Generation of EU during Day - - public int generationRateN = 0; + public int generationRateD = 10; // Generation of EU during Night - - public int internalCapacity = 1000; + public int generationRateN = 0; // Internal EU storage of solar panel - + public int internalCapacity = 1000; public EnumPowerTier powerTier; @@ -37,5 +56,4 @@ public enum EnumPanelType implements IStringSerializable { public String getName() { return friendlyName; } - } \ No newline at end of file diff --git a/src/main/java/techreborn/client/RegisterItemJsons.java b/src/main/java/techreborn/client/RegisterItemJsons.java index 0b484985a..35af03e48 100644 --- a/src/main/java/techreborn/client/RegisterItemJsons.java +++ b/src/main/java/techreborn/client/RegisterItemJsons.java @@ -35,7 +35,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import techreborn.blocks.cable.BlockCable; import techreborn.blocks.cable.EnumCableType; -import techreborn.blocks.generator.solarpanel.EnumPanelType; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.init.ModItems; @@ -176,10 +175,6 @@ public class RegisterItemJsons { registerBlockstateMultiItem(Item.getItemFromBlock(ModBlocks.CABLE), cableType.ordinal(), cableType.getName().toLowerCase(), "cable_inv"); } - for (EnumPanelType panelType : EnumPanelType.values()) { - registerBlockstate(Item.getItemFromBlock(ModBlocks.SOLAR_PANEL), panelType.ordinal(), panelType.getName().toLowerCase() + ",active=false", "blocks/generators/"); - } - ModelLoader.setCustomStateMapper(ModBlocks.CABLE, new DefaultStateMapper() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { diff --git a/src/main/java/techreborn/itemblocks/ItemBlockSolarPanel.java b/src/main/java/techreborn/itemblocks/ItemBlockSolarPanel.java index 534119332..8630ba403 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockSolarPanel.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockSolarPanel.java @@ -1,19 +1,36 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 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.itemblocks; import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; +import reborncore.common.itemblock.ItemBlockBase; import techreborn.blocks.generator.solarpanel.BlockSolarPanel; import techreborn.init.ModBlocks; -public class ItemBlockSolarPanel extends ItemBlock { - - public ItemBlockSolarPanel(Block block) { - super(block); - setHasSubtypes(true); - } - - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + "." + ModBlocks.SOLAR_PANEL.getStateFromMeta(stack.getItemDamage()).getValue(BlockSolarPanel.TYPE).getName().toLowerCase(); +public class ItemBlockSolarPanel extends ItemBlockBase { + public ItemBlockSolarPanel(Block block){ + super(ModBlocks.SOLAR_PANEL, ModBlocks.SOLAR_PANEL, BlockSolarPanel.panes); } } diff --git a/src/main/java/techreborn/utils/IC2ItemCharger.java b/src/main/java/techreborn/utils/IC2ItemCharger.java index d39eb6e6d..52d0475cc 100644 --- a/src/main/java/techreborn/utils/IC2ItemCharger.java +++ b/src/main/java/techreborn/utils/IC2ItemCharger.java @@ -1,3 +1,27 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2017 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.utils; import ic2.api.item.ElectricItem; diff --git a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel.json b/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel.json index 8620ec392..5c2dd8de8 100644 --- a/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel.json +++ b/src/main/resources/assets/techreborn/blockstates/machines/generators/solar_panel.json @@ -3,17 +3,19 @@ "defaults": { "textures": { "particle": "techreborn:blocks/machines/generators/generator_bottom", - "down": "techreborn:blocks/machines/generators/generator_bottom" + "down": "techreborn:blocks/machines/generators/generator_bottom", + "side": "techreborn:blocks/machines/generators/solar_panel_side_off" }, "transform": "forge:default-block", "model": "cube_bottom_top" }, "variants": { - "inventory": { - "transform": "forge:default-block", - "model": "orientable", - "textures": {} - }, + "inventory": { + "transform": "forge:default-block", + "model": "cube_bottom_top", + "textures": {} + }, + "normal": [{}], "active": { "true": { "textures": {