- 30
- 0
Есть код который выполняет некоторые действий при разрушении блока, но данный метод не работает.
Код:
package ua.crazy_dayv.new_craft.blocks;
import java.util.Random;
import ua.crazy_dayv.new_craft.ModInfo;
import ua.crazy_dayv.new_craft.items.Items;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class radiation_block extends Block
{
public radiation_block(String name)
{
super(Material.ground);
this.setBlockName(name);
this.setHardness(15F);
this.setResistance(10F);
this.setHarvestLevel("pickaxe", 1);
this.setLightLevel(150F);
this.setBlockTextureName(ModInfo.MODID + ":radiation_block");
}
public void onBlockDestroyed(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
if(par5EntityPlayer.getCurrentEquippedItem() != null)
{
if(par5EntityPlayer.getCurrentEquippedItem().getItem() != Items.coal_pickaxe)
{
par5EntityPlayer.addPotionEffect(new PotionEffect(9, 600, 1));
} else {
if (par5EntityPlayer.inventory.armorItemInSlot(3) != null && par5EntityPlayer.inventory.armorItemInSlot(2) != null && par5EntityPlayer.inventory.armorItemInSlot(1) != null && par5EntityPlayer.inventory.armorItemInSlot(0) != null && par5EntityPlayer.inventory.armorItemInSlot(3).getItem() == Items.coal_helmet && par5EntityPlayer.inventory.armorItemInSlot(2).getItem() == Items.coal_chest && par5EntityPlayer.inventory.armorItemInSlot(1).getItem() == Items.coal_leggings && par5EntityPlayer.inventory.armorItemInSlot(0).getItem() == Items.coal_boots)
{
par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.getItemById(263)));
}
}
} else {
par5EntityPlayer.addPotionEffect(new PotionEffect(9, 600, 1));
}
}
public boolean isOpaqueCube()
{
return false;
}
@Override
public Item getItemDropped(int par1, Random par2Random, int par3)
{
return null;
}
}