2014-04-11 13:06:32 +02:00
|
|
|
package com.pahimar.ee3.block;
|
|
|
|
|
2014-04-30 03:46:59 +02:00
|
|
|
import com.pahimar.ee3.EquivalentExchange3;
|
2014-09-19 21:55:28 +02:00
|
|
|
import com.pahimar.ee3.reference.GUIs;
|
2014-04-11 13:06:32 +02:00
|
|
|
import com.pahimar.ee3.reference.Names;
|
|
|
|
import com.pahimar.ee3.reference.RenderIds;
|
2014-04-30 03:46:59 +02:00
|
|
|
import com.pahimar.ee3.tileentity.TileEntityAludel;
|
|
|
|
import com.pahimar.ee3.tileentity.TileEntityEE;
|
|
|
|
import com.pahimar.ee3.tileentity.TileEntityGlassBell;
|
2014-04-11 13:06:32 +02:00
|
|
|
import net.minecraft.block.ITileEntityProvider;
|
|
|
|
import net.minecraft.block.material.Material;
|
2014-04-30 03:46:59 +02:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-04-11 13:06:32 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-04-30 03:46:59 +02:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
2014-04-11 13:06:32 +02:00
|
|
|
import net.minecraft.world.World;
|
2014-04-30 03:46:59 +02:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-04-11 13:06:32 +02:00
|
|
|
|
|
|
|
public class BlockGlassBell extends BlockEE implements ITileEntityProvider
|
|
|
|
{
|
|
|
|
public BlockGlassBell()
|
|
|
|
{
|
|
|
|
super(Material.glass);
|
|
|
|
this.setHardness(1.0f);
|
|
|
|
this.setBlockName(Names.Blocks.GLASS_BELL);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-11 22:01:11 +02:00
|
|
|
public TileEntity createNewTileEntity(World world, int metaData)
|
2014-04-11 13:06:32 +02:00
|
|
|
{
|
2014-04-30 03:46:59 +02:00
|
|
|
return new TileEntityGlassBell();
|
2014-04-11 13:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderAsNormalBlock()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
|
|
|
return RenderIds.glassBell;
|
|
|
|
}
|
2014-04-30 03:46:59 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell)
|
|
|
|
{
|
|
|
|
TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z);
|
|
|
|
|
|
|
|
return tileEntityGlassBell.getState();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
|
|
|
{
|
|
|
|
if (player.isSneaking())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
|
|
|
if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell)
|
|
|
|
{
|
|
|
|
if (world.getTileEntity(x, y - 1, z) instanceof TileEntityAludel)
|
|
|
|
{
|
2014-09-19 21:55:28 +02:00
|
|
|
player.openGui(EquivalentExchange3.instance, GUIs.ALUDEL.ordinal(), world, x, y - 1, z);
|
2014-04-30 03:46:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-19 21:55:28 +02:00
|
|
|
player.openGui(EquivalentExchange3.instance, GUIs.GLASS_BELL.ordinal(), world, x, y, z);
|
2014-04-30 03:46:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
|
|
|
{
|
|
|
|
if (itemStack.hasDisplayName())
|
|
|
|
{
|
|
|
|
((TileEntityEE) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (world.getTileEntity(x, y - 1, z) != null && world.getTileEntity(x, y - 1, z) instanceof TileEntityAludel)
|
|
|
|
{
|
|
|
|
((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(ForgeDirection.UP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
|
|
|
|
}
|
|
|
|
|
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
|
|
|
|
{
|
|
|
|
return sideHit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
|
|
|
|
* x, y, z, startVec, endVec
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
|
|
|
|
{
|
|
|
|
if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell)
|
|
|
|
{
|
|
|
|
TileEntityGlassBell tileGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z);
|
|
|
|
|
|
|
|
switch (tileGlassBell.getOrientation())
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UP:
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.66F, 0.875F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NORTH:
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.125F, 0.125F, 0.33F, 0.875F, 0.875F, 1.0F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SOUTH:
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 0.66F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EAST:
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.0F, 0.125F, 0.125F, 0.66F, 0.875F, 0.875F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WEST:
|
|
|
|
{
|
|
|
|
this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UNKNOWN:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
|
|
|
|
}
|
2014-04-11 13:06:32 +02:00
|
|
|
}
|