From 20b41b08bce0ae9dc987cebd042967ef41e08951 Mon Sep 17 00:00:00 2001 From: David Berdik Date: Sun, 6 Mar 2022 17:46:20 -0500 Subject: [PATCH] Add explicit casting to fix problems with the remapper not working properly. --- .../herobrine/NPC/Entity/HumanNPC.java | 11 ++++++----- .../herobrine/entity/CustomSkeleton.java | 11 ++++++----- .../herobrine/entity/CustomZombie.java | 19 ++++++++++--------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/theprogrammersworld/herobrine/NPC/Entity/HumanNPC.java b/src/main/java/net/theprogrammersworld/herobrine/NPC/Entity/HumanNPC.java index 29ab703..42d9728 100644 --- a/src/main/java/net/theprogrammersworld/herobrine/NPC/Entity/HumanNPC.java +++ b/src/main/java/net/theprogrammersworld/herobrine/NPC/Entity/HumanNPC.java @@ -2,6 +2,7 @@ package net.theprogrammersworld.herobrine.NPC.Entity; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; import net.theprogrammersworld.herobrine.Herobrine; import org.bukkit.Bukkit; @@ -53,7 +54,7 @@ public class HumanNPC { } public void setPitch(float pitch) { - ((HumanEntity) getEntity()).setXRot(pitch); + ((Entity) getEntity()).setXRot(pitch); } public void moveTo(Location loc) { @@ -86,7 +87,7 @@ public class HumanNPC { } public void setYaw(float yaw) { - ((ServerPlayer) getEntity()).setYRot(yaw); + ((Entity) getEntity()).setYRot(yaw); } public void lookAtPoint(Location point) { @@ -110,15 +111,15 @@ public class HumanNPC { } if (newYaw > 0.0D || newYaw < 180.0D) { - entity.setXRot((float) newPitch); - entity.setYRot((float) (newYaw - 90.0)); + ((Entity) entity).setXRot((float) newPitch); + ((Entity) entity).setYRot((float) (newYaw - 90.0)); entity.getBukkitEntity().setFlySpeed((float) (newYaw - 90.0) / 360); } } public void setYawA(float yaw) { - ((ServerPlayer) getEntity()).setYRot(yaw); + ((Entity) getEntity()).setYRot(yaw); } public org.bukkit.entity.Entity getBukkitEntity() { diff --git a/src/main/java/net/theprogrammersworld/herobrine/entity/CustomSkeleton.java b/src/main/java/net/theprogrammersworld/herobrine/entity/CustomSkeleton.java index dff9b2f..639fe2d 100644 --- a/src/main/java/net/theprogrammersworld/herobrine/entity/CustomSkeleton.java +++ b/src/main/java/net/theprogrammersworld/herobrine/entity/CustomSkeleton.java @@ -12,6 +12,7 @@ import org.bukkit.Color; import net.minecraft.network.chat.TextComponent; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.level.Level; import net.theprogrammersworld.herobrine.Herobrine; @@ -35,10 +36,10 @@ public class CustomSkeleton extends net.minecraft.world.entity.monster.Skeleton public void spawnDemon(Location loc) { - this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Demon.Speed")); - this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP")); - this.setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP")); - this.setCustomName(new TextComponent("Demon")); + ((LivingEntity) this).getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Demon.Speed")); + ((LivingEntity) this).getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP")); + ((LivingEntity) this).setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP")); + ((Entity) this).setCustomName(new TextComponent("Demon")); Skeleton entityCast = (Skeleton) this.getBukkitEntity(); @@ -68,7 +69,7 @@ public class CustomSkeleton extends net.minecraft.world.entity.monster.Skeleton .getInt("npc.Demon.Drops." + item + ".Count"))); } } - setHealth(0.0f); + ((LivingEntity) this).setHealth(0.0f); } @Override diff --git a/src/main/java/net/theprogrammersworld/herobrine/entity/CustomZombie.java b/src/main/java/net/theprogrammersworld/herobrine/entity/CustomZombie.java index c07839b..7abec40 100644 --- a/src/main/java/net/theprogrammersworld/herobrine/entity/CustomZombie.java +++ b/src/main/java/net/theprogrammersworld/herobrine/entity/CustomZombie.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack; import net.minecraft.network.chat.TextComponent; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.level.Level; import net.theprogrammersworld.herobrine.Herobrine; @@ -34,11 +35,11 @@ public class CustomZombie extends net.minecraft.world.entity.monster.Zombie impl private void spawnArtifactGuardian(Location loc) { - this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Guardian.Speed")); - this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP")); - this.setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP")); + ((LivingEntity) this).getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Guardian.Speed")); + ((LivingEntity) this).getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP")); + ((LivingEntity) this).setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP")); - this.setCustomName(new TextComponent("Artifact Guardian")); + ((Entity) this).setCustomName(new TextComponent("Artifact Guardian")); Zombie entityCast = (Zombie) this.getBukkitEntity(); @@ -54,11 +55,11 @@ public class CustomZombie extends net.minecraft.world.entity.monster.Zombie impl private void spawnHerobrineWarrior(Location loc) { - this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Warrior.Speed")); - this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP")); - this.setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP")); + ((LivingEntity) this).getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Warrior.Speed")); + ((LivingEntity) this).getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP")); + ((LivingEntity) this).setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP")); - this.setCustomName(new TextComponent("Herobrine Warrior")); + ((Entity) this).setCustomName(new TextComponent("Herobrine Warrior")); Zombie entityCast = (Zombie) this.getBukkitEntity(); @@ -96,7 +97,7 @@ public class CustomZombie extends net.minecraft.world.entity.monster.Zombie impl .getInt("npc." + mobS + ".Drops." + item + ".Count"))); } } - setHealth(0.0f); + ((LivingEntity) this).setHealth(0.0f); } public MobType getHerobrineMobType() {