2014-06-27 19:43:09 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.block;
|
|
|
|
|
2014-10-13 22:33:20 +02:00
|
|
|
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralBlock;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.block.Block;
|
2014-07-31 19:45:40 -04:00
|
|
|
import net.minecraft.block.BlockContainer;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.block.material.Material;
|
2015-07-29 14:35:00 -04:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-07-31 19:45:40 -04:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2015-07-29 14:35:00 -04:00
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2014-07-31 19:45:40 -04:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.world.World;
|
2015-07-29 14:35:00 -04:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2014-10-13 22:33:20 +02:00
|
|
|
|
|
|
|
import java.util.Random;
|
2014-06-27 19:43:09 -04:00
|
|
|
|
2015-07-29 11:30:24 -04:00
|
|
|
public class BlockSpectral extends BlockContainer
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-29 11:30:24 -04:00
|
|
|
public BlockSpectral()
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
super(Material.rock);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int quantityDropped(Random par1Random)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2015-07-29 14:35:00 -04:00
|
|
|
@Override
|
2014-07-31 19:45:40 -04:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-07-29 14:35:00 -04:00
|
|
|
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, BlockPos blockPos, EnumFacing side)
|
2014-07-31 19:45:40 -04:00
|
|
|
{
|
2015-07-29 14:35:00 -04:00
|
|
|
Block block = p_149646_1_.getBlockState(blockPos).getBlock();
|
2014-07-31 19:45:40 -04:00
|
|
|
|
2015-07-29 14:35:00 -04:00
|
|
|
if (p_149646_1_.getBlockState(blockPos) != p_149646_1_.getBlockState(blockPos.add(-side.getFrontOffsetX(), -side.getFrontOffsetY(), -side.getFrontOffsetZ())))
|
2014-07-31 19:45:40 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block == this)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-29 14:35:00 -04:00
|
|
|
return block != this && super.shouldSideBeRendered(p_149646_1_, blockPos, side);
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-29 14:35:00 -04:00
|
|
|
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
if (player.isSneaking())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemStack playerItem = player.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
if (playerItem != null)
|
|
|
|
{
|
|
|
|
if (playerItem.getItem() instanceof ItemBlock)
|
|
|
|
{
|
2015-07-29 14:35:00 -04:00
|
|
|
world.addBlockEvent(blockPos, ((ItemBlock) playerItem.getItem()).getBlock(), playerItem.getItemDamage(), 3);
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
playerItem.stackSize--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-13 22:33:20 +02:00
|
|
|
@Override
|
|
|
|
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
|
|
|
|
{
|
|
|
|
return new TESpectralBlock();
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|