Search in sources :

Example 1 with EntityGrenade

use of ladysnake.gaspunk.entity.EntityGrenade in project Gaspunk by Ladysnake.

the class CommonProxy method init.

public void init() {
    PacketHandler.initPackets();
    if (GasPunkConfig.alternativeAshRecipe)
        GameRegistry.addSmelting(Items.NETHER_WART, new ItemStack(ModItems.ASH), 0.8f);
    else
        GameRegistry.addSmelting(Items.ROTTEN_FLESH, new ItemStack(ModItems.ASH), 0.35f);
    if (Loader.isModLoaded("baubles"))
        MinecraftForge.EVENT_BUS.register(new BaublesCompatHandler());
    new Thread(SpecialRewardChecker::retrieveSpecialRewards).start();
    BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.GRENADE, new BehaviorProjectileDispense() {

        @Nonnull
        @Override
        protected IProjectile getProjectileEntity(@Nonnull World worldIn, @Nonnull IPosition position, @Nonnull ItemStack stackIn) {
            EntityGrenade grenade = new EntityGrenade(worldIn);
            grenade.setItem(stackIn);
            return grenade;
        }
    });
}
Also used : IPosition(net.minecraft.dispenser.IPosition) BehaviorProjectileDispense(net.minecraft.dispenser.BehaviorProjectileDispense) Nonnull(javax.annotation.Nonnull) EntityGrenade(ladysnake.gaspunk.entity.EntityGrenade) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) BaublesCompatHandler(ladysnake.gaspunk.compat.BaublesCompatHandler) IProjectile(net.minecraft.entity.IProjectile)

Example 2 with EntityGrenade

use of ladysnake.gaspunk.entity.EntityGrenade in project Gaspunk by Ladysnake.

the class ItemGrenade method onPlayerStoppedUsing.

@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLivingBase, int timeLeft) {
    if (!worldIn.isRemote) {
        worldIn.playSound(null, entityLivingBase.posX, entityLivingBase.posY, entityLivingBase.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
        ItemStack stack1;
        // don't shrink the stack if the player is in creative
        if (entityLivingBase instanceof EntityPlayer && ((EntityPlayer) entityLivingBase).isCreative())
            stack1 = stack.copy();
        else
            stack1 = stack.splitStack(1);
        EntityGrenade grenade = new EntityGrenade(worldIn, entityLivingBase, stack1);
        grenade.setCountdown(timeLeft);
        grenade.shoot(entityLivingBase, entityLivingBase.rotationPitch, entityLivingBase.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntity(grenade);
    }
}
Also used : EntityGrenade(ladysnake.gaspunk.entity.EntityGrenade) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityGrenade (ladysnake.gaspunk.entity.EntityGrenade)2 ItemStack (net.minecraft.item.ItemStack)2 Nonnull (javax.annotation.Nonnull)1 BaublesCompatHandler (ladysnake.gaspunk.compat.BaublesCompatHandler)1 BehaviorProjectileDispense (net.minecraft.dispenser.BehaviorProjectileDispense)1 IPosition (net.minecraft.dispenser.IPosition)1 IProjectile (net.minecraft.entity.IProjectile)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 World (net.minecraft.world.World)1