From 3a1917c8a0af4157cc1e6d5f3986e89377f245d8 Mon Sep 17 00:00:00 2001 From: ThatGravyBoat Date: Sun, 11 Jul 2021 18:57:24 -0230 Subject: Added Mining Overlay including drill bar and heat bar Added mana cost display Update Location Stuff Added new mining events stopped scoreboard logging spam removed missing location logging as hypixel dumb and sends the wrong thing once and a while causing it to log useless stuff. Added DEV Commands --- .../api/sbentities/EntityTypeHelper.java | 21 ++++++++++++++++ .../api/sbentities/EntityTypeRegistry.java | 26 ++++++++++++++++++++ .../skyblockhud/api/sbentities/SkyBlockEntity.java | 28 ++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java (limited to 'src/main/java/com/thatgravyboat/skyblockhud/api/sbentities') 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 0000000..d1ad8d2 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java @@ -0,0 +1,21 @@ +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.init.Blocks; + +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; + } +} 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 0000000..995bc9b --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java @@ -0,0 +1,26 @@ +package com.thatgravyboat.skyblockhud.api.sbentities; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityEnderman; + +import java.util.List; +import java.util.Map; + +public class EntityTypeRegistry { + + private static final Map, List> entities = Maps.newHashMap(); + + static { + entities.put(EntityEnderman.class, ImmutableList.of(SkyBlockEntity.of("zealot", EntityTypeHelper::isZealot))); + } + + 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 0000000..78b48df --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java @@ -0,0 +1,28 @@ +package com.thatgravyboat.skyblockhud.api.sbentities; + +import net.minecraft.entity.Entity; + +import java.util.function.Predicate; + +public class SkyBlockEntity { + + private final String name; + private final Predicate predicate; + + public static SkyBlockEntity of(String name, Predicate predicate) { + return new SkyBlockEntity(name, predicate); + } + + private SkyBlockEntity(String name, Predicate predicate) { + this.name = name; + this.predicate = predicate; + } + + public String getName() { + return name; + } + + public boolean isEntity(Entity entity) { + return predicate.test(entity); + } +} -- cgit