Search in sources :

Example 21 with EntityType

use of net.minecraft.entity.EntityType in project minecolonies by ldtteam.

the class HordeRaidEvent method onUpdate.

@Override
public void onUpdate() {
    if (status == EventStatus.PREPARING) {
        prepareEvent();
    }
    updateRaidBar();
    colony.getRaiderManager().setNightsSinceLastRaid(0);
    if (horde.hordeSize <= 0) {
        status = EventStatus.DONE;
    }
    if (!respawns.isEmpty()) {
        for (final Tuple<EntityType<?>, BlockPos> entry : respawns) {
            final BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(entry.getB(), colony, MAX_RESPAWN_DEVIATION, spawnPoint, MIN_CENTER_DISTANCE, 10);
            if (spawnPos != null) {
                RaiderMobUtils.spawn(entry.getA(), 1, spawnPos, colony.getWorld(), colony, id);
            }
        }
        respawns.clear();
        return;
    }
    if (boss.size() + archers.size() + normal.size() < horde.numberOfBosses + horde.numberOfRaiders + horde.numberOfArchers) {
        final BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(spawnPoint, colony, MAX_RESPAWN_DEVIATION, spawnPoint, MIN_CENTER_DISTANCE, 10);
        if (spawnPos != null) {
            spawnHorde(spawnPos, colony, id, horde.numberOfBosses - boss.size(), horde.numberOfArchers - archers.size(), horde.numberOfRaiders - normal.size());
        }
    }
    if (horde.numberOfBosses + horde.numberOfRaiders + horde.numberOfArchers < Math.round(horde.initialSize * 0.05)) {
        status = EventStatus.DONE;
    }
    for (final Entity entity : getEntities()) {
        if (!entity.isAlive() || !WorldUtil.isEntityBlockLoaded(colony.getWorld(), new BlockPos(entity.position()))) {
            entity.remove();
            respawns.add(new Tuple<>(entity.getType(), new BlockPos(entity.position())));
            continue;
        }
        if (colony.getRaiderManager().areSpiesEnabled()) {
            ((LivingEntity) entity).addEffect(new EffectInstance(Effects.GLOWING, 550));
        }
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BlockPos(net.minecraft.util.math.BlockPos) EffectInstance(net.minecraft.potion.EffectInstance)

Example 22 with EntityType

use of net.minecraft.entity.EntityType in project Enchanted by Favouriteless.

the class AbstractRite method differenceAt.

/**
 * Gets the number of extra requirement entities over the rite requirements at a given position
 * @param world
 * @param pos
 * @return No. of extra requirement entities, -1 if not valid.
 */
public int differenceAt(World world, BlockPos pos) {
    for (CirclePart circlePart : CIRCLES_REQUIRED.keySet()) {
        if (!circlePart.match(world, pos, CIRCLES_REQUIRED.get(circlePart))) {
            return -1;
        }
    }
    List<Entity> allEntities = world.getEntities(null, new AxisAlignedBB(pos.offset(-7, 0, -7), pos.offset(7, 1, 7)));
    HashMap<Item, Integer> items = new HashMap<>();
    HashMap<EntityType<?>, Integer> entities = new HashMap<>();
    for (Entity entity : allEntities) {
        // Get items/entities in area
        if (entity instanceof ItemEntity) {
            ItemEntity itemEntity = (ItemEntity) entity;
            ItemStack itemStack = itemEntity.getItem();
            if (!items.containsKey(itemStack.getItem())) {
                items.put(itemStack.getItem(), itemStack.getCount());
            } else {
                items.put(itemStack.getItem(), items.get(itemStack.getItem()) + itemStack.getCount());
            }
        } else {
            if (!entities.containsKey(entity.getType())) {
                entities.put(entity.getType(), 1);
            } else {
                entities.put(entity.getType(), entities.get(entity.getType()) + 1);
            }
        }
    }
    int diff = 0;
    if (!ITEMS_REQUIRED.isEmpty()) {
        for (Item item : ITEMS_REQUIRED.keySet()) {
            // Check if enough items
            if (!(items.containsKey(item) && items.get(item) >= ITEMS_REQUIRED.get(item)))
                return -1;
        }
        for (Item item : items.keySet()) {
            if (!ITEMS_REQUIRED.containsKey(item))
                diff += items.get(item);
        }
    }
    if (!ENTITIES_REQUIRED.isEmpty()) {
        for (EntityType<?> type : ENTITIES_REQUIRED.keySet()) {
            // Check if enough entities
            if (!(entities.containsKey(type) && entities.get(type) >= ENTITIES_REQUIRED.get(type)))
                return -1;
        }
        for (EntityType<?> type : entities.keySet()) {
            if (!ENTITIES_REQUIRED.containsKey(type))
                diff += entities.get(type);
        }
    }
    return diff;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ChalkGoldTileEntity(com.favouriteless.enchanted.common.tileentity.ChalkGoldTileEntity) AltarTileEntity(com.favouriteless.enchanted.common.tileentity.AltarTileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TileEntity(net.minecraft.tileentity.TileEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) HashMap(java.util.HashMap) EntityType(net.minecraft.entity.EntityType) Item(net.minecraft.item.Item) CirclePart(com.favouriteless.enchanted.common.rites.util.CirclePart) ItemStack(net.minecraft.item.ItemStack)

Example 23 with EntityType

use of net.minecraft.entity.EntityType in project Vampirism by TeamLapen.

the class VampirismEntityRegistry method applyNewResources.

public void applyNewResources(Map<ResourceLocation, Integer> valuesIn, int multiplier) {
    this.bloodValues.putAll(valuesIn);
    this.bloodMultiplier = multiplier;
    Map<ResourceLocation, BiteableEntry> biteables = Maps.newHashMap();
    Set<ResourceLocation> blacklist = Sets.newHashSet();
    float bloodValueMultiplier = bloodMultiplier / 10F;
    final IConvertingHandler defaultHandler = defaultConvertingHandlerCreator.apply(null);
    for (Map.Entry<EntityType<? extends CreatureEntity>, IConvertingHandler> entry : convertibles.entrySet()) {
        ResourceLocation id = entry.getKey().getRegistryName();
        if (id == null) {
            LOGGER.warn("Cannot register convertible {} since there is no EntityString for it", entry.getKey());
            continue;
        }
        Integer blood = valuesIn.remove(id);
        if (blood == null) {
            LOGGER.warn("Missing blood value for convertible creature {} ({})", entry.getKey().getDescription(), id);
            continue;
        }
        blood = Math.round(blood * bloodValueMultiplier);
        LOGGER.debug("Registering convertible {} with blood {} and handler {}", entry.getKey().getDescription().getString(), blood, entry.getValue().getClass().getName());
        BiteableEntry biteEntry = new BiteableEntry(blood, (entry.getValue() == null ? defaultHandler : entry.getValue()));
        biteables.put(id, biteEntry);
    }
    LOGGER.info("Registered {} convertibles", biteables.size());
    for (Map.Entry<ResourceLocation, Integer> entry : valuesIn.entrySet()) {
        int blood = Math.abs(Math.round(entry.getValue() * bloodValueMultiplier));
        if (blood == 0) {
            blacklist.add(entry.getKey());
        } else {
            biteables.put(entry.getKey(), new BiteableEntry(blood));
        }
    }
    biteableEntryManager.setNewBiteables(biteables, blacklist);
}
Also used : CreatureEntity(net.minecraft.entity.CreatureEntity) IConvertingHandler(de.teamlapen.vampirism.api.entity.convertible.IConvertingHandler) EntityType(net.minecraft.entity.EntityType) ResourceLocation(net.minecraft.util.ResourceLocation) BiteableEntry(de.teamlapen.vampirism.api.entity.BiteableEntry) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 24 with EntityType

use of net.minecraft.entity.EntityType in project Vampirism by TeamLapen.

the class TaskItem method generateTaskToolTip.

private void generateTaskToolTip(ITaskInstance taskInfo, List<ITextComponent> toolTips) {
    Task task = taskInfo.getTask();
    toolTips.clear();
    toolTips.add(task.getTranslation().plainCopy().withStyle(this.screen.getTaskContainer().getFactionColor()));
    if (task.useDescription()) {
        toolTips.add(task.getDescription());
        toolTips.add(new StringTextComponent(" "));
    }
    if (this.screen.getTaskContainer().isTaskNotAccepted(taskInfo)) {
        toolTips.add(new TranslationTextComponent("gui.vampirism.taskmaster.not_accepted"));
    } else {
        for (List<TaskRequirement.Requirement<?>> requirements : task.getRequirement().requirements().values()) {
            if (requirements == null)
                continue;
            TaskRequirement.Type type = requirements.get(0).getType();
            boolean completed = this.screen.getTaskContainer().areRequirementsCompleted(taskInfo, type);
            IFormattableTextComponent title = new TranslationTextComponent(type.getTranslationKey()).append(":");
            if (completed) {
                title.withStyle(TextFormatting.STRIKETHROUGH);
            }
            toolTips.add(title);
            for (TaskRequirement.Requirement<?> requirement : requirements) {
                IFormattableTextComponent desc;
                int completedAmount = this.screen.getTaskContainer().getRequirementStatus(taskInfo, requirement);
                switch(type) {
                    case ITEMS:
                        desc = ((Item) requirement.getStat(this.factionPlayer)).getDescription().plainCopy().append(" " + completedAmount + "/" + requirement.getAmount(this.factionPlayer));
                        break;
                    case STATS:
                        desc = new TranslationTextComponent("stat." + requirement.getStat(this.factionPlayer).toString().replace(':', '.')).append(" " + completedAmount + "/" + requirement.getAmount(this.factionPlayer));
                        break;
                    case ENTITY:
                        desc = (((EntityType<?>) requirement.getStat(this.factionPlayer)).getDescription().plainCopy().append(" " + completedAmount + "/" + requirement.getAmount(this.factionPlayer)));
                        break;
                    case ENTITY_TAG:
                        // noinspection unchecked
                        desc = new TranslationTextComponent("tasks.vampirism." + ((ITag.INamedTag<EntityType<?>>) requirement.getStat(this.factionPlayer)).getName()).append(" " + completedAmount + "/" + requirement.getAmount(this.factionPlayer));
                        break;
                    default:
                        desc = new TranslationTextComponent(task.getTranslationKey() + ".req." + requirement.getId().toString().replace(':', '.'));
                        break;
                }
                if (completed || this.screen.getTaskContainer().isRequirementCompleted(taskInfo, requirement)) {
                    desc.withStyle(TextFormatting.STRIKETHROUGH);
                }
                toolTips.add(new StringTextComponent("  ").append(desc));
            }
        }
    }
    this.toolTips.put(taskInfo, toolTips);
}
Also used : Task(de.teamlapen.vampirism.api.entity.player.task.Task) TaskRequirement(de.teamlapen.vampirism.api.entity.player.task.TaskRequirement) EntityType(net.minecraft.entity.EntityType) TaskRequirement(de.teamlapen.vampirism.api.entity.player.task.TaskRequirement) ItemRequirement(de.teamlapen.vampirism.player.tasks.req.ItemRequirement)

Example 25 with EntityType

use of net.minecraft.entity.EntityType in project alaskanativecraft by Platymemo.

the class ShoulderPtarmiganFeatureRenderer method renderShoulderPtarmigan.

private void renderShoulderPtarmigan(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T player, float limbAngle, float limbDistance, float headYaw, float headPitch, boolean leftShoulder) {
    NbtCompound compoundTag = leftShoulder ? player.getShoulderEntityLeft() : player.getShoulderEntityRight();
    EntityType.get(compoundTag.getString("id")).filter((entityType) -> entityType == AlaskaEntities.PTARMIGAN).ifPresent((entityType) -> {
        matrices.push();
        matrices.translate(leftShoulder ? 0.4D : -0.4D, player.isInSneakingPose() ? -1.3D : -1.5D, 0.0D);
        VertexConsumer vertexConsumer = vertexConsumers.getBuffer(this.model.getLayer(PtarmiganEntityRenderer.TEXTURES[compoundTag.getInt("Type")]));
        this.model.poseOnShoulder(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, limbAngle, limbDistance, headYaw, headPitch, player.age);
        matrices.pop();
    });
}
Also used : EntityType(net.minecraft.entity.EntityType) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Environment(net.fabricmc.api.Environment) MatrixStack(net.minecraft.client.util.math.MatrixStack) AlaskaModels(com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels) PlayerEntityModel(net.minecraft.client.render.entity.model.PlayerEntityModel) VertexConsumer(net.minecraft.client.render.VertexConsumer) EntityModelLoader(net.minecraft.client.render.entity.model.EntityModelLoader) FeatureRenderer(net.minecraft.client.render.entity.feature.FeatureRenderer) PtarmiganEntityRenderer(com.github.platymemo.alaskanativecraft.client.renderer.entity.PtarmiganEntityRenderer) NbtCompound(net.minecraft.nbt.NbtCompound) OverlayTexture(net.minecraft.client.render.OverlayTexture) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider) PtarmiganEntityModel(com.github.platymemo.alaskanativecraft.client.model.entity.PtarmiganEntityModel) AlaskaEntities(com.github.platymemo.alaskanativecraft.entity.AlaskaEntities) EnvType(net.fabricmc.api.EnvType) FeatureRendererContext(net.minecraft.client.render.entity.feature.FeatureRendererContext) NotNull(org.jetbrains.annotations.NotNull) NbtCompound(net.minecraft.nbt.NbtCompound) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Aggregations

EntityType (net.minecraft.entity.EntityType)48 Entity (net.minecraft.entity.Entity)16 ResourceLocation (net.minecraft.util.ResourceLocation)13 LivingEntity (net.minecraft.entity.LivingEntity)11 CompoundNBT (net.minecraft.nbt.CompoundNBT)11 BlockPos (net.minecraft.util.math.BlockPos)11 PlayerEntity (net.minecraft.entity.player.PlayerEntity)9 ItemStack (net.minecraft.item.ItemStack)9 HashMap (java.util.HashMap)6 World (net.minecraft.world.World)5 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 EffectInstance (net.minecraft.potion.EffectInstance)4 List (java.util.List)3 Nonnull (javax.annotation.Nonnull)3 MobEntity (net.minecraft.entity.MobEntity)3 TileEntity (net.minecraft.tileentity.TileEntity)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 IPlacementHandler (com.ldtteam.structurize.placement.handlers.placement.IPlacementHandler)2 Random (java.util.Random)2