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));
}
}
}
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;
}
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);
}
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);
}
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();
});
}
Aggregations