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

126 lines
3.9 KiB
Java
Raw Normal View History

2015-11-30 00:04:50 +00:00
package WayofTime.bloodmagic.block;
2016-03-18 17:16:38 +00:00
import java.util.List;
import java.util.Random;
2015-11-30 00:04:50 +00:00
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.particle.ParticleManager;
2015-11-30 00:04:50 +00:00
import net.minecraft.entity.Entity;
2016-03-18 17:16:38 +00:00
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumParticleTypes;
2016-03-18 17:16:38 +00:00
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
2015-11-30 00:04:50 +00:00
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2016-03-18 17:16:38 +00:00
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModItems;
2015-11-30 00:04:50 +00:00
public class BlockBloodLight extends Block
{
2016-03-18 17:16:38 +00:00
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.4, 0.4, 0.4, 0.6, 0.6, 0.6);
public BlockBloodLight()
{
2016-04-24 17:06:28 +00:00
super(Material.CLOTH);
2015-11-30 00:04:50 +00:00
setUnlocalizedName(Constants.Mod.MODID + ".bloodLight");
}
@Override
2016-03-18 17:16:38 +00:00
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
2016-03-18 17:16:38 +00:00
2015-11-30 00:04:50 +00:00
}
@Override
public boolean isReplaceable(IBlockAccess world, BlockPos pos)
{
return true;
}
2015-11-30 00:04:50 +00:00
@Override
@SideOnly(Side.CLIENT)
2016-03-18 17:16:38 +00:00
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
{
2016-03-18 17:16:38 +00:00
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
2016-03-18 17:16:38 +00:00
@Override
public boolean isFullCube(IBlockState state)
{
return false;
2015-11-30 00:04:50 +00:00
}
@Override
2016-03-18 17:16:38 +00:00
public boolean isVisuallyOpaque()
{
2015-11-30 00:04:50 +00:00
return false;
}
@Override
2016-03-18 17:16:38 +00:00
public int getLightValue(IBlockState state)
{
2015-11-30 00:04:50 +00:00
return 15;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager)
{
if (world.getBlockState(pos).getBlock() == this)
{
2015-11-30 00:04:50 +00:00
Random random = new Random();
particleManager.spawnEffectParticle(EnumParticleTypes.REDSTONE.getParticleID(), pos.getX() + 0.5D + random.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + random.nextGaussian() / 8, 0, 0, 0);
2015-11-30 00:04:50 +00:00
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
2016-03-18 17:16:38 +00:00
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
{
EntityPlayerSP playerSP = Minecraft.getMinecraft().thePlayer;
if (rand.nextInt(3) != 0)
{
2016-03-18 17:16:38 +00:00
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
if (playerSP.getActiveItemStack() != null && playerSP.getActiveItemStack().getItem() == ModItems.sigilBloodLight)
2016-03-16 22:41:06 +00:00
{
2016-03-18 17:16:38 +00:00
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
}
2015-11-30 00:04:50 +00:00
}
}
@Override
2016-03-18 17:16:38 +00:00
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
2016-03-18 17:16:38 +00:00
return AABB;
2015-11-30 00:04:50 +00:00
}
@Override
public int quantityDropped(Random par1Random)
{
2015-11-30 00:04:50 +00:00
return 0;
}
}