Search in sources :

Example 6 with MonsterEntity

use of net.minecraft.entity.monster.MonsterEntity in project ChaosAwakens by ChaosAwakens.

the class AntInfestedOre method spawnAnt.

private void spawnAnt(World world, BlockPos pos) {
    MonsterEntity antEntity = (MonsterEntity) ant.get().create(world);
    assert antEntity != null;
    antEntity.moveTo((double) pos.getX() + 0.5D, pos.getY(), (double) pos.getZ() + 0.5D, 0.0F, 0.0F);
    world.addFreshEntity(antEntity);
    antEntity.spawnAnim();
}
Also used : MonsterEntity(net.minecraft.entity.monster.MonsterEntity)

Example 7 with MonsterEntity

use of net.minecraft.entity.monster.MonsterEntity in project minecolonies by ldtteam.

the class CommandKillMonster method onExecute.

/**
 * What happens when the command is executed
 *
 * @param context the context of the command execution
 */
@Override
public int onExecute(final CommandContext<CommandSource> context) {
    entitiesKilled = 0;
    context.getSource().getLevel().getEntities().forEach(entity -> {
        if (entity instanceof MonsterEntity) {
            entity.remove();
            entitiesKilled++;
        }
    });
    context.getSource().sendSuccess(new StringTextComponent(entitiesKilled + " entities killed"), true);
    return 1;
}
Also used : MonsterEntity(net.minecraft.entity.monster.MonsterEntity) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 8 with MonsterEntity

use of net.minecraft.entity.monster.MonsterEntity in project Kingdom-Keys by Wehavecookies56.

the class EntityEvents method onLivingDeathEvent.

@SubscribeEvent
public void onLivingDeathEvent(LivingDeathEvent event) {
    // EnderDragon killed makes heartless spawn if mode is 3
    IWorldCapabilities worldData = ModCapabilities.getWorld(event.getEntityLiving().world);
    if (event.getEntityLiving() instanceof EnderDragonEntity) {
        LivingEntity entity = event.getEntityLiving();
        if (worldData.getHeartlessSpawnLevel() == 0 && ModConfigs.heartlessSpawningMode == SpawningMode.AFTER_DRAGON) {
            worldData.setHeartlessSpawnLevel(1);
        }
        for (PlayerEntity p : entity.world.getPlayers()) {
            entity.world.addEntity(new ItemEntity(entity.world, p.getPosX(), p.getPosY(), p.getPosZ(), new ItemStack(ModItems.proofOfHeart.get(), 1)));
        }
    }
    if (!event.getEntity().world.isRemote) {
        if (event.getSource().getImmediateSource() instanceof PlayerEntity || event.getSource().getTrueSource() instanceof PlayerEntity) {
            // If the player kills
            PlayerEntity player = (PlayerEntity) event.getSource().getTrueSource();
            IPlayerCapabilities playerData = ModCapabilities.getPlayer(player);
            // Give hearts
            if (player.getHeldItemMainhand().getItem() instanceof IOrgWeapon || player.getHeldItemMainhand().getItem() instanceof KeybladeItem) {
                int multiplier = 1;
                if (player.getHeldItemMainhand().getItem() instanceof IOrgWeapon) {
                    IOrgWeapon weapon = (IOrgWeapon) player.getHeldItemMainhand().getItem();
                    if (weapon.getMember() == playerData.getAlignment()) {
                        multiplier = 2;
                    }
                }
                if (event.getEntity() instanceof IKHMob) {
                    IKHMob mob = (IKHMob) event.getEntity();
                    if (mob.getMobType() == MobType.HEARTLESS_EMBLEM) {
                        playerData.addHearts((int) ((20 * multiplier) * ModConfigs.heartMultiplier));
                    }
                } else if (event.getEntity() instanceof EnderDragonEntity || event.getEntity() instanceof WitherEntity) {
                    playerData.addHearts((int) ((1000 * multiplier) * ModConfigs.heartMultiplier));
                } else if (event.getEntity() instanceof VillagerEntity) {
                    playerData.addHearts((int) ((5 * multiplier) * ModConfigs.heartMultiplier));
                } else if (event.getEntity() instanceof MonsterEntity) {
                    playerData.addHearts((int) ((2 * multiplier) * ModConfigs.heartMultiplier));
                } else {
                    playerData.addHearts((int) ((1 * multiplier) * ModConfigs.heartMultiplier));
                }
            }
            if (event.getEntityLiving() instanceof IKHMob) {
                IKHMob heartless = (IKHMob) event.getEntityLiving();
                if (heartless.getMobType() == MobType.HEARTLESS_EMBLEM && Utils.getWeaponDamageStack(event.getSource(), player) != null && Utils.getWeaponDamageStack(event.getSource(), player).getItem() instanceof KeybladeItem) {
                    HeartEntity heart = new HeartEntity(event.getEntityLiving().world);
                    heart.setPosition(event.getEntityLiving().getPosX(), event.getEntityLiving().getPosY() + 1, event.getEntityLiving().getPosZ());
                    event.getEntityLiving().world.addEntity(heart);
                }
            }
            if (event.getEntity().getClassification(false) == EntityClassification.MONSTER) {
                if (!playerData.isAbilityEquipped(Strings.zeroExp)) {
                    LivingEntity mob = (LivingEntity) event.getEntity();
                    double value = mob.getAttribute(Attributes.MAX_HEALTH).getValue() / 2;
                    double exp = Utils.randomWithRange(value * 0.8, value * 1.8);
                    playerData.addExperience(player, (int) ((int) exp * ModConfigs.xpMultiplier), true, true);
                    if (event.getEntity() instanceof WitherEntity) {
                        playerData.addExperience(player, 1500, true, true);
                    }
                }
                LivingEntity entity = event.getEntityLiving();
                double x = entity.getPosX();
                double y = entity.getPosY();
                double z = entity.getPosZ();
                if (entity.world.rand.nextInt(100) <= ModConfigs.munnyDropProbability) {
                    int num = Utils.randomWithRange(5, 15);
                    num += playerData.getNumberOfAbilitiesEquipped(Strings.jackpot) * 1.2;
                    entity.world.addEntity(new MunnyEntity(event.getEntity().world, x, y, z, num));
                }
                if (entity.world.rand.nextInt(100) <= ModConfigs.hpDropProbability) {
                    int num = (int) Utils.randomWithRange(entity.getMaxHealth() / 10, entity.getMaxHealth() / 5);
                    num += playerData.getNumberOfAbilitiesEquipped(Strings.jackpot) * 1.2;
                    entity.world.addEntity(new HPOrbEntity(event.getEntity().world, x, y, z, num));
                }
                if (entity.world.rand.nextInt(100) <= ModConfigs.mpDropProbability) {
                    int num = (int) Utils.randomWithRange(entity.getMaxHealth() / 10, entity.getMaxHealth() / 5);
                    num += playerData.getNumberOfAbilitiesEquipped(Strings.jackpot) * 1.2;
                    entity.world.addEntity(new MPOrbEntity(event.getEntity().world, x, y, z, num));
                }
                if (entity.world.rand.nextInt(100) <= ModConfigs.driveDropProbability) {
                    int num = (int) (Utils.randomWithRange(entity.getMaxHealth() * 0.1F, entity.getMaxHealth() * 0.25F) * ModConfigs.drivePointsMultiplier);
                    num += num * playerData.getNumberOfAbilitiesEquipped(Strings.driveConverter) * 0.5;
                    entity.world.addEntity(new DriveOrbEntity(event.getEntity().world, x, y, z, num));
                }
                if (entity.world.rand.nextInt(100) <= ModConfigs.focusDropProbability) {
                    int num = (int) (Utils.randomWithRange(entity.getMaxHealth() * 0.1F, entity.getMaxHealth() * 0.25F) * ModConfigs.focusPointsMultiplier);
                    num += num * playerData.getNumberOfAbilitiesEquipped(Strings.focusConverter) * 0.25;
                    entity.world.addEntity(new FocusOrbEntity(event.getEntity().world, x, y, z, num));
                }
                int num = Utils.randomWithRange(0, 99);
                if (num < ModConfigs.recipeDropChance) {
                    ItemEntity ie = new ItemEntity(player.world, x, y, z, new ItemStack(ModItems.recipe.get()));
                    player.world.addEntity(ie);
                }
                PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) player);
            }
        }
        if (event.getEntity() instanceof MoogleEntity && event.getSource() == DamageSource.ANVIL) {
            ItemEntity ie = new ItemEntity(event.getEntity().world, event.getEntity().getPosX(), event.getEntity().getPosY(), event.getEntity().getPosZ(), new ItemStack(ModBlocks.moogleProjector.get()));
            event.getEntity().world.addEntity(ie);
        }
        if (event.getSource().getTrueSource() instanceof IKHMob && ModConfigs.playerSpawnHeartless) {
            IKHMob killerMob = (IKHMob) event.getSource().getTrueSource();
            if (!event.getSource().getTrueSource().hasCustomName() && (killerMob.getMobType() == MobType.HEARTLESS_EMBLEM || killerMob.getMobType() == MobType.HEARTLESS_PUREBLOOD)) {
                if (event.getEntityLiving() instanceof PlayerEntity) {
                    // If a player gets killed by a heartless
                    IPlayerCapabilities playerData = ModCapabilities.getPlayer((PlayerEntity) event.getEntityLiving());
                    String[] heartless = ModConfigs.playerSpawnHeartlessData.get(0).split(",");
                    String[] nobody = ModConfigs.playerSpawnHeartlessData.get(1).split(",");
                    DuskEntity newDusk = new DuskEntity(ModEntities.TYPE_DUSK.get(), event.getSource().getTrueSource().world);
                    newDusk.setPosition(event.getEntityLiving().getPosition().getX(), event.getEntityLiving().getPosition().getY(), event.getEntityLiving().getPosition().getZ());
                    newDusk.setCustomName(new TranslationTextComponent(event.getEntityLiving().getDisplayName().getString() + "'s Nobody"));
                    newDusk.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Math.max(event.getEntityLiving().getMaxHealth() * Double.parseDouble(nobody[1]) / 100, newDusk.getMaxHealth()));
                    newDusk.heal(newDusk.getMaxHealth());
                    newDusk.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(Math.max(playerData.getStrength(true) * Double.parseDouble(nobody[2]) / 100, newDusk.getAttribute(Attributes.ATTACK_DAMAGE).getBaseValue()));
                    event.getSource().getTrueSource().world.addEntity(newDusk);
                    ShadowEntity newShadow = new ShadowEntity(ModEntities.TYPE_SHADOW.get(), event.getSource().getTrueSource().world);
                    newShadow.setPosition(event.getEntityLiving().getPosition().getX(), event.getEntityLiving().getPosition().getY(), event.getEntityLiving().getPosition().getZ());
                    newShadow.setCustomName(new TranslationTextComponent(event.getEntityLiving().getDisplayName().getString() + "'s Heartless"));
                    newShadow.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Math.max(event.getEntityLiving().getMaxHealth() * Double.parseDouble(heartless[1]) / 100, newShadow.getMaxHealth()));
                    newShadow.heal(newShadow.getMaxHealth());
                    newShadow.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(Math.max(playerData.getStrength(true) * Double.parseDouble(heartless[2]) / 100, newShadow.getAttribute(Attributes.ATTACK_DAMAGE).getBaseValue()));
                    event.getSource().getTrueSource().world.addEntity(newShadow);
                    HeartEntity heart = new HeartEntity(event.getEntityLiving().world);
                    heart.setPosition(event.getEntityLiving().getPosX(), event.getEntityLiving().getPosY() + 1, event.getEntityLiving().getPosZ());
                    event.getEntityLiving().world.addEntity(heart);
                } else if (event.getEntityLiving() instanceof VillagerEntity) {
                    ShadowEntity newShadow = new ShadowEntity(ModEntities.TYPE_SHADOW.get(), event.getSource().getTrueSource().world);
                    newShadow.setPosition(event.getEntityLiving().getPosition().getX(), event.getEntityLiving().getPosition().getY(), event.getEntityLiving().getPosition().getZ());
                    event.getSource().getTrueSource().world.addEntity(newShadow);
                    HeartEntity heart = new HeartEntity(event.getEntityLiving().world);
                    heart.setPosition(event.getEntityLiving().getPosX(), event.getEntityLiving().getPosY() + 1, event.getEntityLiving().getPosZ());
                    event.getEntityLiving().world.addEntity(heart);
                }
            }
        }
    }
}
Also used : VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) MoogleEntity(online.kingdomkeys.kingdomkeys.entity.mob.MoogleEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) DriveOrbEntity(online.kingdomkeys.kingdomkeys.entity.DriveOrbEntity) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) DuskEntity(online.kingdomkeys.kingdomkeys.entity.mob.DuskEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) IPlayerCapabilities(online.kingdomkeys.kingdomkeys.capability.IPlayerCapabilities) SCSyncCapabilityPacket(online.kingdomkeys.kingdomkeys.network.stc.SCSyncCapabilityPacket) MunnyEntity(online.kingdomkeys.kingdomkeys.entity.MunnyEntity) KeybladeItem(online.kingdomkeys.kingdomkeys.item.KeybladeItem) IKHMob(online.kingdomkeys.kingdomkeys.entity.mob.IKHMob) HPOrbEntity(online.kingdomkeys.kingdomkeys.entity.HPOrbEntity) WitherEntity(net.minecraft.entity.boss.WitherEntity) IWorldCapabilities(online.kingdomkeys.kingdomkeys.capability.IWorldCapabilities) ShadowEntity(online.kingdomkeys.kingdomkeys.entity.mob.ShadowEntity) MPOrbEntity(online.kingdomkeys.kingdomkeys.entity.MPOrbEntity) ItemStack(net.minecraft.item.ItemStack) HeartEntity(online.kingdomkeys.kingdomkeys.entity.HeartEntity) IOrgWeapon(online.kingdomkeys.kingdomkeys.item.organization.IOrgWeapon) FocusOrbEntity(online.kingdomkeys.kingdomkeys.entity.FocusOrbEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 9 with MonsterEntity

use of net.minecraft.entity.monster.MonsterEntity in project Kingdom-Keys by Wehavecookies56.

the class EntityEvents method onPlayerTick.

@SubscribeEvent
public void onPlayerTick(PlayerTickEvent event) {
    if (event.phase == Phase.START) {
        if (ticks >= Integer.MAX_VALUE) {
            ticks = Integer.MIN_VALUE;
        }
        IPlayerCapabilities playerData = ModCapabilities.getPlayer(event.player);
        if (playerData != null) {
            // System.out.println(playerData.getNumberOfAbilitiesEquipped(Strings.damageControl));
            // Check if rc conditions match
            List<ReactionCommand> rcList = new ArrayList<ReactionCommand>();
            // Those will be available when joining the world too if the conditions are met
            for (ReactionCommand rc : ModReactionCommands.registry.getValues()) {
                if (rc.needsConstantCheck() && rc.conditionsToAppear(event.player, event.player)) {
                    rcList.add(rc);
                }
            }
            // Check commands in player list
            for (String rcName : playerData.getReactionCommands()) {
                ReactionCommand rc = ModReactionCommands.registry.getValue(new ResourceLocation(rcName));
                if (rc.conditionsToAppear(event.player, event.player)) {
                    rcList.add(rc);
                }
            }
            playerData.setReactionCommands(new ArrayList<String>());
            for (ReactionCommand rc : rcList) {
                playerData.addReactionCommand(rc.getName(), event.player);
            }
            // Check for magics that you've been using enough to unlock Grand Magic
            Iterator<Map.Entry<String, int[]>> magicsIt = playerData.getMagicsMap().entrySet().iterator();
            while (magicsIt.hasNext()) {
                // Get all magics the player has and iterate over them
                Map.Entry<String, int[]> pair = (Map.Entry<String, int[]>) magicsIt.next();
                // Get the magic instance of it
                Magic magic = ModMagic.registry.getValue(new ResourceLocation(pair.getKey()));
                if (magic != null && magic.getMagicData() != null && magic.hasRC()) {
                    // If the magic exists and has data and has Grand Magic
                    if (playerData.getMagicUses(magic.getRegistryName().toString()) >= magic.getUsesToGM(pair.getValue()[0])) {
                        // If the actual uses is equals or above the required
                        playerData.addReactionCommand(KingdomKeys.MODID + ":" + magic.getRegistryName().getPath(), event.player);
                    }
                }
            }
            if (!event.player.world.isRemote && event.player.ticksExisted == 5) {
                // TODO Check if it's necessary, I thought it was to set the max hp value but now it seems to work fine without it
                PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) event.player);
            }
            if (playerData.getActiveDriveForm().equals(Strings.Form_Anti)) {
                if (playerData.getFP() > 0) {
                    playerData.setFP(playerData.getFP() - 0.3);
                } else {
                    playerData.setActiveDriveForm(DriveForm.NONE.toString());
                    event.player.world.playSound(event.player, event.player.getPosition(), ModSounds.unsummon.get(), SoundCategory.MASTER, 1.0f, 1.0f);
                    if (!event.player.world.isRemote) {
                        PacketHandler.syncToAllAround(event.player, playerData);
                    }
                }
            } else if (!playerData.getActiveDriveForm().equals(DriveForm.NONE.toString())) {
                ModDriveForms.registry.getValue(new ResourceLocation(playerData.getActiveDriveForm())).updateDrive(event.player);
            }
            // Limit recharge system
            if (playerData.getLimitCooldownTicks() > 0 && !event.player.world.isRemote) {
                playerData.setLimitCooldownTicks(playerData.getLimitCooldownTicks() - 1);
                if (playerData.getLimitCooldownTicks() <= 0) {
                    PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) event.player);
                }
            }
            // Magic CD recharge system
            if (playerData.getMagicCooldownTicks() > 0 && !event.player.world.isRemote) {
                playerData.setMagicCooldownTicks(playerData.getMagicCooldownTicks() - 1);
                if (playerData.getMagicCooldownTicks() <= 0) {
                    PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) event.player);
                }
            }
            // MP Recharge system
            if (playerData.getRecharge()) {
                if (playerData.getMP() >= playerData.getMaxMP()) {
                    // Has recharged fully
                    playerData.setRecharge(false);
                    playerData.setMP(playerData.getMaxMP());
                } else {
                    // Still recharging
                    playerData.addMP(playerData.getMaxMP() / 500 * ((Utils.getMPHasteValue(playerData) / 10) + 2));
                }
            // PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) event.player);
            } else {
                // Not on recharge
                if (playerData.getMP() <= 0 && playerData.getMaxMP() > 0) {
                    playerData.setRecharge(true);
                    if (!event.player.world.isRemote) {
                        PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) event.player);
                    }
                }
            }
            if (!event.player.world.isRemote) {
                if (playerData.getAlignment() == Utils.OrgMember.NONE) {
                    if (!openedAlignment.containsKey(event.player.getUniqueID())) {
                        openedAlignment.put(event.player.getUniqueID(), false);
                    }
                    boolean wearingOrgCloak = Utils.isWearingOrgRobes(event.player);
                    if (wearingOrgCloak) {
                        if (!openedAlignment.get(event.player.getUniqueID())) {
                            PacketHandler.sendTo(new SCOpenAlignmentScreen(), (ServerPlayerEntity) event.player);
                            openedAlignment.put(event.player.getUniqueID(), true);
                        }
                    } else {
                        openedAlignment.put(event.player.getUniqueID(), false);
                    }
                }
                // Treasure Magnet
                if (playerData.isAbilityEquipped(Strings.treasureMagnet) && event.player.inventory.getFirstEmptyStack() > -1) {
                    double x = event.player.getPosX();
                    double y = event.player.getPosY() + 0.75;
                    double z = event.player.getPosZ();
                    float range = 1 + playerData.getNumberOfAbilitiesEquipped(Strings.treasureMagnet);
                    List<ItemEntity> items = event.player.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
                    int pulled = 0;
                    for (ItemEntity item : items) {
                        if (item.ticksExisted < 20) {
                            break;
                        }
                        if (pulled > 200) {
                            break;
                        }
                        Vector3d entityVector = new Vector3d(item.getPosX(), item.getPosY() - item.getYOffset() + item.getHeight() / 2, item.getPosZ());
                        Vector3d finalVector = new Vector3d(x, y, z).subtract(entityVector);
                        if (Math.sqrt(x * x + y * y + z * z) > 1) {
                            finalVector = finalVector.normalize();
                        }
                        item.setMotion(finalVector.mul(0.45F, 0.45F, 0.45F));
                        pulled++;
                    }
                }
            }
            if (ModConfigs.magicUsesTimer > 1) {
                if (event.player.ticksExisted % ModConfigs.magicUsesTimer == 0) {
                    for (Entry<String, int[]> entry : playerData.getMagicsMap().entrySet()) {
                        int uses = playerData.getMagicUses(entry.getKey());
                        if (uses > 0) {
                            playerData.remMagicUses(entry.getKey(), 1);
                        }
                    }
                }
            }
        }
    }
    if (ticks % 5 == 0) {
        // Combat mode
        List<LivingEntity> entities = Utils.getLivingEntitiesInRadius(event.player, 16);
        List<LivingEntity> bossEntities = Utils.getLivingEntitiesInRadius(event.player, 150);
        if (!bossEntities.isEmpty()) {
            for (int i = 0; i < bossEntities.size(); i++) {
                if (bossEntities.get(i) instanceof EnderDragonEntity || bossEntities.get(i) instanceof WitherEntity) {
                    isBoss = true;
                    break;
                } else {
                    isBoss = false;
                }
            }
        } else {
            isBoss = false;
        }
        if (!entities.isEmpty()) {
            for (Entity entity : entities) {
                if (entity instanceof MonsterEntity) {
                    isHostiles = true;
                    break;
                } else {
                    isHostiles = false;
                }
            }
        } else {
            isHostiles = false;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) VillagerEntity(net.minecraft.entity.merchant.villager.VillagerEntity) DriveOrbEntity(online.kingdomkeys.kingdomkeys.entity.DriveOrbEntity) LivingEntity(net.minecraft.entity.LivingEntity) FocusOrbEntity(online.kingdomkeys.kingdomkeys.entity.FocusOrbEntity) HeartEntity(online.kingdomkeys.kingdomkeys.entity.HeartEntity) MunnyEntity(online.kingdomkeys.kingdomkeys.entity.MunnyEntity) FiragaEntity(online.kingdomkeys.kingdomkeys.entity.magic.FiragaEntity) BaseKHEntity(online.kingdomkeys.kingdomkeys.entity.mob.BaseKHEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) FirazaEntity(online.kingdomkeys.kingdomkeys.entity.magic.FirazaEntity) MoogleEntity(online.kingdomkeys.kingdomkeys.entity.mob.MoogleEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) SoRCoreTileEntity(online.kingdomkeys.kingdomkeys.entity.block.SoRCoreTileEntity) FiraEntity(online.kingdomkeys.kingdomkeys.entity.magic.FiraEntity) ShadowEntity(online.kingdomkeys.kingdomkeys.entity.mob.ShadowEntity) WitherEntity(net.minecraft.entity.boss.WitherEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) VolleyShotEntity(online.kingdomkeys.kingdomkeys.entity.shotlock.VolleyShotEntity) MarluxiaEntity(online.kingdomkeys.kingdomkeys.entity.mob.MarluxiaEntity) ThunderBoltEntity(online.kingdomkeys.kingdomkeys.entity.magic.ThunderBoltEntity) MPOrbEntity(online.kingdomkeys.kingdomkeys.entity.MPOrbEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) RagnarokShotEntity(online.kingdomkeys.kingdomkeys.entity.shotlock.RagnarokShotEntity) DuskEntity(online.kingdomkeys.kingdomkeys.entity.mob.DuskEntity) MobEntity(net.minecraft.entity.MobEntity) Entity(net.minecraft.entity.Entity) HPOrbEntity(online.kingdomkeys.kingdomkeys.entity.HPOrbEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) FireEntity(online.kingdomkeys.kingdomkeys.entity.magic.FireEntity) ArrayList(java.util.ArrayList) LivingEntity(net.minecraft.entity.LivingEntity) Entry(java.util.Map.Entry) ResourceLocation(net.minecraft.util.ResourceLocation) ItemEntity(net.minecraft.entity.item.ItemEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) ModMagic(online.kingdomkeys.kingdomkeys.magic.ModMagic) Magic(online.kingdomkeys.kingdomkeys.magic.Magic) SCOpenAlignmentScreen(online.kingdomkeys.kingdomkeys.network.stc.SCOpenAlignmentScreen) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) IPlayerCapabilities(online.kingdomkeys.kingdomkeys.capability.IPlayerCapabilities) SCSyncCapabilityPacket(online.kingdomkeys.kingdomkeys.network.stc.SCSyncCapabilityPacket) ReactionCommand(online.kingdomkeys.kingdomkeys.reactioncommands.ReactionCommand) Vector3d(net.minecraft.util.math.vector.Vector3d) WitherEntity(net.minecraft.entity.boss.WitherEntity) Map(java.util.Map) HashMap(java.util.HashMap) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 10 with MonsterEntity

use of net.minecraft.entity.monster.MonsterEntity in project Kingdom-Keys by Wehavecookies56.

the class DriveFormLimit method getLimitFormXP.

@SubscribeEvent
public static void getLimitFormXP(LivingAttackEvent event) {
    if (!event.getEntity().world.isRemote && event.getEntityLiving() instanceof MonsterEntity) {
        if (event.getSource().getTrueSource() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getSource().getTrueSource();
            IPlayerCapabilities playerData = ModCapabilities.getPlayer(player);
            if (playerData != null && playerData.getActiveDriveForm().equals(Strings.Form_Limit) && playerData.hasShotMaxShotlock()) {
                double mult = Double.parseDouble(ModConfigs.driveFormXPMultiplier.get(2).split(",")[1]);
                playerData.setDriveFormExp(player, playerData.getActiveDriveForm(), (int) (playerData.getDriveFormExp(playerData.getActiveDriveForm()) + (1 * mult)));
                playerData.setHasShotMaxShotlock(false);
                PacketHandler.sendTo(new SCSyncCapabilityPacket(playerData), (ServerPlayerEntity) player);
            }
        }
    }
}
Also used : MonsterEntity(net.minecraft.entity.monster.MonsterEntity) IPlayerCapabilities(online.kingdomkeys.kingdomkeys.capability.IPlayerCapabilities) SCSyncCapabilityPacket(online.kingdomkeys.kingdomkeys.network.stc.SCSyncCapabilityPacket) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

MonsterEntity (net.minecraft.entity.monster.MonsterEntity)14 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)9 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)7 Entity (net.minecraft.entity.Entity)5 LivingEntity (net.minecraft.entity.LivingEntity)5 MobEntity (net.minecraft.entity.MobEntity)5 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)5 ItemEntity (net.minecraft.entity.item.ItemEntity)5 VillagerEntity (net.minecraft.entity.merchant.villager.VillagerEntity)4 IPlayerCapabilities (online.kingdomkeys.kingdomkeys.capability.IPlayerCapabilities)4 SCSyncCapabilityPacket (online.kingdomkeys.kingdomkeys.network.stc.SCSyncCapabilityPacket)4 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 AbstractJobGuard (com.minecolonies.coremod.colony.jobs.AbstractJobGuard)2 Permissions (com.minecolonies.coremod.colony.permissions.Permissions)2 EntityCitizen (com.minecolonies.coremod.entity.citizen.EntityCitizen)2 ArrayList (java.util.ArrayList)2 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)2 WitherEntity (net.minecraft.entity.boss.WitherEntity)2 ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)2