2013-06-07 21:36:52 +00:00
|
|
|
package biomesoplenty.blocks;
|
|
|
|
|
|
|
|
import java.util.List;
|
2013-06-14 23:37:47 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2013-06-07 21:36:52 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2013-06-15 08:46:50 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2013-06-16 06:27:08 +00:00
|
|
|
import net.minecraft.entity.boss.EntityDragon;
|
2013-06-15 03:18:19 +00:00
|
|
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
2013-06-16 06:27:08 +00:00
|
|
|
import net.minecraft.entity.item.EntityTNTPrimed;
|
2013-06-15 08:46:50 +00:00
|
|
|
import net.minecraft.entity.passive.EntityVillager;
|
2013-06-15 03:18:19 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-06-07 21:36:52 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-06-15 08:46:50 +00:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2013-06-07 21:36:52 +00:00
|
|
|
import net.minecraft.util.Icon;
|
2013-06-14 23:37:47 +00:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2013-06-15 03:18:19 +00:00
|
|
|
import net.minecraft.world.World;
|
2013-06-07 21:36:52 +00:00
|
|
|
import biomesoplenty.BiomesOPlenty;
|
2013-06-15 03:18:19 +00:00
|
|
|
import biomesoplenty.api.Blocks;
|
|
|
|
import biomesoplenty.api.Items;
|
2013-10-18 23:57:56 +00:00
|
|
|
import biomesoplenty.configuration.BOPAchievements;
|
2013-07-03 07:51:39 +00:00
|
|
|
import biomesoplenty.tileentities.TileEntityAltar;
|
2013-07-01 00:31:34 +00:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-06-07 21:36:52 +00:00
|
|
|
|
|
|
|
public class BlockBOPGlass extends Block
|
|
|
|
{
|
2013-07-03 05:43:41 +00:00
|
|
|
private static final String[] glassTypes = new String[] {"celestiallens", "sacrificialfocus_empty", "sacrificialfocus_active", "sacrificialfocus_villager"};
|
2013-06-07 21:36:52 +00:00
|
|
|
private Icon[] textures;
|
|
|
|
|
|
|
|
public BlockBOPGlass(int blockID)
|
|
|
|
{
|
|
|
|
super(blockID, Material.glass);
|
|
|
|
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
|
|
|
|
|
|
|
this.blockHardness = 0.37F;
|
|
|
|
}
|
2013-06-14 23:37:47 +00:00
|
|
|
|
2013-06-15 08:46:50 +00:00
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if (world.getBlockMetadata(x, y, z) == 2)
|
|
|
|
{
|
|
|
|
float var5 = 0.01F;
|
|
|
|
return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1 - var5, z + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1, z + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
|
|
|
{
|
|
|
|
if (world.getBlockMetadata(x, y, z) == 2)
|
|
|
|
{
|
|
|
|
if (checkAltarStructreIntegrity(world, x, y, z))
|
|
|
|
{
|
|
|
|
if (entity instanceof EntityVillager)
|
|
|
|
{
|
2013-06-15 10:39:13 +00:00
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
2013-06-15 08:46:50 +00:00
|
|
|
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x + 1, y + 2, z));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x -1, y + 2, z));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z + 1));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z - 1));
|
|
|
|
|
|
|
|
entity.setDead();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-15 03:18:19 +00:00
|
|
|
@Override
|
2013-06-16 00:30:58 +00:00
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float par7, float par8, float par9)
|
2013-06-15 03:18:19 +00:00
|
|
|
{
|
|
|
|
ItemStack equippedItem = player.getCurrentEquippedItem();
|
2013-06-16 00:30:58 +00:00
|
|
|
Random rand = new Random();
|
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
if (equippedItem != null)
|
2013-06-15 03:18:19 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (equippedItem.itemID == Items.soulManipulator.get().itemID)
|
2013-06-15 03:18:19 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (equippedItem.getItemDamage() == 0)
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (world.getBlockMetadata(x, y, z) == 2)
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (checkAltarStructreIntegrity(world, x, y, z))
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 1));
|
|
|
|
}
|
2013-06-16 06:27:08 +00:00
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
2013-06-16 06:27:08 +00:00
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
return true;
|
2013-06-16 00:30:58 +00:00
|
|
|
}
|
2013-06-15 11:19:57 +00:00
|
|
|
}
|
2013-07-14 10:03:06 +00:00
|
|
|
else if (world.getBlockMetadata(x, y, z) == 3)
|
2013-06-16 00:30:58 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (checkAltarStructreIntegrity(world, x, y, z))
|
2013-06-16 00:30:58 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 2));
|
|
|
|
}
|
2013-06-15 03:18:19 +00:00
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
FMLClientHandler.instance().getClient().sndManager.playSound("mob.villager.idle", (float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, 1.0F, 1.0F);
|
2013-06-16 00:30:58 +00:00
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
2013-06-15 03:18:19 +00:00
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-06-15 08:46:50 +00:00
|
|
|
}
|
2013-07-14 10:03:06 +00:00
|
|
|
else if (equippedItem.getItemDamage() == 1)
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (world.getBlockMetadata(x, y, z) == 1)
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (checkAltarStructreIntegrity(world, x, y, z))
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-07-14 10:03:06 +00:00
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 0));
|
|
|
|
}
|
2013-06-16 06:27:08 +00:00
|
|
|
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x + 1, y + 2, z));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x -1, y + 2, z));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z + 1));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z - 1));
|
|
|
|
|
2013-07-14 10:03:06 +00:00
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (world.getBlockMetadata(x, y, z) == 3)
|
|
|
|
{
|
2013-08-17 00:36:47 +00:00
|
|
|
if (player.dimension == 1)
|
2013-07-14 10:03:06 +00:00
|
|
|
{
|
2013-08-14 20:38:34 +00:00
|
|
|
if (checkAltarStructreIntegrity(world, x, y, z))
|
2013-06-16 06:27:08 +00:00
|
|
|
{
|
2013-08-14 20:38:34 +00:00
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 0));
|
|
|
|
}
|
2013-06-16 06:27:08 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 1, z));
|
2013-07-14 10:03:06 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
if (world.isRemote)
|
|
|
|
{
|
|
|
|
FMLClientHandler.instance().getClient().sndManager.playSound("mob.wither.death", (float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, 5.0F, 10.0F);
|
|
|
|
FMLClientHandler.instance().getClient().sndManager.playSound("mob.enderdragon.growl", (float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, 5.0F, 1.0F);
|
|
|
|
}
|
|
|
|
|
2013-10-18 23:57:56 +00:00
|
|
|
player.addStat(BOPAchievements.achSacrifice, 1);
|
2013-07-14 10:03:06 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
|
|
|
world.spawnEntityInWorld(new EntityDragon(world));
|
2013-07-14 10:03:06 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
2013-07-14 10:03:06 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
Entity entitytnt = new EntityTNTPrimed(world);
|
2013-07-14 10:03:06 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
world.createExplosion(entitytnt, (double)x, (double)y, (double)z, 10.0F, true);
|
|
|
|
}
|
2013-06-16 06:27:08 +00:00
|
|
|
|
2013-08-14 20:38:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-06-16 06:27:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-14 10:03:06 +00:00
|
|
|
if (equippedItem.getItemDamage() == 2)
|
|
|
|
{
|
|
|
|
if (world.getBlockMetadata(x, y, z) == 2)
|
|
|
|
{
|
|
|
|
if (checkAltarStructreIntegrity(world, x, y, z))
|
|
|
|
{
|
|
|
|
if (player.dimension != 1)
|
|
|
|
{
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x + 1, y + 2, z));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x -1, y + 2, z));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z + 1));
|
|
|
|
world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z - 1));
|
|
|
|
|
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-15 03:18:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean checkAltarStructreIntegrity(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
TileEntityAltar tileentityaltar0 = (TileEntityAltar) world.getBlockTileEntity(x + 1, y, z);
|
|
|
|
TileEntityAltar tileentityaltar1 = (TileEntityAltar) world.getBlockTileEntity(x - 1, y, z);
|
|
|
|
TileEntityAltar tileentityaltar2 = (TileEntityAltar) world.getBlockTileEntity(x, y, z + 1);
|
|
|
|
TileEntityAltar tileentityaltar3 = (TileEntityAltar) world.getBlockTileEntity(x, y, z - 1);
|
|
|
|
|
2013-06-15 08:46:50 +00:00
|
|
|
if (tileentityaltar0 != null && tileentityaltar1 != null && tileentityaltar2 != null && tileentityaltar3 != null)
|
2013-06-15 03:18:19 +00:00
|
|
|
if (tileentityaltar0.getAllPresent() && tileentityaltar1.getAllPresent() && tileentityaltar2.getAllPresent() && tileentityaltar3.getAllPresent())
|
|
|
|
{
|
|
|
|
if (world.getBlockId(x + 1, y + 1, z) == Blocks.bones.get().blockID && world.getBlockId(x - 1, y + 1, z) == Blocks.bones.get().blockID && world.getBlockId(x, y + 1, z + 1) == Blocks.bones.get().blockID && world.getBlockId(x, y + 1, z - 1) == Blocks.bones.get().blockID)
|
|
|
|
{
|
|
|
|
if (world.getBlockMetadata(x + 1, y + 1, z) == 1 && world.getBlockMetadata(x - 1, y + 1, z) == 1 && world.getBlockMetadata(x, y + 1, z + 1) == 1 && world.getBlockMetadata(x, y + 1, z - 1) == 1)
|
|
|
|
{
|
|
|
|
if (world.getBlockId(x + 1, y + 2, z) == Blocks.bones.get().blockID && world.getBlockId(x - 1, y + 2, z) == Blocks.bones.get().blockID && world.getBlockId(x, y + 2, z + 1) == Blocks.bones.get().blockID && world.getBlockId(x, y + 2, z - 1) == Blocks.bones.get().blockID)
|
|
|
|
{
|
|
|
|
if (world.getBlockMetadata(x + 1, y + 2, z) == 0 && world.getBlockMetadata(x - 1, y + 2, z) == 0 && world.getBlockMetadata(x, y + 2, z + 1) == 0 && world.getBlockMetadata(x, y + 2, z - 1) == 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-15 11:19:57 +00:00
|
|
|
@Override
|
|
|
|
public int getDamageValue(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
|
|
|
|
if (meta == 2 || meta == 3)
|
|
|
|
{
|
|
|
|
meta = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return meta;
|
|
|
|
}
|
|
|
|
|
2013-07-01 00:31:34 +00:00
|
|
|
@Override
|
|
|
|
public int quantityDropped(Random par1Random)
|
2013-06-14 23:37:47 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-01 00:31:34 +00:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-06-14 23:37:47 +00:00
|
|
|
public int getRenderBlockPass()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
|
|
|
{
|
|
|
|
return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, 1 - par5);
|
|
|
|
}
|
|
|
|
|
2013-07-01 00:31:34 +00:00
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
2013-06-14 23:37:47 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-01 00:31:34 +00:00
|
|
|
@Override
|
|
|
|
protected boolean canSilkHarvest()
|
2013-06-14 23:37:47 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-06-07 21:36:52 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister iconRegister)
|
|
|
|
{
|
|
|
|
textures = new Icon[glassTypes.length];
|
|
|
|
|
|
|
|
for (int i = 0; i < glassTypes.length; ++i) {
|
2013-07-03 06:01:28 +00:00
|
|
|
textures[i] = iconRegister.registerIcon("biomesoplenty:"+glassTypes[i]);
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Icon getIcon(int side, int meta)
|
|
|
|
{
|
|
|
|
if (meta < 0 || meta >= textures.length) {
|
|
|
|
meta = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return textures[meta];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
2013-06-15 08:46:50 +00:00
|
|
|
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < glassTypes.length; ++i)
|
|
|
|
{
|
2013-06-15 10:39:13 +00:00
|
|
|
if (i != 2 && i != 3)
|
2013-06-15 08:46:50 +00:00
|
|
|
list.add(new ItemStack(blockID, 1, i));
|
2013-06-07 21:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int damageDropped(int meta)
|
|
|
|
{
|
|
|
|
return meta;
|
|
|
|
}
|
|
|
|
}
|