Added solar panel textures that are based on sate
This commit is contained in:
parent
76665a0360
commit
e3c71248a4
2 changed files with 48 additions and 1 deletions
|
@ -1,7 +1,13 @@
|
|||
package techreborn.blocks.generator;
|
||||
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
|
@ -10,16 +16,50 @@ import techreborn.tiles.generator.TileSolarPanel;
|
|||
/**
|
||||
* Created by mark on 25/02/2016.
|
||||
*/
|
||||
public class BlockSolarPanel extends BaseTileBlock {
|
||||
public class BlockSolarPanel extends BaseTileBlock implements ITexturedBlock {
|
||||
|
||||
public static PropertyBool ACTIVE = PropertyBool.create("active");
|
||||
|
||||
public BlockSolarPanel() {
|
||||
super(Material.iron);
|
||||
setUnlocalizedName("techreborn.solarpanel");
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(ACTIVE, false));
|
||||
}
|
||||
|
||||
protected BlockState createBlockState() {
|
||||
ACTIVE = PropertyBool.create("active");
|
||||
return new BlockState(this, ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(ACTIVE, meta == 0 ? false : true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(ACTIVE) == true ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileSolarPanel();
|
||||
}
|
||||
|
||||
private final String prefix = "techreborn:blocks/machine/";
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState state, EnumFacing side) {
|
||||
boolean isActive = state.getValue(ACTIVE);
|
||||
if(side == EnumFacing.UP){
|
||||
return prefix + "solar_panel_top_" + (isActive ? "on" : "off");
|
||||
}
|
||||
return prefix + "solar_panel_side_" + (isActive ? "on" : "off");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue