Some more work on solar panels.
This commit is contained in:
parent
0aa8974035
commit
e0edff6891
9 changed files with 45 additions and 28 deletions
|
@ -27,6 +27,7 @@ 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;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -58,31 +59,38 @@ 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);
|
||||
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
||||
private static final List<String> paneList = Lists.newArrayList(panes);
|
||||
|
||||
public BlockSolarPanel() {
|
||||
super(Material.IRON);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
this.setDefaultState(this.getBlockState().getBaseState().withProperty(TYPE, EnumPanelType.Basic));
|
||||
this.setDefaultState(this.getBlockState().getBaseState().withProperty(TYPE, EnumPanelType.Basic).withProperty(ACTIVE, false));
|
||||
setHardness(2.0F);
|
||||
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]));
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("type=" + panes[i] + ",active=false"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(TYPE).ordinal();
|
||||
int active = state.getValue(ACTIVE) ? EnumPanelType.values().length : 0;
|
||||
return state.getValue(TYPE).ordinal() + active;
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]{TYPE});
|
||||
return new BlockStateContainer(this, TYPE, ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(TYPE, EnumPanelType.values()[meta]);
|
||||
boolean active = false;
|
||||
if(meta >= EnumPanelType.values().length){
|
||||
active = true;
|
||||
meta -= EnumPanelType.values().length;
|
||||
}
|
||||
return getDefaultState().withProperty(TYPE, EnumPanelType.values()[meta]).withProperty(ACTIVE, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,8 @@ package techreborn.itemblocks;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.blocks.generator.solarpanel.EnumPanelType;
|
||||
import techreborn.blocks.generator.solarpanel.BlockSolarPanel;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class ItemBlockSolarPanel extends ItemBlock {
|
||||
|
||||
|
@ -13,6 +14,6 @@ public class ItemBlockSolarPanel extends ItemBlock {
|
|||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName() + "." + EnumPanelType.values()[stack.getItemDamage()].getName();
|
||||
return super.getUnlocalizedName() + "." + ModBlocks.SOLAR_PANEL.getStateFromMeta(stack.getItemDamage()).getValue(BlockSolarPanel.TYPE).getName().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import reborncore.api.power.EnumPowerTier;
|
|||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.Core;
|
||||
import techreborn.blocks.generator.solarpanel.BlockSolarPanel;
|
||||
import techreborn.blocks.generator.solarpanel.EnumPanelType;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
|
@ -42,6 +43,7 @@ import java.util.List;
|
|||
public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
||||
|
||||
boolean canSeeSky = false;
|
||||
boolean lastSate = false;
|
||||
int powerToAdd;
|
||||
EnumPanelType panel;
|
||||
|
||||
|
@ -62,6 +64,12 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
|||
}
|
||||
if (world.getTotalWorldTime() % 20 == 0) {
|
||||
canSeeSky = this.world.canBlockSeeSky(this.pos.up());
|
||||
if(lastSate != this.isSunOut()){
|
||||
this.world.setBlockState(this.getPos(),
|
||||
this.world.getBlockState(this.getPos()).withProperty(BlockSolarPanel.ACTIVE, this.isSunOut()));
|
||||
lastSate = isSunOut();
|
||||
}
|
||||
|
||||
}
|
||||
if (isSunOut()) {
|
||||
this.powerToAdd = panel.generationRateD;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"textures": {},
|
||||
"textures": {
|
||||
"particle": "techreborn:blocks/machines/generators/generator_bottom",
|
||||
"down": "techreborn:blocks/machines/generators/generator_bottom"
|
||||
},
|
||||
"transform": "forge:default-block",
|
||||
"model": "cube_bottom_top"
|
||||
},
|
||||
|
@ -11,45 +14,42 @@
|
|||
"model": "orientable",
|
||||
"textures": {}
|
||||
},
|
||||
"active": {
|
||||
"true": {
|
||||
"textures": {
|
||||
"side": "techreborn:blocks/machines/generators/solar_panel_side_on"
|
||||
}
|
||||
},
|
||||
"false": {
|
||||
"textures": {
|
||||
"side": "techreborn:blocks/machines/generators/solar_panel_side_off"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"basic": {
|
||||
"textures": {
|
||||
"particle": "techreborn:blocks/machines/generators/panels/basicsolar_panel_side",
|
||||
"top": "techreborn:blocks/machines/generators/panels/basicsolar_panel_top",
|
||||
"down": "techreborn:blocks/machines/generators/generator_bottom",
|
||||
"side": "techreborn:blocks/machines/generators/panels/basicsolar_panel_side"
|
||||
"top": "techreborn:blocks/machines/generators/panels/basicsolar_panel_top"
|
||||
}
|
||||
},
|
||||
"hybrid": {
|
||||
"textures": {
|
||||
"particle": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_side",
|
||||
"top": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_top",
|
||||
"down": "techreborn:blocks/machines/generators/generator_bottom",
|
||||
"side": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_side"
|
||||
"top": "techreborn:blocks/machines/generators/panels/hybridsolar_panel_top"
|
||||
}
|
||||
},
|
||||
"advanced": {
|
||||
"textures": {
|
||||
"particle": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_side",
|
||||
"top": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_top",
|
||||
"down": "techreborn:blocks/machines/generators/generator_bottom",
|
||||
"side": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_side"
|
||||
"top": "techreborn:blocks/machines/generators/panels/advancedsolar_panel_top"
|
||||
}
|
||||
},
|
||||
"ultimate": {
|
||||
"textures": {
|
||||
"particle": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_side",
|
||||
"top": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_top",
|
||||
"down": "techreborn:blocks/machines/generators/generator_bottom",
|
||||
"side": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_side"
|
||||
"top": "techreborn:blocks/machines/generators/panels/ultimatesolar_panel_top"
|
||||
}
|
||||
},
|
||||
"quantum": {
|
||||
"textures": {
|
||||
"particle": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_side",
|
||||
"top": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_top",
|
||||
"down": "techreborn:blocks/machines/generators/generator_bottom",
|
||||
"side": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_side"
|
||||
"top": "techreborn:blocks/machines/generators/panels/quantumsolar_panel_top"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 650 B |
Binary file not shown.
Before Width: | Height: | Size: 636 B |
Binary file not shown.
Before Width: | Height: | Size: 642 B |
Binary file not shown.
Before Width: | Height: | Size: 650 B |
Binary file not shown.
Before Width: | Height: | Size: 653 B |
Loading…
Reference in a new issue