Search in sources :

Example 6 with EntityMob

use of net.minecraft.entity.monster.EntityMob in project VanillaTeleporter by dyeo.

the class BlockTeleporter method onEntityWalk.

@Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
    TeleporterNode destinationNode = null;
    IBlockState state = world.getBlockState(pos);
    EnumType type = EnumType.byMetadata(getMetaFromState(state));
    if (entity instanceof EntityLivingBase && entity.hasCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null)) {
        ITeleportHandler teleportHandler = entity.getCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null);
        if (!world.isRemote) {
            if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
                teleportHandler.setOnTeleporter(entity.getPosition().distanceSq(pos) <= 1);
                teleportHandler.setDimension(entity.dimension);
                if (teleportHandler.getOnTeleporter()) {
                    boolean isHostile = (entity instanceof EntityMob) || (entity instanceof EntityWolf && ((EntityWolf) entity).isAngry());
                    boolean isPassive = (entity instanceof EntityAnimal);
                    if ((isHostile == false || isHostile == ModConfiguration.teleportHostileMobs) && (isPassive == false || isPassive == ModConfiguration.teleportPassiveMobs)) {
                        destinationNode = TeleporterUtility.teleport((EntityLivingBase) entity, pos);
                    }
                }
            }
        }
        if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
            TileEntityTeleporter tEnt = (TileEntityTeleporter) world.getTileEntity(pos);
            if (tEnt != null) {
                tEnt.spawnParticles();
            }
        }
        if (type.isRecall() && entity instanceof EntityPlayerMP && destinationNode != null) {
            WorldServer nextWorld = world.getMinecraftServer().worldServerForDimension(destinationNode.dimension);
            breakBlockRecall(world, nextWorld, pos, destinationNode.pos, state, (EntityPlayerMP) entity);
        }
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IBlockState(net.minecraft.block.state.IBlockState) TeleporterNode(net.dyeo.teleporter.teleport.TeleporterNode) ITeleportHandler(net.dyeo.teleporter.capabilities.ITeleportHandler) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) EntityWolf(net.minecraft.entity.passive.EntityWolf) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) TileEntityTeleporter(net.dyeo.teleporter.tileentity.TileEntityTeleporter)

Example 7 with EntityMob

use of net.minecraft.entity.monster.EntityMob in project PneumaticCraft by MineMaarten.

the class RenderTarget method render.

public void render(float partialTicks, boolean justRenderWhenHovering) {
    for (IEntityTrackEntry tracker : trackEntries) {
        tracker.render(entity, partialTicks);
    }
    double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks;
    double y = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks + entity.height / 2D;
    double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    float red;
    float green;
    float blue;
    float alpha = 0.5F;
    if (entity instanceof EntityDrone) {
        red = 1;
        green = 1;
        blue = 0;
    } else if (entity instanceof EntityMob || entity instanceof EntitySlime) {
        red = 1;
        green = 0;
        blue = 0;
    } else {
        red = 0;
        green = 1;
        blue = 0;
    }
    float size = entity.height * 0.5F;
    if (ticksExisted < 60) {
        size += 5 - Math.abs(ticksExisted) * 0.083F;
        alpha = Math.abs(ticksExisted) * 0.005F;
    }
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(180.0F - RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
    GL11.glColor4d(red, green, blue, alpha);
    float renderSize = oldSize + (size - oldSize) * partialTicks;
    circle1.render(renderSize, partialTicks);
    circle2.render(renderSize + 0.2D, partialTicks);
    int targetAcquireProgress = (int) ((ticksExisted - 50) / 0.7F);
    if (ticksExisted <= 120 && ticksExisted > 50) {
        GL11.glColor4d(0, 1, 0, 0.8D);
        RenderProgressBar.render(0D, 0.4D, 1.8D, 0.9D, 0, targetAcquireProgress);
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    FontRenderer fontRenderer = RenderManager.instance.getFontRenderer();
    GL11.glScaled(0.02D, 0.02D, 0.02D);
    GL11.glColor4d(red, green, blue, alpha);
    if (ticksExisted > 120) {
        if (justRenderWhenHovering && !isLookingAtTarget) {
            stat.closeWindow();
        } else {
            stat.openWindow();
        }
        textList = new ArrayList<String>();
        for (IEntityTrackEntry tracker : trackEntries) {
            tracker.addInfo(entity, textList);
        }
        stat.setText(textList);
        stat.render(-1, -1, partialTicks);
    } else if (ticksExisted > 50) {
        fontRenderer.drawString("Acquiring Target...", 0, 0, 0x7F7F7F);
        fontRenderer.drawString(targetAcquireProgress + "%", 37, 28, 0x002F00);
    } else if (ticksExisted < -30) {
        stat.closeWindow();
        //if(stat.getWidth() > stat.getMinWidth() || stat.getHeight() > stat.getMinHeight()) {
        //    stat.setText(new ArrayList<String>());
        stat.render(-1, -1, partialTicks);
        //            }
        fontRenderer.drawString("Lost Target!", 0, 0, 0xFF0000);
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    oldSize = size;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IEntityTrackEntry(pneumaticCraft.api.client.pneumaticHelmet.IEntityTrackEntry) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) EntitySlime(net.minecraft.entity.monster.EntitySlime) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 8 with EntityMob

use of net.minecraft.entity.monster.EntityMob in project PneumaticCraft by MineMaarten.

the class EntityTrackUpgradeHandler method update.

@Override
@SideOnly(Side.CLIENT)
public void update(EntityPlayer player, int rangeUpgrades) {
    ItemStack helmetStack = player.getCurrentArmor(3);
    String entityFilter = "";
    if (helmetStack != null)
        entityFilter = NBTUtil.getString(helmetStack, "entityFilter");
    double entityTrackRange = ENTITY_TRACKING_RANGE + rangeUpgrades * PneumaticValues.RANGE_UPGRADE_HELMET_RANGE_INCREASE;
    AxisAlignedBB bbBox = getAABBFromRange(player, rangeUpgrades);
    List<Entity> mobs = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bbBox);
    if (mobs.contains(player))
        mobs.remove(player);
    for (int i = 0; i < mobs.size(); i++) {
        if (player.getDistanceToEntity(mobs.get(i)) > entityTrackRange || !PneumaticCraftUtils.isEntityValidForFilter(entityFilter, mobs.get(i)) || MinecraftForge.EVENT_BUS.post(new EntityTrackEvent(mobs.get(i))))
            continue;
        boolean inList = false;
        for (int j = 0; j < targets.size(); j++) {
            if (targets.get(j).entity == mobs.get(i)) {
                inList = true;
                // cancel
                targets.get(j).ticksExisted = Math.abs(targets.get(j).ticksExisted);
                // targets
                break;
            }
        }
        if (!inList) {
            //player.worldObj.playSoundAtEntity(player, Sounds.CANNON_SOUND, 1.0F, 1.0F);
            targets.add(new RenderTarget(mobs.get(i)));
            if (mobs.get(i) instanceof EntityMob && !isEntityWithinPlayerFOV(player, mobs.get(i))) {
            //       HUDHandler.instance().addMessage(new ArmorMessage("A mob is sneaking up on you!", new ArrayList<String>(), 60, 0x70FF0000));
            }
        }
    }
    for (int j = 0; j < targets.size(); j++) {
        RenderTarget target = targets.get(j);
        if (target.entity.isDead || player.getDistanceToEntity(target.entity) > entityTrackRange + 5 || !PneumaticCraftUtils.isEntityValidForFilter(entityFilter, target.entity)) {
            if (target.ticksExisted > 0) {
                target.ticksExisted = -60;
            } else if (target.ticksExisted == -1) {
                targets.remove(target);
                j--;
            }
        }
    }
    if (targets.size() > ENTITY_TRACK_THRESHOLD) {
        if (!shouldStopSpamOnEntityTracking) {
            shouldStopSpamOnEntityTracking = true;
            HUDHandler.instance().addMessage(new ArmorMessage("Stopped spam on Entity Tracker", new ArrayList<String>(), 60, 0x7700AA00));
        }
    } else {
        shouldStopSpamOnEntityTracking = false;
    }
    List<String> text = new ArrayList<String>();
    for (RenderTarget target : targets) {
        boolean wasNegative = target.ticksExisted < 0;
        target.ticksExisted += CommonHUDHandler.getHandlerForPlayer(player).getSpeedFromUpgrades();
        if (target.ticksExisted >= 0 && wasNegative)
            target.ticksExisted = -1;
        target.update();
        if (target.isLookingAtTarget) {
            if (target.isInitialized()) {
                text.add(EnumChatFormatting.GRAY + target.entity.getCommandSenderName());
                text.addAll(target.getEntityText());
            } else {
                text.add(EnumChatFormatting.GRAY + "Acquiring target...");
            }
        }
    }
    if (text.size() == 0) {
        text.add("Filter mode: " + (entityFilter.equals("") ? "None" : entityFilter));
    }
    entityTrackInfo.setText(text);
    //Remove entities that don't need to be tracked anymore.
    Iterator<Entry<Entity, Integer>> iterator = targetingEntities.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<Entity, Integer> entry = iterator.next();
        Entity entity = entry.getKey();
        if (entry.getValue() >= 0)
            entry.setValue(entry.getValue() + 1);
        if (entity.isDead || !player.worldObj.getLoadedEntityList().contains(entity) || entry.getValue() > 50)
            iterator.remove();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityTrackEvent(pneumaticCraft.api.client.pneumaticHelmet.EntityTrackEvent) ArrayList(java.util.ArrayList) EntityMob(net.minecraft.entity.monster.EntityMob) Entry(java.util.Map.Entry) ItemStack(net.minecraft.item.ItemStack) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 9 with EntityMob

use of net.minecraft.entity.monster.EntityMob in project ArsMagica2 by Mithion.

the class EntityUtilities method makeSummon_MonsterFaction.

public static void makeSummon_MonsterFaction(EntityCreature entityliving, boolean storeForRevert) {
    if (isAIEnabled(entityliving) && !(entityliving instanceof IBossDisplayData)) {
        if (storeForRevert)
            storedTasks.put(entityliving.getEntityId(), new ArrayList(entityliving.targetTasks.taskEntries));
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.addTask(1, new EntityAIHurtByTarget(entityliving, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityPlayer.class, 0, true));
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null && entityliving.getAttackTarget() instanceof EntityMob)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        entityliving.getEntityData().setBoolean(isSummonKey, true);
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) ArrayList(java.util.ArrayList) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget)

Example 10 with EntityMob

use of net.minecraft.entity.monster.EntityMob in project ArsMagica2 by Mithion.

the class Disarm method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (target instanceof EntityLightMage || target instanceof EntityDarkMage)
        return false;
    if (target instanceof EntityPlayer && (!AMCore.config.getDisarmAffectsPlayers() || (!world.isRemote && !MinecraftServer.getServer().isPVPEnabled())))
        return false;
    if (target instanceof EntityPlayer && ((EntityPlayer) target).getHeldItem() != null && !target.worldObj.isRemote) {
        if (EnchantmentHelper.getEnchantmentLevel(AMEnchantments.soulbound.effectId, ((EntityPlayer) target).getHeldItem()) > 0)
            return true;
        ((EntityPlayer) target).dropOneItem(true);
        return true;
    } else if (target instanceof EntityMob && ((EntityMob) target).getHeldItem() != null) {
        if (EnchantmentHelper.getEnchantmentLevel(AMEnchantments.soulbound.effectId, ((EntityMob) target).getHeldItem()) > 0)
            return true;
        if (!world.isRemote) {
            EntityItem item = new EntityItem(world);
            ItemStack dropstack = ((EntityMob) target).getHeldItem().copy();
            if (dropstack.getMaxDamage() > 0)
                dropstack.setItemDamage((int) Math.floor(dropstack.getMaxDamage() * (0.8f + (world.rand.nextFloat() * 0.19f))));
            item.setEntityItemStack(dropstack);
            item.setPosition(target.posX, target.posY, target.posZ);
            world.spawnEntityInWorld(item);
        }
        ((EntityMob) target).setCurrentItemOrArmor(0, null);
        ((EntityMob) target).setAttackTarget(caster);
        Iterator it = ((EntityMob) target).tasks.taskEntries.iterator();
        boolean removed = false;
        while (it.hasNext()) {
            EntityAITaskEntry task = (EntityAITaskEntry) it.next();
            if (task.action instanceof EntityAIArrowAttack) {
                it.remove();
                removed = true;
                break;
            }
        }
        if (removed) {
            ((EntityMob) target).tasks.addTask(5, new EntityAIAttackOnCollide((EntityCreature) target, 0.5, true));
            ((EntityMob) target).setCanPickUpLoot(true);
        }
    } else if (target instanceof EntityEnderman) {
        int blockID = ((EntityEnderman) target).getCarryingData();
        int meta = ((EntityEnderman) target).getCarryingData();
        if (blockID > 0) {
            ((EntityEnderman) target).setCarryingData(0);
            ItemStack dropstack = new ItemStack(Block.getBlockById(blockID), 1, meta);
            EntityItem item = new EntityItem(world);
            item.setEntityItemStack(dropstack);
            item.setPosition(target.posX, target.posY, target.posZ);
            world.spawnEntityInWorld(item);
        }
        ((EntityMob) target).setAttackTarget(caster);
    }
    return false;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) EntityLightMage(am2.entities.EntityLightMage) EntityDarkMage(am2.entities.EntityDarkMage) EntityAIArrowAttack(net.minecraft.entity.ai.EntityAIArrowAttack) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) EntityItem(net.minecraft.entity.item.EntityItem) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)

Aggregations

EntityMob (net.minecraft.entity.monster.EntityMob)10 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ItemStack (net.minecraft.item.ItemStack)5 ArrayList (java.util.ArrayList)3 Entity (net.minecraft.entity.Entity)2 EntityLiving (net.minecraft.entity.EntityLiving)2 EntityDarkMage (am2.entities.EntityDarkMage)1 EntityLightMage (am2.entities.EntityLightMage)1 BuildingBuilder (com.minecolonies.coremod.colony.buildings.BuildingBuilder)1 JobGuard (com.minecolonies.coremod.colony.jobs.JobGuard)1 Permissions (com.minecolonies.coremod.colony.permissions.Permissions)1 EntityCitizen (com.minecolonies.coremod.entity.EntityCitizen)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 Iterator (java.util.Iterator)1 Entry (java.util.Map.Entry)1 ITeleportHandler (net.dyeo.teleporter.capabilities.ITeleportHandler)1 TeleporterNode (net.dyeo.teleporter.teleport.TeleporterNode)1 TileEntityTeleporter (net.dyeo.teleporter.tileentity.TileEntityTeleporter)1 IBlockState (net.minecraft.block.state.IBlockState)1