Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.battledamaged10.btech.blocks;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.properties.PropertyDirection;
- import net.minecraft.block.properties.PropertyInteger;
- import net.minecraft.block.state.BlockState;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemDye;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- public class BlockMonitor extends Block{
- public static final PropertyInteger COLOR = PropertyInteger.create("color", 0, 15);
- public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
- public BlockMonitor(Material materialIn) {
- super(materialIn);
- this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(COLOR, Integer.valueOf(0)));
- }
- @Override
- public boolean isOpaqueCube()
- {
- return false;
- }
- @Override
- public boolean isFullCube()
- {
- return false;
- }
- @Override
- public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
- ItemStack currentItem = player.getCurrentEquippedItem();
- if (currentItem != null){
- if (currentItem.getItem() instanceof ItemDye){
- world.setBlockState(pos, state.withProperty(COLOR, 15 - currentItem.getItemDamage()));
- currentItem.stackSize--;
- return true;
- }
- }
- return false;
- }
- @Override
- public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
- {
- IBlockState state = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, placer);
- state = state.withProperty(FACING, placer.getHorizontalFacing());
- return state.withProperty(COLOR, Integer.valueOf(0));
- }
- @Override
- public int getMetaFromState(IBlockState state)
- {
- return ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
- }
- @Override
- protected BlockState createBlockState()
- {
- return new BlockState(this, new IProperty[] { FACING, COLOR });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement