Fixed itemBlock rendering. TOP\Waila are still an issue

This commit is contained in:
drcrazy 2017-11-05 02:32:06 +03:00
parent 047507f4fc
commit 19ccbd681d
6 changed files with 94 additions and 42 deletions

View file

@ -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<EnumPanelType> TYPE = PropertyEnum.create("type", EnumPanelType.class);
"basic", "hybrid", "advanced", "ultimate", "quantum"};
public static PropertyBool ACTIVE = PropertyBool.create("active");
private static final List<String> paneList = Lists.newArrayList(panes);
public static final IProperty<EnumPanelType> 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

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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": {