BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/block/BlockSpectral.java

96 lines
2.6 KiB
Java
Raw Normal View History

package WayofTime.alchemicalWizardry.common.block;
2014-10-13 22:33:20 +02:00
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralBlock;
import net.minecraft.block.Block;
2014-07-31 19:45:40 -04:00
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
2015-07-29 14:35:00 -04:00
import net.minecraft.block.state.IBlockState;
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;
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;
2015-07-29 11:30:24 -04:00
public class BlockSpectral extends BlockContainer
{
2015-07-29 11:30:24 -04:00
public BlockSpectral()
{
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);
}
@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)
{
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);
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();
}
}