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

98 lines
3.3 KiB
Java
Raw Normal View History

2015-11-30 00:04:50 +00:00
package WayofTime.bloodmagic.block;
import java.util.List;
import java.util.Random;
import WayofTime.bloodmagic.registry.ModItems;
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;
2015-11-30 00:04:50 +00:00
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
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;
import WayofTime.bloodmagic.api.Constants;
2015-11-30 00:04:50 +00:00
public class BlockBloodLight extends Block
{
public BlockBloodLight()
{
2015-11-30 00:04:50 +00:00
super(Material.cloth);
setUnlocalizedName(Constants.Mod.MODID + ".bloodLight");
setRegistryName(Constants.BloodMagicBlock.BLOOD_LIGHT.getRegName());
2015-11-30 00:04:50 +00:00
}
@Override
public boolean isOpaqueCube()
{
2015-11-30 00:04:50 +00:00
return false;
}
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer()
{
2015-11-30 00:04:50 +00:00
return EnumWorldBlockLayer.CUTOUT;
}
@Override
public boolean isFullCube()
{
2015-11-30 00:04:50 +00:00
return false;
}
@Override
public int getLightValue()
{
2015-11-30 00:04:50 +00:00
return 15;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.EffectRenderer effectRenderer)
{
if (world.getBlockState(pos).getBlock() == this)
{
2015-11-30 00:04:50 +00:00
Random random = new Random();
effectRenderer.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)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
EntityPlayerSP playerSP = Minecraft.getMinecraft().thePlayer;
if (rand.nextInt(3) != 0)
{
worldIn.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.getHeldItem() != null && playerSP.getHeldItem().getItem() == ModItems.sigilBloodLight) {
worldIn.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);
worldIn.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);
worldIn.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
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity)
{
2015-11-30 00:04:50 +00:00
this.setBlockBounds(0.35F, 0.35F, 0.35F, 0.65F, 0.65F, 0.65F);
}
@Override
public int quantityDropped(Random par1Random)
{
2015-11-30 00:04:50 +00:00
return 0;
}
}