Fix Bugs
All checks were successful
Herobrine-Rewoven/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-10-21 13:51:58 -04:00
parent 0ef5b77ac2
commit 636a1556c6
3 changed files with 16 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -22,34 +22,19 @@ public class HerobrineEntityRenderer extends LivingEntityRenderer<HerobrineEntit
} }
@Override @Override
protected void method_29353(HerobrineEntity livingEntity, float f) { public void setAngles(HerobrineEntity livingEntity, float f, float g, float h, float i, float j) {
super.method_29353(livingEntity, f); super.setAngles(livingEntity, f, g, h, i, j);
// Set Arm Angles
switch (livingEntity.getDataTracker().get(HerobrineEntity.POSE)) { switch (livingEntity.getDataTracker().get(HerobrineEntity.POSE)) {
case FIREBALL: { case FIREBALL: {
leftArm.pitch = -45; leftArm.pitch = -45;
leftArm.yaw = -6; leftArm.yaw = -6;
leftArm.roll = 0;
rightArm.pitch = -45; rightArm.pitch = -45;
rightArm.yaw = 6; rightArm.yaw = 6;
rightArm.roll = 0;
break; break;
} }
case LIGHTNING: { case LIGHTNING: {
leftArm.roll = -128; leftArm.roll = -65;
leftArm.yaw = 0; rightArm.roll = 65;
leftArm.pitch = 0;
rightArm.roll = 210;
leftArm.yaw = 0;
rightArm.pitch = 0;
break;
}
case NORMAL:
default: {
leftArm.yaw = 0;
leftArm.roll = 0;
rightArm.yaw = 0;
rightArm.roll = 0;
break; break;
} }
} }

View File

@ -19,6 +19,7 @@ import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandler; import net.minecraft.entity.data.TrackedDataHandler;
import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.mob.Monster;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
@ -47,7 +48,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@SuppressWarnings("EntityConstructor") @SuppressWarnings("EntityConstructor")
public class HerobrineEntity extends LivingEntity { public class HerobrineEntity extends LivingEntity implements Monster {
private static final TrackedDataHandler<Pose> POSE_HANDLER = new TrackedDataHandler<Pose>() { private static final TrackedDataHandler<Pose> POSE_HANDLER = new TrackedDataHandler<Pose>() {
@Override @Override
public void write(PacketByteBuf data, Pose object) { public void write(PacketByteBuf data, Pose object) {
@ -196,9 +197,9 @@ public class HerobrineEntity extends LivingEntity {
} else if (noPlayerTeleportCountdown == 0) { } else if (noPlayerTeleportCountdown == 0) {
reset = true; reset = true;
List<? extends PlayerEntity> players = getEntityWorld().getPlayers(); List<? extends PlayerEntity> players = getEntityWorld().getPlayers();
Collections.shuffle(players);
if (players.size() > 0 || getNearestPlayer().distanceTo(this) >= HardcodedConfig.HEROBRINE_MAX_DISTANCE) { if (players.size() > 0 || getNearestPlayer().distanceTo(this) >= HardcodedConfig.HEROBRINE_MAX_DISTANCE) {
while (true) { for (PlayerEntity player : players) {
PlayerEntity player = players.get(getEntityWorld().random.nextInt(players.size()));
if (player.isAlive()) { if (player.isAlive()) {
getAI().setStage(new TeleportStage(this, player.getUuid())); getAI().setStage(new TeleportStage(this, player.getUuid()));
break; break;
@ -230,18 +231,12 @@ public class HerobrineEntity extends LivingEntity {
public ServerPlayerEntity getNearestPlayer() { public ServerPlayerEntity getNearestPlayer() {
tracking.sort((player1, player2) -> Float.compare(distanceTo(player1), distanceTo(player2))); tracking.sort((player1, player2) -> Float.compare(distanceTo(player1), distanceTo(player2)));
if (tracking.size() > 0) { for (ServerPlayerEntity player : tracking) {
int i = 0; if (player.isAlive()) {
while (true) { return player;
if (tracking.get(i).isAlive()) {
return tracking.get(i);
} else {
i++;
}
} }
} else {
return null;
} }
return null;
} }
public static void summon(PlayerEntity player) { public static void summon(PlayerEntity player) {
@ -250,12 +245,13 @@ public class HerobrineEntity extends LivingEntity {
if (entity == null) { if (entity == null) {
ServerWorld world = Objects.requireNonNull(player.getEntityWorld().getServer()).getWorld(World.OVERWORLD); ServerWorld world = Objects.requireNonNull(player.getEntityWorld().getServer()).getWorld(World.OVERWORLD);
entity = new HerobrineEntity(HerobrineRewoven.HEROBRINE_ENTITY_TYPE, world); entity = new HerobrineEntity(HerobrineRewoven.HEROBRINE_ENTITY_TYPE, world);
entity.updatePosition(0d, 51200d, 0d);
assert world != null; assert world != null;
Objects.requireNonNull(world.getServer().getWorld(World.OVERWORLD)).spawnEntity(entity); ServerWorld serverWorld = Objects.requireNonNull(world.getServer().getWorld(World.OVERWORLD));
BlockPos spawn = serverWorld.getSpawnPos();
entity.updatePosition(spawn.getX() + 0.5d, spawn.getY(), spawn.getZ() + 0.5d);
serverWorld.spawnEntity(entity);
data.set(entity.getUuid()); data.set(entity.getUuid());
world.getServer().getPlayerManager().sendToAll(new GameMessageS2CPacket(new TranslatableText("multiplayer.player.joined", entity.getDisplayName()).formatted(Formatting.YELLOW), MessageType.CHAT, Util.NIL_UUID)); world.getServer().getPlayerManager().sendToAll(new GameMessageS2CPacket(new TranslatableText("multiplayer.player.joined", entity.getDisplayName()).formatted(Formatting.YELLOW), MessageType.CHAT, Util.NIL_UUID));
entity.getAI().setStage(new TeleportStage(entity, world.getSpawnPos()));
world.getServer().getPlayerManager().sendToAll(new GameMessageS2CPacket(new TranslatableText(entity.getMessageKey("spawn"), entity.getDisplayName()), MessageType.CHAT, Util.NIL_UUID)); world.getServer().getPlayerManager().sendToAll(new GameMessageS2CPacket(new TranslatableText(entity.getMessageKey("spawn"), entity.getDisplayName()), MessageType.CHAT, Util.NIL_UUID));
} }
} }