Update to latest commit(Master)

This commit is contained in:
Dimmerworld 2017-10-05 02:38:11 +11:00 committed by drcrazy
parent c8b6edd390
commit c651363b73
12 changed files with 174 additions and 135 deletions

View file

@ -22,17 +22,19 @@
* SOFTWARE.
*/
package techreborn.blocks.generator;
package techreborn.blocks.generator.solarpanel;
import net.minecraft.block.Block;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
@ -45,30 +47,36 @@ import techreborn.tiles.generator.TileSolarPanel;
* Created by modmuss50 on 25/02/2016.
*/
public class BlockSolarPanel extends BaseTileBlock {
public static PropertyBool ACTIVE = PropertyBool.create("active");
public static final String[] panes = new String[] {
"basic", "hybrid", "advanced", "ultimate", "quantum"};
public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumPanelType.class);
public BlockSolarPanel() {
super(Material.IRON);
setCreativeTab(TechRebornCreativeTab.instance);
this.setDefaultState(this.getDefaultState().withProperty(ACTIVE, false));
this.setDefaultState(this.getBlockState().getBaseState().withProperty(TYPE, EnumPanelType.Basic));
setHardness(2.0F);
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/generators"));
this.setDefaultState(this.getStateFromMeta(0));
for (int i = 0; i < panes.length; i++) {
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i).setInvVariant("type=" + panes[i]).setFileName("ores"));
}
}
protected BlockStateContainer createBlockState() {
ACTIVE = PropertyBool.create("active");
return new BlockStateContainer(this, ACTIVE);
return new BlockStateContainer(this, new IProperty[]{TYPE});
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(ACTIVE, meta != 0);
return getDefaultState().withProperty(TYPE, EnumPanelType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(ACTIVE) ? 1 : 0;
EnumPanelType type = (EnumPanelType) state.getValue(TYPE);
return type.getID();
}
@Override
@ -77,31 +85,9 @@ public class BlockSolarPanel extends BaseTileBlock {
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock, BlockPos p_189540_5_) {
if (worldIn.canBlockSeeSky(pos.up()) && !worldIn.isRaining() && !worldIn.isThundering()
&& worldIn.isDaytime()) {
worldIn.setBlockState(pos,
worldIn.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, true));
} else {
worldIn.setBlockState(pos,
worldIn.getBlockState(pos).withProperty(BlockSolarPanel.ACTIVE, false));
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (EnumPanelType panelType : EnumPanelType.values()) {
list.add(new ItemStack(this, 1, panelType.ordinal()));
}
}
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY,
float hitZ, int meta, EntityLivingBase placer) {
if (!worldIn.isRemote) {
if (worldIn.canBlockSeeSky(pos.up()) && !worldIn.isRaining() && !worldIn.isThundering() && worldIn.isDaytime()) {
return this.getDefaultState().withProperty(ACTIVE, true);
} else {
return this.getDefaultState().withProperty(ACTIVE, false);
}
} else {
return this.getDefaultState().withProperty(ACTIVE, false);
}
}
}

View file

@ -0,0 +1,34 @@
package techreborn.blocks.generator.solarpanel;
import net.minecraft.util.IStringSerializable;
import reborncore.api.power.EnumPowerTier;
public enum EnumPanelType implements IStringSerializable {
Basic("basic", 128, EnumPowerTier.LOW, 0),
Hybrid("hybrid", 32, EnumPowerTier.MEDIUM, 1),
Advanced("advanced", 512, EnumPowerTier.MEDIUM, 2),
Ultimate("ultimate", 2048, EnumPowerTier.HIGH, 3),
Quantum("quantum", 2048, EnumPowerTier.EXTREME, 4);
private int ID;
public int generationRate = 128;
private String friendlyName;
EnumPanelType(String friendlyName, int generationRate, EnumPowerTier tier, int ID) {
this.friendlyName = friendlyName;
this.generationRate = generationRate;
this.ID = ID;
}
@Override
public String getName() {
return friendlyName.toLowerCase();
}
public int getID(){
return ID;
}
}