Search in sources :

Example 31 with EntityArmorStand

use of net.minecraft.entity.item.EntityArmorStand in project Patcher by Sk1erLLC.

the class EntityCulling method shouldRenderEntity.

/**
 * Fire rays from the player's eyes, detecting on if it can see an entity or not.
 * If it can see an entity, continue to render the entity, otherwise save some time
 * performing rendering and cancel the entity render.
 *
 * @param event {@link RenderLivingEvent.Pre<EntityLivingBase>}
 */
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void shouldRenderEntity(RenderLivingEvent.Pre<EntityLivingBase> event) {
    if (!PatcherConfig.entityCulling || !shouldPerformCulling) {
        return;
    }
    // #if MC==10809
    EntityLivingBase entity = event.entity;
    // #else
    // $$ EntityLivingBase entity = event.getEntity();
    // #endif
    boolean armorstand = entity instanceof EntityArmorStand;
    if (entity == mc.thePlayer || entity.worldObj != mc.thePlayer.worldObj || (PatcherConfig.checkArmorstandRules && armorstand && ((EntityArmorStand) entity).hasMarker()) || (entity.isInvisibleToPlayer(mc.thePlayer) && !armorstand)) // #if MC==11202
    // $$ || entity.isGlowing()
    // #endif
    {
        return;
    }
    if (checkEntity(entity)) {
        event.setCanceled(true);
        if (!canRenderName(entity)) {
            return;
        }
        if ((PatcherConfig.dontCullNametags && entity instanceof EntityPlayer) || (PatcherConfig.dontCullEntityNametags && !armorstand) || (PatcherConfig.dontCullArmorStandNametags && armorstand)) {
            // #if MC==10809
            double x = event.x;
            double y = event.y;
            double z = event.z;
            RendererLivingEntity<EntityLivingBase> renderer = event.renderer;
            // #else
            // $$ double x = event.getX();
            // $$ double y = event.getY();
            // $$ double z = event.getZ();
            // $$ RenderLivingBase<EntityLivingBase> renderer = event.getRenderer();
            // #endif
            renderer.renderName(entity, x, y, z);
        }
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 32 with EntityArmorStand

use of net.minecraft.entity.item.EntityArmorStand in project Patcher by Sk1erLLC.

the class EntityRendering method cancelRendering.

@SubscribeEvent
public void cancelRendering(RenderLivingEvent.Pre<? extends EntityLivingBase> event) {
    // #if MC==10809
    EntityLivingBase entity = event.entity;
    // #endif
    if ((PatcherConfig.disableArmorstands && entity instanceof EntityArmorStand) || (PatcherConfig.disableSemitransparentEntities && entity.isInvisible() && entity instanceof EntityPlayer)) {
        event.setCanceled(true);
    }
    final float entityDistance = entity.getDistanceToEntity(mc.thePlayer);
    if (PatcherConfig.entityRenderDistanceToggle && EntityCulling.shouldPerformCulling) {
        if (entityDistance > PatcherConfig.entityRenderDistance) {
            event.setCanceled(true);
        } else if (entity instanceof IMob && entityDistance > PatcherConfig.hostileEntityRenderDistance) {
            event.setCanceled(true);
        } else if ((entity instanceof EntityAnimal || entity instanceof EntityAmbientCreature || entity instanceof EntityWaterMob) && entityDistance > PatcherConfig.passiveEntityRenderDistance) {
            event.setCanceled(true);
        } else if (entity instanceof EntityPlayer && entityDistance > PatcherConfig.playerRenderDistance) {
            event.setCanceled(true);
        }
    }
}
Also used : IMob(net.minecraft.entity.monster.IMob) EntityWaterMob(net.minecraft.entity.passive.EntityWaterMob) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) EntityAmbientCreature(net.minecraft.entity.passive.EntityAmbientCreature) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 33 with EntityArmorStand

use of net.minecraft.entity.item.EntityArmorStand in project Wynntils by Wynntils.

the class TotemTracker method onTotemRename.

public void onTotemRename(PacketEvent<SPacketEntityMetadata> e) {
    if (!Reference.onWorld)
        return;
    String name = Utils.getNameFromMetadata(e.getPacket().getDataManagerEntries());
    if (name == null || name.isEmpty())
        return;
    Entity entity = getBufferedEntity(e.getPacket().getEntityId());
    if (!(entity instanceof EntityArmorStand))
        return;
    if (totemState == TotemState.PREPARING || totemState == TotemState.ACTIVE) {
        Matcher m = SHAMAN_TOTEM_TIMER.matcher(name);
        if (m.find()) {
            // We got a armor stand with a timer nametag
            if (totemState == TotemState.PREPARING) {
                // Widen search range until found
                double acceptableDistance = 3.0 + (System.currentTimeMillis() - totemPreparedTimestamp) / 1000d;
                double distanceXZ = Math.abs(entity.posX - totemX) + Math.abs(entity.posZ - totemZ);
                if (distanceXZ < acceptableDistance && entity.posY <= (totemY + 2.0 + (acceptableDistance / 3.0)) && entity.posY >= ((totemY + 2.0))) {
                    // Update totem location if it was too far away
                    totemX = entity.posX;
                    totemY = entity.posY - 2.0;
                    totemZ = entity.posZ;
                }
            }
            double distanceXZ = Math.abs(entity.posX - totemX) + Math.abs(entity.posZ - totemZ);
            if (distanceXZ < 1.0 && entity.posY <= (totemY + 3.0) && entity.posY >= ((totemY + 2.0))) {
                // ... and it's close to our totem; regard this as our timer
                int time = Integer.parseInt(m.group(1));
                if (totemTime == -1) {
                    totemTime = time;
                    totemState = TotemState.ACTIVE;
                    postEvent(new SpellEvent.TotemActivated(totemTime, new Location(totemX, totemY, totemZ)));
                } else if (time != totemTime) {
                    if (time > totemTime) {
                        // Timer restarted using uproot
                        postEvent(new SpellEvent.TotemRenewed(time, new Location(totemX, totemY, totemZ)));
                    }
                    totemTime = time;
                }
            }
            return;
        }
    }
    Matcher m2 = MOB_TOTEM_NAME.matcher(name);
    if (m2.find()) {
        int mobTotemId = e.getPacket().getEntityId();
        MobTotem mobTotem = new MobTotem(mobTotemId, new Location(entity.posX, entity.posY - 4.5, entity.posZ), m2.group(1));
        mobTotemUnstarted.put(mobTotemId, mobTotem);
        return;
    }
    for (MobTotem mobTotem : mobTotemUnstarted.values()) {
        if (entity.posX == mobTotem.getLocation().getX() && entity.posZ == mobTotem.getLocation().getZ() && entity.posY == mobTotem.getLocation().getY() + 4.7) {
            Matcher m3 = MOB_TOTEM_TIMER.matcher(name);
            if (m3.find()) {
                int minutes = Integer.parseInt(m3.group(1));
                int seconds = Integer.parseInt(m3.group(2));
                mobTotemStarted.put(mobTotem.totemId, mobTotem);
                mobTotemUnstarted.remove(mobTotem.totemId);
                postEvent(new SpellEvent.MobTotemActivated(mobTotem, minutes * 60 + seconds + 1));
                return;
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) SpellEvent(com.wynntils.core.events.custom.SpellEvent) Matcher(java.util.regex.Matcher) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) Location(com.wynntils.core.utils.objects.Location)

Example 34 with EntityArmorStand

use of net.minecraft.entity.item.EntityArmorStand in project Wynntils by Wynntils.

the class LabelDetector method handleLabel.

public static void handleLabel(String label, String formattedLabel, Location location, Entity entity) {
    if (SERVICES_MAP.keySet().stream().anyMatch(l -> l.equals(formattedLabel))) {
        if (entity instanceof EntityArmorStand) {
            detectedServices.put(location, SERVICES_MAP.get(formattedLabel));
        }
        // (typically item frames outside the shop)
        return;
    }
    if (IGNORE.stream().anyMatch(l -> l.equals(label)))
        return;
    Matcher m1 = GATHERING_LABEL.matcher(label);
    if (m1.find()) {
        Location offsetLocation = location.add(0, 1, 0);
        registerTypeLocation(BakerType.GATHER, offsetLocation);
        return;
    }
    if (label.equals("NPC")) {
        registerTypeLocation(BakerType.NPC, location);
        return;
    }
    if (label.equals("Click for Options")) {
        registerTypeLocation(BakerType.TERRITORY, location);
        return;
    }
    if (formattedLabel.equals("§6Dungeon")) {
        registerTypeLocation(BakerType.DUNGEON, location);
        return;
    }
    if (formattedLabel.equals("§cRaid")) {
        registerTypeLocation(BakerType.RAID, location);
        return;
    }
    if (formattedLabel.equals("§cBoss Altar")) {
        registerTypeLocation(BakerType.BOSS_ALTAR, location);
        return;
    }
    if (formattedLabel.matches("^§b.*'s §7Shop$")) {
        registerTypeLocation(BakerType.BOOTH, location);
        Location offsetLocation = location.add(0, -1, 0);
        registerTypeLocation(BakerType.BOOTH_LINE_2, offsetLocation);
        return;
    }
    if (label.matches("Left-Click to set up booth")) {
        registerName("Unclaimed", "Unclaimed", location);
        registerTypeLocation(BakerType.BOOTH, location);
        return;
    }
    // Send the label on to the baker
    registerName(label, formattedLabel, location);
}
Also used : Matcher(java.util.regex.Matcher) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) Location(com.wynntils.core.utils.objects.Location)

Example 35 with EntityArmorStand

use of net.minecraft.entity.item.EntityArmorStand in project ElementalSorcery by Yuzunyannn.

the class VillageESHall method setArmorStand.

private EntityArmorStand setArmorStand(int x, int y, int z, World world) {
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
    AxisAlignedBB box = new AxisAlignedBB(blockpos.getX(), blockpos.getY(), blockpos.getZ(), blockpos.getX() + 1, blockpos.getY() + 1, blockpos.getZ() + 1);
    List<EntityArmorStand> list = world.getEntitiesWithinAABB(EntityArmorStand.class, box);
    if (list != null && list.size() != 0)
        return list.get(0);
    EntityArmorStand armorStand = new EntityArmorStand(world, blockpos.getX() + 0.5, blockpos.getY() + 0.5, blockpos.getZ() + 0.5);
    byte status = armorStand.getDataManager().get(EntityArmorStand.STATUS);
    status = (byte) (status | 4);
    armorStand.getDataManager().set(EntityArmorStand.STATUS, status);
    switch(this.getCoordBaseMode()) {
        case NORTH:
            armorStand.rotationYaw = -45;
            break;
        case SOUTH:
            armorStand.rotationYaw = -135;
            break;
        case EAST:
            armorStand.rotationYaw = 45;
            break;
        case WEST:
            armorStand.rotationYaw = -45;
            break;
        default:
            break;
    }
    world.spawnEntity(armorStand);
    return armorStand;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockPos(net.minecraft.util.math.BlockPos) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand)

Aggregations

EntityArmorStand (net.minecraft.entity.item.EntityArmorStand)36 Entity (net.minecraft.entity.Entity)13 BlockPos (net.minecraft.util.math.BlockPos)8 ArrayList (java.util.ArrayList)7 EntityItemFrame (net.minecraft.entity.item.EntityItemFrame)7 ItemStack (net.minecraft.item.ItemStack)7 EntityFallingBlock (net.minecraft.entity.item.EntityFallingBlock)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 EntityBoat (net.minecraft.entity.item.EntityBoat)5 EntityPig (net.minecraft.entity.passive.EntityPig)5 TileEntity (net.minecraft.tileentity.TileEntity)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 Location (com.wynntils.core.utils.objects.Location)3 Matcher (java.util.regex.Matcher)3 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)3 EntityEnderPearl (net.minecraft.entity.item.EntityEnderPearl)3 EntityItem (net.minecraft.entity.item.EntityItem)3 RayTraceResult (net.minecraft.util.math.RayTraceResult)3 Iterator (java.util.Iterator)2