Textures and block work.

This commit is contained in:
Dimmerworld 2017-10-05 21:35:23 +11:00 committed by drcrazy
parent d3ede81de4
commit c4711848ae
16 changed files with 121 additions and 107 deletions

View file

@ -25,20 +25,29 @@
package techreborn.blocks.generator.solarpanel;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.material.Material;
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.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.common.BaseTileBlock;
import reborncore.common.util.ArrayUtils;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
import techreborn.tiles.generator.TileSolarPanel;
@ -48,22 +57,25 @@ import techreborn.tiles.generator.TileSolarPanel;
*/
public class BlockSolarPanel extends BaseTileBlock {
public static final String[] panes = new String[] {
"basic", "hybrid", "advanced", "ultimate", "quantum"};
public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumPanelType.class);
"Basic", "Hybrid", "Advanced", "Ultimate", "Quantum"};
public static final IProperty<EnumPanelType> TYPE = PropertyEnum.create("type", EnumPanelType.class);
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));
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]));
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/generators").setInvVariant("type=" + panes[i]));
}
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(TYPE).ordinal();
}
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[]{TYPE});
}
@ -74,21 +86,31 @@ public class BlockSolarPanel extends BaseTileBlock {
}
@Override
public int getMetaFromState(IBlockState state) {
EnumPanelType type = (EnumPanelType) state.getValue(TYPE);
return type.getID();
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileSolarPanel();
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileSolarPanel();
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
return getStateFromMeta(placer.getHeldItem(hand).getItemDamage());
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(Item.getItemFromBlock(this),1,getMetaFromState(world.getBlockState(pos)));
}
@Override
public int damageDropped(IBlockState state) {
return getMetaFromState(state);
}
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (EnumPanelType panelType : EnumPanelType.values()) {
list.add(new ItemStack(this, 1, panelType.ordinal()));
System.out.println((new ItemStack(this, 1, panelType.ordinal())) + "daad");
}
}
}