diff options
author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-11 18:57:24 -0230 |
---|---|---|
committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-11 18:57:24 -0230 |
commit | 3a1917c8a0af4157cc1e6d5f3986e89377f245d8 (patch) | |
tree | 0a25fdc3ad1fc48da3f0d06c501f772ac9cfc353 /src/main/java/com/thatgravyboat/skyblockhud/api | |
parent | 5a98a98dfc0009599b90280ae3a1f166de21e6e8 (diff) | |
download | SkyblockHud-Death-Defied-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.tar.gz SkyblockHud-Death-Defied-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.tar.bz2 SkyblockHud-Death-Defied-3a1917c8a0af4157cc1e6d5f3986e89377f245d8.zip |
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
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/api')
5 files changed, 152 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java b/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java new file mode 100644 index 0000000..9aad4c6 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java @@ -0,0 +1,61 @@ +package com.thatgravyboat.skyblockhud.api; + +import com.thatgravyboat.skyblockhud.DevModeConstants; +import com.thatgravyboat.skyblockhud.api.events.SkyBlockEntityKilled; +import com.thatgravyboat.skyblockhud.api.sbentities.EntityTypeRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.util.DamageSource; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class KillTracking { + + public static final Set<UUID> attackedEntities = new HashSet<>(); + + @SubscribeEvent + public void onAttack(AttackEntityEvent event) { + if (event.target != null) { + attackedEntities.add(event.target.getUniqueID()); + } + } + + @SubscribeEvent + public void onDeath(LivingDeathEvent event) { + if (DevModeConstants.mobDeathLogging) { + //Used for testing + System.out.println("----------------------------------------------------------------------------------------------------------------"); + System.out.println("Name : " + event.entity.getName()); + System.out.println("UUID : " + event.entity.getUniqueID()); + System.out.println("Tag : " + event.entity.serializeNBT()); + System.out.println("Damage : " + getDamageSourceString(event.source)); + System.out.println("SBH Entity ID: " + EntityTypeRegistry.getEntityId(event.entity)); + System.out.println("----------------------------------------------------------------------------------------------------------------"); + } + if (attackedEntities.contains(event.entity.getUniqueID())) { + if (EntityTypeRegistry.getEntityId(event.entity) != null) { + MinecraftForge.EVENT_BUS.post(new SkyBlockEntityKilled(EntityTypeRegistry.getEntityId(event.entity), event.entity)); + } + attackedEntities.remove(event.entity.getUniqueID()); + } + } + + public static String getDamageSourceString(DamageSource source) { + return ("{ " + source.getDamageType() + ", " + source.isDamageAbsolute() + ", " + source.isDifficultyScaled() + ", " + source.isFireDamage() + ", " + source.isProjectile() + ", " + source.isUnblockable() + ", " + source.isExplosion() + ", " + source.isMagicDamage() + ", " + source.isCreativePlayer() + ", " + source.getSourceOfDamage() + " }"); + } + + @SubscribeEvent + public void onWorldChange(EntityJoinWorldEvent event) { + if (event.entity != null) { + if (event.entity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { + attackedEntities.clear(); + } + } + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java new file mode 100644 index 0000000..9d02993 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java @@ -0,0 +1,16 @@ +package com.thatgravyboat.skyblockhud.api.events; + +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.Event; + +public class SkyBlockEntityKilled extends Event { + + public String id; + public Entity entity; + + public SkyBlockEntityKilled(String id, Entity entity) { + this.id = id; + this.entity = entity; + } + +} 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<Class<? extends Entity>, List<SkyBlockEntity>> 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<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); + } +} |