Search in sources :

Example 1 with SkinItem

use of ladysnake.gaspunk.item.SkinItem in project Gaspunk by Ladysnake.

the class EntityGrenade method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (world.isRemote)
        return;
    int countdown = getCountdown();
    if (countdown == 1)
        explode();
    setCountdown(getCountdown() - 1);
    // after exploding, the countdown is used to track the time before cloud expiration
    if (countdown <= -cloudMaxLifeSpan) {
        if (canPickup) {
            ItemStack stack = getGrenade();
            ItemGrenade grenadeItem = (ItemGrenade) stack.getItem();
            ItemStack emptyGrenade = new ItemStack(ModItems.EMPTY_GRENADE);
            ((SkinItem) ModItems.EMPTY_GRENADE).setSkin(emptyGrenade, grenadeItem.getSkin(stack));
            world.spawnEntity(new EntityItem(world, posX, posY, posZ, emptyGrenade));
        }
        setDead();
    }
}
Also used : ItemGrenade(ladysnake.gaspunk.item.ItemGrenade) SkinItem(ladysnake.gaspunk.item.SkinItem) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

ItemGrenade (ladysnake.gaspunk.item.ItemGrenade)1 SkinItem (ladysnake.gaspunk.item.SkinItem)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1