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

114 lines
3.9 KiB
Java
Raw Normal View History

2015-11-29 19:04:50 -05:00
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
2017-08-15 21:30:48 -07:00
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
2015-11-29 19:04:50 -05: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;
2016-03-18 13:16:38 -04:00
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumParticleTypes;
2016-03-18 13:16:38 -04:00
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
2015-11-29 19:04:50 -05:00
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
2017-08-15 21:30:48 -07:00
import java.util.Random;
2017-08-15 21:30:48 -07:00
public class BlockBloodLight extends Block {
2016-03-18 13:16:38 -04:00
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.4, 0.4, 0.4, 0.6, 0.6, 0.6);
2017-08-15 21:30:48 -07:00
public BlockBloodLight() {
2016-04-24 10:06:28 -07:00
super(Material.CLOTH);
2015-11-29 19:04:50 -05:00
setUnlocalizedName(BloodMagic.MODID + ".bloodLight");
2015-11-29 19:04:50 -05:00
}
@Nullable
2015-11-29 19:04:50 -05:00
@Override
2017-08-15 21:30:48 -07:00
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return null;
}
2016-03-18 13:16:38 -04:00
@Override
2017-08-15 21:30:48 -07:00
public boolean isCollidable() {
return false;
2015-11-29 19:04:50 -05:00
}
@Override
2017-08-15 21:30:48 -07:00
public boolean isReplaceable(IBlockAccess world, BlockPos pos) {
return true;
}
2015-11-29 19:04:50 -05:00
@Override
@SideOnly(Side.CLIENT)
2017-08-15 21:30:48 -07:00
public BlockRenderLayer getBlockLayer() {
2016-03-18 13:16:38 -04:00
return BlockRenderLayer.CUTOUT;
}
@Override
2017-08-15 21:30:48 -07:00
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
2016-03-18 13:16:38 -04:00
return false;
}
@Override
2017-08-15 21:30:48 -07:00
public boolean isOpaqueCube(IBlockState state) {
return false;
}
2016-03-18 13:16:38 -04:00
@Override
2017-08-15 21:30:48 -07:00
public boolean isFullCube(IBlockState state) {
2016-03-18 13:16:38 -04:00
return false;
2015-11-29 19:04:50 -05:00
}
@Override
2017-08-15 21:30:48 -07:00
public boolean causesSuffocation(IBlockState state) {
2015-11-29 19:04:50 -05:00
return false;
}
@Override
2017-08-15 21:30:48 -07:00
public int getLightValue(IBlockState state) {
2015-11-29 19:04:50 -05:00
return 15;
}
@Override
@SideOnly(Side.CLIENT)
2017-08-15 21:30:48 -07:00
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager) {
if (world.getBlockState(pos).getBlock() == this) {
2015-11-29 19:04:50 -05: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-29 19:04:50 -05:00
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
2017-08-15 21:30:48 -07:00
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
2017-01-01 21:43:34 -08:00
EntityPlayerSP playerSP = Minecraft.getMinecraft().player;
2017-08-15 21:30:48 -07:00
if (rand.nextInt(3) != 0) {
2016-03-18 13:16:38 -04: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);
2017-08-15 21:30:48 -07:00
if (!playerSP.getActiveItemStack().isEmpty() && playerSP.getActiveItemStack().getItem() == RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT) {
2016-03-18 13:16:38 -04: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-29 19:04:50 -05:00
}
}
@Override
2017-08-15 21:30:48 -07:00
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
2016-03-18 13:16:38 -04:00
return AABB;
2015-11-29 19:04:50 -05:00
}
@Override
2017-08-15 21:30:48 -07:00
public int quantityDropped(Random par1Random) {
2015-11-29 19:04:50 -05:00
return 0;
}
}