2015-03-11 21:34:37 +01:00
|
|
|
package com.pahimar.ee3.block;
|
|
|
|
|
2015-03-19 02:52:53 +01:00
|
|
|
import com.pahimar.ee3.EquivalentExchange3;
|
|
|
|
import com.pahimar.ee3.init.ModBlocks;
|
|
|
|
import com.pahimar.ee3.reference.GUIs;
|
2015-03-11 21:34:37 +01:00
|
|
|
import com.pahimar.ee3.reference.Names;
|
|
|
|
import com.pahimar.ee3.reference.RenderIds;
|
|
|
|
import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet;
|
|
|
|
import net.minecraft.block.material.Material;
|
2015-03-19 02:52:53 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
2015-03-11 21:34:37 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2015-03-19 04:33:09 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2015-03-11 21:34:37 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-03-19 02:52:53 +01:00
|
|
|
import java.util.Random;
|
|
|
|
|
2015-05-28 03:37:55 +02:00
|
|
|
public class BlockTransmutationTablet extends BlockTileEntityEE
|
2015-03-11 21:34:37 +01:00
|
|
|
{
|
|
|
|
public BlockTransmutationTablet()
|
|
|
|
{
|
|
|
|
super(Material.rock);
|
2015-03-19 03:22:13 +01:00
|
|
|
setCreativeTab(null);
|
2015-03-11 21:34:37 +01:00
|
|
|
this.setHardness(2.0f);
|
|
|
|
this.setBlockName(Names.Blocks.TRANSMUTATION_TABLET);
|
2015-03-19 02:52:53 +01:00
|
|
|
}
|
|
|
|
|
2015-03-19 04:33:09 +01:00
|
|
|
@Override
|
|
|
|
public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if (isStructureValid(iBlockAccess, x, y, z))
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0f, 0f, 0f, 1f, 0.625f, 1f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-19 02:52:53 +01:00
|
|
|
@Override
|
|
|
|
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
|
|
|
{
|
|
|
|
return Item.getItemFromBlock(ModBlocks.ashInfusedStoneSlab);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ)
|
|
|
|
{
|
|
|
|
if (entityPlayer.isSneaking())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
|
|
|
if (world.getTileEntity(x, y, z) instanceof TileEntityTransmutationTablet && isStructureValid(world, x, y, z))
|
|
|
|
{
|
|
|
|
entityPlayer.openGui(EquivalentExchange3.instance, GUIs.TRANSMUTATION_TABLET.ordinal(), world, x, y, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
|
|
|
|
{
|
|
|
|
return metaData;
|
|
|
|
}
|
|
|
|
|
2015-03-11 21:34:37 +01:00
|
|
|
@Override
|
|
|
|
public TileEntity createNewTileEntity(World world, int metaData)
|
|
|
|
{
|
|
|
|
return new TileEntityTransmutationTablet();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderAsNormalBlock()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
|
|
|
return RenderIds.tabletSlab;
|
|
|
|
}
|
2015-03-19 02:52:53 +01:00
|
|
|
|
2015-03-19 04:33:09 +01:00
|
|
|
private boolean isStructureValid(IBlockAccess iBlockAcces, int xCoord, int yCoord, int zCoord)
|
2015-03-19 02:52:53 +01:00
|
|
|
{
|
2015-03-19 04:33:09 +01:00
|
|
|
return ((iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord - 1) == 1) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord, yCoord, zCoord - 1) == 2) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord - 1) == 3) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord) == 4) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord) == 5) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord + 1) == 6) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord, yCoord, zCoord + 1) == 7) &&
|
|
|
|
(iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord + 1) == 8));
|
2015-03-19 02:52:53 +01:00
|
|
|
}
|
2015-03-11 21:34:37 +01:00
|
|
|
}
|