BloodMagic/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java

115 lines
3.1 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
2016-03-18 13:16:38 -04:00
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
2016-03-18 13:16:38 -04:00
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
2016-03-18 13:16:38 -04:00
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
2016-03-18 13:16:38 -04:00
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockStringContainer;
import WayofTime.bloodmagic.tile.TilePlinth;
import WayofTime.bloodmagic.util.Utils;
public class BlockPedestal extends BlockStringContainer
{
public static String[] names = { "pedestal", "plinth" };
public BlockPedestal()
{
2016-04-24 10:06:28 -07:00
super(Material.ROCK, names);
setUnlocalizedName(Constants.Mod.MODID + ".");
setCreativeTab(BloodMagic.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
2016-03-18 13:16:38 -04:00
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
switch (getMetaFromState(state))
{
case 0:
{
// TileEntity plinth = world.getTileEntity(pos);
//
// if (plinth!= null && plinth instanceof TilePlinth) {
// Utils.insertItemToTile((TilePlinth) plinth, player);
// }
}
case 1:
{
TileEntity plinth = world.getTileEntity(pos);
if (plinth == null || player.isSneaking())
return false;
if (plinth instanceof TilePlinth)
{
Utils.insertItemToTile((TilePlinth) plinth, player);
return true;
}
}
}
2016-03-18 13:16:38 -04:00
world.notifyBlockUpdate(pos, state, state, 3);
return false;
}
2016-03-18 13:16:38 -04:00
// @Override
// public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos)
// {
// IBlockState state = blockAccess.getBlockState(pos);
//
// if (getMetaFromState(state) == 0)
// setBlockBounds(0.5F - 0.3125F, 0.0F, 0.5F - 0.3125F, 0.5F + 0.3125F, 0.6F, 0.5F + 0.3125F);
// else if (getMetaFromState(state) == 1)
// setBlockBounds(0.1F, 0.0F, 0.1F, 1.0F - 0.1F, 0.8F, 1.0F - 0.1F);
//
// }
@Override
2016-03-18 13:16:38 -04:00
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
{
2016-03-18 13:16:38 -04:00
return false;
}
@Override
2016-03-18 13:16:38 -04:00
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
2016-03-18 13:16:38 -04:00
public boolean isVisuallyOpaque()
{
return false;
}
2016-03-18 13:16:38 -04:00
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return meta == 0 ? null : new TilePlinth();
}
}