Add explicit casting to fix problems with the remapper not working properly.

This commit is contained in:
David Berdik 2022-03-06 17:46:20 -05:00
parent f76f7036d0
commit 20b41b08bc
3 changed files with 22 additions and 19 deletions

View File

@ -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() {

View File

@ -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

View File

@ -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() {