Search in sources :

Example 6 with IBullet

use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.

the class EntityRevolvershot method onImpact.

protected void onImpact(RayTraceResult mop) {
    boolean headshot = false;
    if (mop.entityHit instanceof EntityLivingBase)
        headshot = Utils.isVecInEntityHead((EntityLivingBase) mop.entityHit, new Vec3d(posX, posY, posZ));
    if (this.bulletType != null) {
        IBullet bullet = BulletHandler.getBullet(bulletType);
        if (bullet != null)
            bullet.onHitTarget(world, mop, this.shootingEntity, this, headshot);
        if (headshot && mop.entityHit instanceof EntityAgeable && ((EntityAgeable) mop.entityHit).isChild() && ((EntityLivingBase) mop.entityHit).getHealth() <= 0) {
            if (this.shootingEntity instanceof EntityPlayer)
                Utils.unlockIEAdvancement((EntityPlayer) this.shootingEntity, "main/secret_birthdayparty");
            world.playSound(null, posX, posY, posZ, IESounds.birthdayParty, SoundCategory.PLAYERS, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
            ImmersiveEngineering.packetHandler.sendToDimension(new MessageBirthdayParty((EntityLivingBase) mop.entityHit), world.provider.getDimension());
        }
    }
    if (!this.world.isRemote) {
        // if(bulletType==3)
        // world.createExplosion(shootingEntity, posX, posY, posZ, 2, false);
        this.secondaryImpact(mop);
    }
    if (mop.typeOfHit == Type.BLOCK) {
        IBlockState state = this.world.getBlockState(mop.getBlockPos());
        if (state.getBlock().getMaterial(state) != Material.AIR)
            state.getBlock().onEntityCollision(this.world, mop.getBlockPos(), state, this);
    }
    this.setDead();
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) IBlockState(net.minecraft.block.state.IBlockState) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAgeable(net.minecraft.entity.EntityAgeable) MessageBirthdayParty(blusunrize.immersiveengineering.common.util.network.MessageBirthdayParty)

Example 7 with IBullet

use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.

the class ItemBullet method getSubItems.

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
    if (this.isInCreativeTab(tab)) {
        list.add(new ItemStack(this, 1, 0));
        list.add(new ItemStack(this, 1, 1));
        for (Map.Entry<String, IBullet> entry : BulletHandler.registry.entrySet()) if (entry.getValue().isProperCartridge()) {
            ItemStack s = new ItemStack(this, 1, 2);
            ItemNBTHelper.setString(s, "bullet", entry.getKey());
            list.add(s);
        }
    }
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ITextureOverride(blusunrize.immersiveengineering.common.items.IEItemInterfaces.ITextureOverride)

Example 8 with IBullet

use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.

the class ItemBullet method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack stack) {
    if (stack.getItemDamage() == 2) {
        String s = "item.immersiveengineering.bullet.";
        String key = ItemNBTHelper.getString(stack, "bullet");
        // handle legacy bullets
        key = BulletHandler.handleLeagcyNames(key);
        s += key;
        IBullet bullet = BulletHandler.getBullet(key);
        if (bullet != null)
            s = bullet.getTranslationKey(stack, s);
        return I18n.translateToLocal(s + ".name").trim();
    }
    return super.getItemStackDisplayName(stack);
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) ITextureOverride(blusunrize.immersiveengineering.common.items.IEItemInterfaces.ITextureOverride)

Example 9 with IBullet

use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.

the class ItemBullet method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> list, ITooltipFlag flag) {
    if (stack.getItemDamage() == 2) {
        String key = ItemNBTHelper.getString(stack, "bullet");
        IBullet bullet = BulletHandler.getBullet(key);
        if (bullet != null)
            bullet.addTooltip(stack, world, list, flag);
    }
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ITextureOverride(blusunrize.immersiveengineering.common.items.IEItemInterfaces.ITextureOverride)

Aggregations

IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)9 ItemStack (net.minecraft.item.ItemStack)5 ITextureOverride (blusunrize.immersiveengineering.common.items.IEItemInterfaces.ITextureOverride)4 Entity (net.minecraft.entity.Entity)3 EntityItem (net.minecraft.entity.item.EntityItem)3 Vec3d (net.minecraft.util.math.Vec3d)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 MessageSpeedloaderSync (blusunrize.immersiveengineering.common.util.network.MessageSpeedloaderSync)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 MessageBirthdayParty (blusunrize.immersiveengineering.common.util.network.MessageBirthdayParty)1 Map (java.util.Map)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 PotionEffect (net.minecraft.potion.PotionEffect)1 Triple (org.apache.commons.lang3.tuple.Triple)1