Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.reygok.octablocks.blocks;
- import java.util.List;
- import com.reygok.octablocks.OctablocksMod;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockDirt;
- import net.minecraft.block.BlockStairs;
- import net.minecraft.block.ITileEntityProvider;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.properties.PropertyBool;
- import net.minecraft.block.state.BlockState;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.EnumWorldBlockLayer;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import net.minecraftforge.common.property.ExtendedBlockState;
- import net.minecraftforge.common.property.IExtendedBlockState;
- import net.minecraftforge.common.property.IUnlistedProperty;
- import net.minecraftforge.common.property.Properties;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- public class TinyDirt extends Block implements ITileEntityProvider
- {
- public static final IUnlistedProperty<Boolean> BOT_NW = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("bottom_north_west"));
- public static final IUnlistedProperty<Boolean> BOT_NE = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("bottom_north_east"));
- public static final IUnlistedProperty<Boolean> BOT_SE = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("bottom_south_east"));
- public static final IUnlistedProperty<Boolean> BOT_SW = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("bottom_south_west"));
- public static final IUnlistedProperty<Boolean> TOP_NW = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("top_north_west"));
- public static final IUnlistedProperty<Boolean> TOP_NE = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("top_north_east"));
- public static final IUnlistedProperty<Boolean> TOP_SE = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("top_south_east"));
- public static final IUnlistedProperty<Boolean> TOP_SW = new Properties.PropertyAdapter<Boolean>(PropertyBool.create("top_south_west"));
- //public static final PropertyBool isFull = PropertyBool.create("isFull");
- private final String name = "tinyDirt";
- public TinyDirt()
- {
- super(Material.ground);
- setUnlocalizedName(OctablocksMod.MODID + "_" + name);
- setCreativeTab(CreativeTabs.tabBlock);
- setHarvestLevel("shovel", 0);
- setHardness(0.5F);
- setStepSound(soundTypeGravel);
- }
- @SideOnly(Side.CLIENT)
- public EnumWorldBlockLayer getBlockLayer()
- {
- return EnumWorldBlockLayer.SOLID;
- }
- public String getName()
- {
- return name;
- }
- public Object getVariant(ItemStack stack)
- {
- return BlockDirt.DirtType.byMetadata(stack.getMetadata() & 7);
- }
- @Override
- public TileEntity createNewTileEntity(World worldIn, int meta)
- {
- return new TileEntityTinyDirt();
- }
- @Override
- public void breakBlock(World world, BlockPos pos, IBlockState state) {
- super.breakBlock(world, pos, state);
- world.removeTileEntity(pos);
- }
- @Override
- public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) {
- super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
- TileEntity tileentity = worldIn.getTileEntity(pos);
- return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
- }
- @Override
- protected BlockState createBlockState() {
- IProperty [] listedProperties = new IProperty[] {}; // no listed properties
- IUnlistedProperty [] unlistedProperties = new IUnlistedProperty[] {BOT_NW, BOT_NE, BOT_SE, BOT_SW, TOP_NW, TOP_NE, TOP_SE, TOP_SW};
- return new ExtendedBlockState(this, listedProperties, unlistedProperties);
- }
- @Override
- public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
- if (state instanceof IExtendedBlockState) { // avoid crash in case of mismatch
- IExtendedBlockState stateExt = (IExtendedBlockState)state;
- TileEntityTinyDirt tileEntity = (TileEntityTinyDirt) world.getTileEntity(pos);
- boolean bot_nw = tileEntity.isBot_nw();
- boolean bot_ne = tileEntity.isBot_ne();
- boolean bot_se = tileEntity.isBot_se();
- boolean bot_sw = tileEntity.isBot_sw();
- boolean top_nw = tileEntity.isTop_nw();
- boolean top_ne = tileEntity.isTop_ne();
- boolean top_se = tileEntity.isTop_se();
- boolean top_sw = tileEntity.isTop_sw();
- return stateExt
- .withProperty(BOT_NW, bot_nw).withProperty(BOT_NE, bot_ne).withProperty(BOT_SE, bot_se) .withProperty(BOT_SW, bot_sw)
- .withProperty(TOP_NW, top_nw).withProperty(TOP_NE, top_ne).withProperty(TOP_SE, top_se) .withProperty(TOP_SW, top_sw);
- }
- return state;
- }
- @Override
- public boolean isReplaceable(World worldIn, BlockPos pos)
- {
- return true;
- }
- @Override
- public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity)
- {
- TileEntityTinyDirt tileEntity = (TileEntityTinyDirt) worldIn.getTileEntity(pos);
- boolean bot_nw = tileEntity.isBot_nw();
- boolean bot_ne = tileEntity.isBot_ne();
- boolean bot_se = tileEntity.isBot_se();
- boolean bot_sw = tileEntity.isBot_sw();
- boolean top_nw = tileEntity.isTop_nw();
- boolean top_ne = tileEntity.isTop_ne();
- boolean top_se = tileEntity.isTop_se();
- boolean top_sw = tileEntity.isTop_sw();
- if(bot_nw)
- {
- setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 0.5F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(bot_ne)
- {
- setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(bot_se)
- {
- setBlockBounds(0.5F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(bot_sw)
- {
- setBlockBounds(0.0F, 0.0F, 0.5F, 0.5F, 0.5F, 1.0F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(top_nw)
- {
- setBlockBounds(0.0F, 0.5F, 0.0F, 0.5F, 1.0F, 0.5F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(top_ne)
- {
- setBlockBounds(0.5F, 0.5F, 0.0F, 1.0F, 1.0F, 0.5F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(top_se)
- {
- setBlockBounds(0.5F, 0.5F, 0.5F, 1.0F, 1.0F, 1.0F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- if(top_sw)
- {
- setBlockBounds(0.0F, 0.5F, 0.5F, 0.5F, 1.0F, 1.0F);
- super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
- }
- }
- public boolean isOpaqueCube()
- {
- return false;
- }
- public boolean isFullCube()
- {
- return false;
- }
- public int quantityDropped()
- {
- return 1;
- }
- public Item getItemDropped(int par1, int par2)
- {
- return Item.getItemFromBlock(this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement