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
protected void method_29353(HerobrineEntity livingEntity, float f) {
super.method_29353(livingEntity, f);
// Set Arm Angles
public void setAngles(HerobrineEntity livingEntity, float f, float g, float h, float i, float j) {
super.setAngles(livingEntity, f, g, h, i, j);
switch (livingEntity.getDataTracker().get(HerobrineEntity.POSE)) {
case FIREBALL: {
leftArm.pitch = -45;
leftArm.yaw = -6;
leftArm.roll = 0;
rightArm.pitch = -45;
rightArm.yaw = 6;
rightArm.roll = 0;
break;
}
case LIGHTNING: {
leftArm.roll = -128;
leftArm.yaw = 0;
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;
leftArm.roll = -65;
rightArm.roll = 65;
break;
}
}

View File

@ -19,6 +19,7 @@ import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandler;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.mob.Monster;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@ -47,7 +48,7 @@ import java.util.List;
import java.util.Objects;
@SuppressWarnings("EntityConstructor")
public class HerobrineEntity extends LivingEntity {
public class HerobrineEntity extends LivingEntity implements Monster {
private static final TrackedDataHandler<Pose> POSE_HANDLER = new TrackedDataHandler<Pose>() {
@Override
public void write(PacketByteBuf data, Pose object) {
@ -196,9 +197,9 @@ public class HerobrineEntity extends LivingEntity {
} else if (noPlayerTeleportCountdown == 0) {
reset = true;
List<? extends PlayerEntity> players = getEntityWorld().getPlayers();
Collections.shuffle(players);
if (players.size() > 0 || getNearestPlayer().distanceTo(this) >= HardcodedConfig.HEROBRINE_MAX_DISTANCE) {
while (true) {
PlayerEntity player = players.get(getEntityWorld().random.nextInt(players.size()));
for (PlayerEntity player : players) {
if (player.isAlive()) {
getAI().setStage(new TeleportStage(this, player.getUuid()));
break;
@ -230,19 +231,13 @@ public class HerobrineEntity extends LivingEntity {
public ServerPlayerEntity getNearestPlayer() {
tracking.sort((player1, player2) -> Float.compare(distanceTo(player1), distanceTo(player2)));
if (tracking.size() > 0) {
int i = 0;
while (true) {
if (tracking.get(i).isAlive()) {
return tracking.get(i);
} else {
i++;
for (ServerPlayerEntity player : tracking) {
if (player.isAlive()) {
return player;
}
}
} else {
return null;
}
}
public static void summon(PlayerEntity player) {
HerobrineData data = HerobrineData.get((ServerWorld) player.getEntityWorld());
@ -250,12 +245,13 @@ public class HerobrineEntity extends LivingEntity {
if (entity == null) {
ServerWorld world = Objects.requireNonNull(player.getEntityWorld().getServer()).getWorld(World.OVERWORLD);
entity = new HerobrineEntity(HerobrineRewoven.HEROBRINE_ENTITY_TYPE, world);
entity.updatePosition(0d, 51200d, 0d);
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());
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));
}
}