2013-11-02 22:24:47 -07:00
|
|
|
package tconstruct.blocks;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2014-01-16 01:36:18 -05:00
|
|
|
import mantle.world.WorldHelper;
|
2013-12-31 11:26:08 -05:00
|
|
|
import net.minecraft.block.Block;
|
2013-11-02 22:24:47 -07:00
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
|
import net.minecraft.entity.item.EntityTNTPrimed;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.entity.projectile.EntityArrow;
|
2014-01-01 08:54:06 -05:00
|
|
|
import net.minecraft.init.Items;
|
2013-11-02 22:24:47 -07:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
2013-12-31 11:26:08 -05:00
|
|
|
import net.minecraft.util.IIcon;
|
2013-11-02 22:24:47 -07:00
|
|
|
import net.minecraft.world.Explosion;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import tconstruct.entity.item.ExplosivePrimed;
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
|
|
public class SlimeExplosive extends TConstructBlock
|
|
|
|
|
{
|
|
|
|
|
|
2013-12-31 11:26:08 -05:00
|
|
|
public SlimeExplosive()
|
2013-11-02 22:24:47 -07:00
|
|
|
{
|
2013-12-31 11:26:08 -05:00
|
|
|
super(Material.tnt, 0f, getTextureNames());
|
2013-11-02 22:24:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String[] getTextureNames ()
|
|
|
|
|
{
|
|
|
|
|
String[] names = new String[6];
|
|
|
|
|
String[] types = new String[] { "green", "blue" };
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
names[i * 3 + 0] = "sdx_bottom_" + types[i];
|
|
|
|
|
names[i * 3 + 1] = "sdx_side_" + types[i];
|
|
|
|
|
names[i * 3 + 2] = "sdx_top_" + types[i];
|
|
|
|
|
}
|
|
|
|
|
return names;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-31 11:26:08 -05:00
|
|
|
public IIcon getIcon (int side, int meta)
|
2013-11-02 22:24:47 -07:00
|
|
|
{
|
|
|
|
|
return icons[(meta / 2) * 3 + getSideTextureIndex(side)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2013-12-31 11:26:08 -05:00
|
|
|
public void getSubBlocks (Block b, CreativeTabs tab, List list)
|
2013-11-02 22:24:47 -07:00
|
|
|
{
|
|
|
|
|
for (int iter = 0; iter < 2; iter++)
|
|
|
|
|
{
|
2013-12-31 11:26:08 -05:00
|
|
|
list.add(new ItemStack(b, 1, iter * 2));
|
2013-11-02 22:24:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBlockAdded (World par1World, int par2, int par3, int par4)
|
|
|
|
|
{
|
|
|
|
|
super.onBlockAdded(par1World, par2, par3, par4);
|
|
|
|
|
|
|
|
|
|
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
|
|
|
|
|
{
|
|
|
|
|
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
|
2014-01-16 01:36:18 -05:00
|
|
|
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
2013-11-02 22:24:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
|
|
|
|
|
{
|
|
|
|
|
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
|
|
|
|
|
{
|
|
|
|
|
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
|
2014-01-16 01:36:18 -05:00
|
|
|
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
2013-11-02 22:24:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBlockDestroyedByExplosion (World par1World, int par2, int par3, int par4, Explosion par5Explosion)
|
|
|
|
|
{
|
|
|
|
|
if (!par1World.isRemote)
|
|
|
|
|
{
|
|
|
|
|
ExplosivePrimed entitytntprimed = new ExplosivePrimed(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F),
|
|
|
|
|
par5Explosion.getExplosivePlacedBy());
|
|
|
|
|
entitytntprimed.fuse = par1World.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
|
|
|
|
|
par1World.spawnEntityInWorld(entitytntprimed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBlockDestroyedByPlayer (World par1World, int par2, int par3, int par4, int par5)
|
|
|
|
|
{
|
|
|
|
|
this.primeTnt(par1World, par2, par3, par4, par5, (EntityLivingBase) null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void primeTnt (World par1World, int par2, int par3, int par4, int par5, EntityLivingBase par6EntityLivingBase)
|
|
|
|
|
{
|
|
|
|
|
if (!par1World.isRemote)
|
|
|
|
|
{
|
|
|
|
|
if ((par5 % 2) == 1)
|
|
|
|
|
{
|
|
|
|
|
ExplosivePrimed entitytntprimed = new ExplosivePrimed(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), par6EntityLivingBase);
|
|
|
|
|
par1World.spawnEntityInWorld(entitytntprimed);
|
|
|
|
|
par1World.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
|
|
|
|
{
|
2014-01-10 21:14:54 -05:00
|
|
|
if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel)
|
2013-11-02 22:24:47 -07:00
|
|
|
{
|
|
|
|
|
this.primeTnt(par1World, par2, par3, par4, 1, par5EntityPlayer);
|
2014-01-16 01:36:18 -05:00
|
|
|
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
2013-11-02 22:24:47 -07:00
|
|
|
par5EntityPlayer.getCurrentEquippedItem().damageItem(1, par5EntityPlayer);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
|
|
|
|
{
|
|
|
|
|
if (par5Entity instanceof EntityArrow && !par1World.isRemote)
|
|
|
|
|
{
|
|
|
|
|
EntityArrow entityarrow = (EntityArrow) par5Entity;
|
|
|
|
|
|
|
|
|
|
if (entityarrow.isBurning())
|
|
|
|
|
{
|
|
|
|
|
this.primeTnt(par1World, par2, par3, par4, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null);
|
2014-01-16 01:36:18 -05:00
|
|
|
WorldHelper.setBlockToAir(par1World,par2, par3, par4);
|
2013-11-02 22:24:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canDropFromExplosion (Explosion par1Explosion)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|