diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-07 00:31:50 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-07 00:31:50 +0200 |
commit | 99773d6a593c444151503de315f127bea6f74d49 (patch) | |
tree | 9ee1ae505e5f82aba62f10c882af85a3acd6e483 /src/main/java/com/thatgravyboat/skyblockhud/api/sbentities | |
download | skyhanni-99773d6a593c444151503de315f127bea6f74d49.tar.gz skyhanni-99773d6a593c444151503de315f127bea6f74d49.tar.bz2 skyhanni-99773d6a593c444151503de315f127bea6f74d49.zip |
init lorenz mod
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/api/sbentities')
3 files changed, 90 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java new file mode 100644 index 000000000..bb14e5d21 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java @@ -0,0 +1,36 @@ +package com.thatgravyboat.skyblockhud.api.sbentities; + +import com.thatgravyboat.skyblockhud.location.LocationHandler; +import com.thatgravyboat.skyblockhud.location.Locations; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; + +public class EntityTypeHelper { + + public static boolean isZealot(Entity entity) { + if (entity instanceof EntityEnderman) { + EntityEnderman enderman = ((EntityEnderman) entity); + double maxHealthBase = enderman.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getBaseValue(); + if (maxHealthBase == 13000 || (maxHealthBase == 2000d && enderman.getHeldBlockState().getBlock().equals(Blocks.end_portal_frame))) { + return LocationHandler.getCurrentLocation().equals(Locations.DRAGONSNEST); + } + } + return false; + } + + public static boolean isCrypt(Entity entity) { + if (entity instanceof EntityZombie) { + EntityZombie zombie = ((EntityZombie) entity); + double maxHealthBase = zombie.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getBaseValue(); + if (maxHealthBase != 2000d) return false; + if (zombie.getEquipmentInSlot(0) == null || !zombie.getEquipmentInSlot(0).getItem().equals(Items.iron_sword)) return false; + if (zombie.getEquipmentInSlot(1) == null || !zombie.getEquipmentInSlot(1).getItem().equals(Items.chainmail_boots)) return false; + if (zombie.getEquipmentInSlot(2) == null || !zombie.getEquipmentInSlot(2).getItem().equals(Items.chainmail_leggings)) return false; + return zombie.getEquipmentInSlot(3) != null && zombie.getEquipmentInSlot(3).getItem().equals(Items.chainmail_chestplate); + } + return false; + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java new file mode 100644 index 000000000..6ff88fafb --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java @@ -0,0 +1,27 @@ +package com.thatgravyboat.skyblockhud.api.sbentities; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; +import java.util.List; +import java.util.Map; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntityZombie; + +public class EntityTypeRegistry { + + private static final Map<Class<? extends Entity>, List<SkyBlockEntity>> entities = Maps.newHashMap(); + + static { + entities.put(EntityEnderman.class, ImmutableList.of(SkyBlockEntity.of("ZEALOT", EntityTypeHelper::isZealot))); + entities.put(EntityZombie.class, ImmutableList.of(SkyBlockEntity.of("CRYPT_GHOUL", EntityTypeHelper::isCrypt))); + } + + public static String getEntityId(Entity entity) { + if (!entities.containsKey(entity.getClass())) return null; + for (SkyBlockEntity skyBlockEntity : entities.get(entity.getClass())) { + if (skyBlockEntity.isEntity(entity)) return skyBlockEntity.getName(); + } + return null; + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java new file mode 100644 index 000000000..bcd1196f5 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java @@ -0,0 +1,27 @@ +package com.thatgravyboat.skyblockhud.api.sbentities; + +import java.util.function.Predicate; +import net.minecraft.entity.Entity; + +public class SkyBlockEntity { + + private final String name; + private final Predicate<Entity> predicate; + + public static SkyBlockEntity of(String name, Predicate<Entity> predicate) { + return new SkyBlockEntity(name, predicate); + } + + private SkyBlockEntity(String name, Predicate<Entity> predicate) { + this.name = name; + this.predicate = predicate; + } + + public String getName() { + return name; + } + + public boolean isEntity(Entity entity) { + return predicate.test(entity); + } +} |