aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/api/sbentities')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java36
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java27
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java27
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);
+ }
+}