Search in sources :

Example 1 with ItemKeyblade

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class EntityEvents method onLivingDrops.

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
    for (int i = 0; i < entityDrops.size(); i++) {
        if (entityDrops.get(i).getDroppedFrom().isInstance(event.getEntity())) {
            addEntityDrop(event, entityDrops.get(i));
        }
    }
    // Remove any summoned keyblades or org weapons on death
    if (event.getEntity() instanceof EntityPlayer) {
        for (int i = 0; i < event.getDrops().size(); i++) {
            if (event.getDrops().get(i).getItem().getItem() instanceof ItemKeyblade && (event.getDrops().get(i).getItem().getItem() != ModItems.WoodenKeyblade && event.getDrops().get(i).getItem().getItem() != ModItems.WoodenStick)) {
                event.getDrops().remove(i);
                event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
                i = 0;
            }
            if (event.getDrops().get(i).getItem().getItem() == event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
                event.getDrops().remove(i);
                event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(((EntityPlayer) event.getEntity()).getActiveHand(), false);
                i = 0;
            }
        }
    }
    if (!MainConfig.entities.disableDrops) {
        if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
                    if (event.getEntity() instanceof EntityMob)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            dropRecipe(event);
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
                    if (event.getEntity() instanceof EntityMob)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            dropRecipe(event);
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemRealKeyblade) {
                    if (event.getEntity() instanceof EntityAnimal) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
                    } else if (event.getEntity() instanceof EntityMob) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart")) {
                            if (!(event.getEntityLiving() instanceof IKHMob && ((IKHMob) event.getEntityLiving()).getType() == MobType.HEARTLESS_PUREBLOOD))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
                        }
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
                            int rand;
                            rand = Utils.randomWithRange(1, 30);
                            if (rand == 1)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
                            else if (rand == 5)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
                            else if (rand == 9)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
                            else if (rand == 13)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
                            else if (rand == 17) {
                            // event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
                            } else if (rand == 21)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
                            else if (rand == 25)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
                        }
                    } else if (event.getEntity() instanceof EntityAgeable)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
                    if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
                    }
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
                if (player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof ItemRealKeyblade) {
                    if (event.getEntity() instanceof EntityAnimal)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
                        else if (event.getEntity() instanceof EntityMob) {
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart"))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
                                int rand;
                                rand = Utils.randomWithRange(1, 30);
                                if (rand == 1)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
                                else if (rand == 5)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
                                else if (rand == 9)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
                                else if (rand == 13)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
                                else if (rand == 17) {
                                // event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
                                } else if (rand == 21)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
                                else if (rand == 25)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
                            }
                        } else if (event.getEntity() instanceof EntityAgeable)
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
                    if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
                    }
                }
            }
            ItemStack munny = new ItemStack(ModItems.Munny, 1);
            munny.setTagCompound(new NBTTagCompound());
            ItemStack driveOrb = new ItemStack(ModItems.DriveOrb, 1);
            driveOrb.setTagCompound(new NBTTagCompound());
            ItemStack magicOrb = new ItemStack(ModItems.MagicOrb, 1);
            magicOrb.setTagCompound(new NBTTagCompound());
            ItemStack HPOrb = new ItemStack(ModItems.HpOrb, 1);
            if (event.getEntity() instanceof EntityAnimal) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(1, 20));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(2, 8));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityMob) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 50));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 5);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 15));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityAgeable) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(50, 100));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 5);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(10, 25));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(500, 1000));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(200, 250));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(100, 140));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            }
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) ItemRealKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) EntityMob(net.minecraft.entity.monster.EntityMob) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityWither(net.minecraft.entity.boss.EntityWither) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) ItemStack(net.minecraft.item.ItemStack) EntityWitch(net.minecraft.entity.monster.EntityWitch) EntityAgeable(net.minecraft.entity.EntityAgeable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ItemKeyblade

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class ItemEvents method onItemTossEvent.

@SubscribeEvent
public void onItemTossEvent(ItemTossEvent event) {
    if (!event.getPlayer().world.isRemote)
        if (event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getInDrive() && !event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Anti)) {
            event.setCanceled(true);
            return;
        }
    if (event.getEntityItem().getItem().getItem() instanceof ItemKeyblade && (event.getEntityItem().getItem().getItem() != ModItems.WoodenKeyblade && event.getEntityItem().getItem().getItem() != ModItems.WoodenStick && event.getEntityItem().getItem().getItem() != ModItems.DreamSword && event.getEntityItem().getItem().getItem() != ModItems.DreamStaff)) {
        event.getEntityItem().isDead = true;
        event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
        if (!ItemStack.areItemStacksEqual(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0), ItemStack.EMPTY))
            PacketDispatcher.sendTo(new SyncKeybladeData(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) event.getPlayer());
    } else if (event.getEntityItem().getItem().getItem() instanceof ItemMunny) {
        event.setCanceled(true);
        if (!event.getPlayer().world.isRemote) {
            PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getEntityItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getPlayer());
            event.getPlayer().getCapability(ModCapabilities.MUNNY, null).addMunny(event.getEntityItem().getItem().getTagCompound().getInteger("amount"));
        }
    }
    if (event.getEntityItem().getItem().getItem() == event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
        event.getEntityItem().isDead = true;
        event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(EnumHand.MAIN_HAND, false);
        PacketDispatcher.sendTo(new SyncOrgXIIIData(event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) event.getPlayer());
    }
}
Also used : ShowOverlayPacket(uk.co.wehavecookies56.kk.common.network.packet.client.ShowOverlayPacket) SyncKeybladeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemMunny(uk.co.wehavecookies56.kk.common.item.ItemMunny) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ItemKeyblade

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiFreeDevelopmentRecipeList method drawSlot.

@Override
protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(RECIPES.getFreeDevRecipes().get(var1).toString() + ".name"), listWidth - 1), this.left + 3, var3 + 2, 0xFFFFFF);
    this.ir.renderItemAndEffectIntoGUI(new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getFreeDevRecipes().get(var1).substring(5)))), this.left + 3, var3 + 12);
// this.f.drawString("Str: +"+((ItemKeyblade)ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(var1).substring(5)))).getStrength(),this.left + 25, var3 + 12, 0xFF0000);
// this.f.drawString("Mag: +"+((ItemKeyblade)ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(var1).substring(5)))).getMagic(),this.left + 25, var3 + 20, 0x4444FF);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 4 with ItemKeyblade

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class AttackEntity method attackTargetEntityWithCurrentItem.

/**
 * Slightly modified {@link EntityPlayer#attackTargetEntityWithCurrentItem(Entity)} for off hand
 * @param player The player
 * @param targetEntity The entity to attack
 */
public void attackTargetEntityWithCurrentItem(EntityPlayer player, Entity targetEntity) {
    if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget(player, targetEntity))
        return;
    if (targetEntity.canBeAttackedWithItem()) {
        if (!targetEntity.hitByEntity(player)) {
            // float f = (float)player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
            float f = DamageCalculation.getStrengthDamage(player, (ItemKeyblade) player.getHeldItemOffhand().getItem());
            // f += (float)(player.getCapability(ModCapabilities.PLAYER_STATS, null).getStrength() + ((ItemKeyblade)player.getHeldItemOffhand().getItem()).getStrength());
            float f1;
            if (targetEntity instanceof EntityLivingBase) {
                f1 = EnchantmentHelper.getModifierForCreature(player.getHeldItemOffhand(), ((EntityLivingBase) targetEntity).getCreatureAttribute());
            } else {
                f1 = EnchantmentHelper.getModifierForCreature(player.getHeldItemOffhand(), EnumCreatureAttribute.UNDEFINED);
            }
            if (player.getHeldItemMainhand().getItem() instanceof ItemKeyblade) {
            // f -= 3;
            }
            // player.getCooledAttackStrength(0.5F);
            float f2 = 1;
            f = f * (0.2F + f2 * f2 * 0.8F);
            f1 = f1 * f2;
            player.resetCooldown();
            if (f > 0.0F || f1 > 0.0F) {
                boolean flag = f2 > 0.9F;
                boolean flag1 = false;
                int i = 0;
                i = i + EnchantmentHelper.getKnockbackModifier(player);
                if (player.isSprinting() && flag) {
                    player.world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, player.getSoundCategory(), 1.0F, 1.0F);
                    ++i;
                    flag1 = true;
                }
                boolean flag2 = flag && player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(MobEffects.BLINDNESS) && !player.isRiding() && targetEntity instanceof EntityLivingBase;
                flag2 = flag2 && !player.isSprinting();
                if (flag2) {
                    f *= 1.5F;
                }
                f = f + f1;
                boolean flag3 = false;
                double d0 = (double) (player.distanceWalkedModified - player.prevDistanceWalkedModified);
                if (flag && !flag2 && !flag1 && player.onGround && d0 < (double) player.getAIMoveSpeed()) {
                    ItemStack itemstack = player.getHeldItem(EnumHand.OFF_HAND);
                    if (itemstack.getItem() instanceof ItemKeyblade) {
                        flag3 = true;
                    }
                }
                float f4 = 0.0F;
                boolean flag4 = false;
                int j = EnchantmentHelper.getFireAspectModifier(player);
                if (targetEntity instanceof EntityLivingBase) {
                    f4 = ((EntityLivingBase) targetEntity).getHealth();
                    if (j > 0 && !targetEntity.isBurning()) {
                        flag4 = true;
                        targetEntity.setFire(1);
                    }
                }
                double d1 = targetEntity.motionX;
                double d2 = targetEntity.motionY;
                double d3 = targetEntity.motionZ;
                DamageSource playerDamage = DamageSource.causePlayerDamage(player);
                playerDamage.damageType = EnumHand.OFF_HAND.name();
                boolean flag5 = targetEntity.attackEntityFrom(playerDamage, f);
                if (flag5) {
                    if (i > 0) {
                        if (targetEntity instanceof EntityLivingBase) {
                            ((EntityLivingBase) targetEntity).knockBack(player, (float) i * 0.5F, (double) MathHelper.sin(player.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(player.rotationYaw * 0.017453292F)));
                        } else {
                            targetEntity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(player.rotationYaw * 0.017453292F) * (float) i * 0.5F));
                        }
                        player.motionX *= 0.6D;
                        player.motionZ *= 0.6D;
                        player.setSprinting(false);
                    }
                    if (flag3) {
                        float f3 = 1.0F + EnchantmentHelper.getSweepingDamageRatio(player) * f;
                        for (EntityLivingBase entitylivingbase : player.world.getEntitiesWithinAABB(EntityLivingBase.class, targetEntity.getEntityBoundingBox().grow(1.0D, 0.25D, 1.0D))) {
                            if (entitylivingbase != player && entitylivingbase != targetEntity && !player.isOnSameTeam(entitylivingbase) && player.getDistanceSqToEntity(entitylivingbase) < 9.0D) {
                                entitylivingbase.knockBack(player, 0.4F, (double) MathHelper.sin(player.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(player.rotationYaw * 0.017453292F)));
                                entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage(player), f3);
                            }
                        }
                        player.world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, player.getSoundCategory(), 1.0F, 1.0F);
                        player.spawnSweepParticles();
                    }
                    if (targetEntity instanceof EntityPlayerMP && targetEntity.velocityChanged) {
                        ((EntityPlayerMP) targetEntity).connection.sendPacket(new SPacketEntityVelocity(targetEntity));
                        targetEntity.velocityChanged = false;
                        targetEntity.motionX = d1;
                        targetEntity.motionY = d2;
                        targetEntity.motionZ = d3;
                    }
                    if (flag2) {
                        player.world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, player.getSoundCategory(), 1.0F, 1.0F);
                        player.onCriticalHit(targetEntity);
                    }
                    if (!flag2 && !flag3) {
                        if (flag) {
                            player.world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, player.getSoundCategory(), 1.0F, 1.0F);
                        } else {
                            player.world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, player.getSoundCategory(), 1.0F, 1.0F);
                        }
                    }
                    if (f1 > 0.0F) {
                        player.onEnchantmentCritical(targetEntity);
                    }
                    player.setLastAttackedEntity(targetEntity);
                    if (targetEntity instanceof EntityLivingBase) {
                        EnchantmentHelper.applyThornEnchantments((EntityLivingBase) targetEntity, player);
                    }
                    EnchantmentHelper.applyArthropodEnchantments(player, targetEntity);
                    ItemStack itemstack1 = player.getHeldItemOffhand();
                    Entity entity = targetEntity;
                    if (targetEntity instanceof MultiPartEntityPart) {
                        IEntityMultiPart ientitymultipart = ((MultiPartEntityPart) targetEntity).parent;
                        if (ientitymultipart instanceof EntityLivingBase) {
                            entity = (EntityLivingBase) ientitymultipart;
                        }
                    }
                    if (!itemstack1.isEmpty() && entity instanceof EntityLivingBase) {
                        ItemStack beforeHitCopy = itemstack1.copy();
                        itemstack1.hitEntity((EntityLivingBase) entity, player);
                        if (itemstack1.isEmpty()) {
                            net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, beforeHitCopy, EnumHand.OFF_HAND);
                            player.setHeldItem(EnumHand.OFF_HAND, ItemStack.EMPTY);
                        }
                    }
                    if (targetEntity instanceof EntityLivingBase) {
                        float f5 = f4 - ((EntityLivingBase) targetEntity).getHealth();
                        player.addStat(StatList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
                        if (j > 0) {
                            targetEntity.setFire(j * 4);
                        }
                        if (player.world instanceof WorldServer && f5 > 2.0F) {
                            int k = (int) ((double) f5 * 0.5D);
                            ((WorldServer) player.world).spawnParticle(EnumParticleTypes.DAMAGE_INDICATOR, targetEntity.posX, targetEntity.posY + (double) (targetEntity.height * 0.5F), targetEntity.posZ, k, 0.1D, 0.0D, 0.1D, 0.2D);
                        }
                    }
                    player.addExhaustion(0.1F);
                } else {
                    player.world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, player.getSoundCategory(), 1.0F, 1.0F);
                    if (flag4) {
                        targetEntity.extinguish();
                    }
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) DamageSource(net.minecraft.util.DamageSource) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) MultiPartEntityPart(net.minecraft.entity.MultiPartEntityPart) WorldServer(net.minecraft.world.WorldServer) SPacketEntityVelocity(net.minecraft.network.play.server.SPacketEntityVelocity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IEntityMultiPart(net.minecraft.entity.IEntityMultiPart) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemKeyblade

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class CommandOpenKeyInv method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender.getCommandSenderEntity() instanceof EntityPlayer) {
        if (args.length > 1) {
            TextHelper.sendFormattedChatMessage("Invalid arguments, usage: " + getUsage(sender), TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
        } else {
            EntityPlayer player = (EntityPlayer) sender.getCommandSenderEntity();
            if (args.length == 1) {
                if (getPlayerFromUsername(args[0]) != null) {
                    player = getPlayerFromUsername(args[0]);
                }
            }
            ISummonKeyblade KEYBLADE = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
            GuiHelper.openInv(GuiIDs.GUI_KEYCHAIN_INV);
        /*  if (!ItemStack.areItemStacksEqual(KEYBLADE.getInventoryKeychain().getStackInSlot(slot), ItemStack.EMPTY)) {
                    PacketDispatcher.sendToServer(new RemoveItemInSlot("keychain", slot));
                    PacketDispatcher.sendToAllAround(new RemoveItemInSlot("keychain", slot), (EntityPlayer) sender.getCommandSenderEntity(), 1);

                    if (sender.getCommandSenderEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getIsKeybladeSummoned(EnumHand.MAIN_HAND))
                        if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY) && player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemKeyblade)
                            //player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, true);
                        PacketDispatcher.sendToServer(new DeSummonKeyblade());
                    	if(args.length == 2)
                    		TextHelper.sendFormattedChatMessage(args[1] + "'s keychain has been removed!", TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
                    	else
                    		TextHelper.sendFormattedChatMessage("Your keychain has been removed!", TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
                } else
                    TextHelper.sendFormattedChatMessage("The chain slot has no chain!", TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
                */
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ISummonKeyblade(uk.co.wehavecookies56.kk.common.capability.SummonKeybladeCapability.ISummonKeyblade)

Aggregations

ItemKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade)9 ItemStack (net.minecraft.item.ItemStack)8 SynthesisRecipeCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)5 IOrgWeapon (uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon)5 Item (net.minecraft.item.Item)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Map (java.util.Map)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemKeychain (uk.co.wehavecookies56.kk.common.item.base.ItemKeychain)3 Iterator (java.util.Iterator)2 RenderItem (net.minecraft.client.renderer.RenderItem)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Material (uk.co.wehavecookies56.kk.api.materials.Material)2 SynthesisMaterialCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability)2 IKHMob (uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob)2 ItemRealKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade)2 Entity (net.minecraft.entity.Entity)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1