Migrate left over occurrences to enhanced switches (#3979)

* Migrate left-overs to enhanced switches

* More
This commit is contained in:
Alexander Brandes
2023-03-06 10:25:02 +01:00
committed by GitHub
parent 42e146b8c7
commit 89031447f2
16 changed files with 243 additions and 418 deletions

View File

@ -101,50 +101,26 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.noGravity = true;
}
switch (entity.getType().toString()) {
case "BOAT":
case "BOAT" -> {
Boat boat = (Boat) entity;
this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType());
return;
case "ARROW":
case "EGG":
case "ENDER_CRYSTAL":
case "ENDER_PEARL":
case "ENDER_SIGNAL":
case "EXPERIENCE_ORB":
case "FALLING_BLOCK":
case "FIREBALL":
case "FIREWORK":
case "FISHING_HOOK":
case "LEASH_HITCH":
case "LIGHTNING":
case "MINECART":
case "MINECART_COMMAND":
case "MINECART_MOB_SPAWNER":
case "MINECART_TNT":
case "PLAYER":
case "PRIMED_TNT":
case "SLIME":
case "SMALL_FIREBALL":
case "SNOWBALL":
case "MINECART_FURNACE":
case "SPLASH_POTION":
case "THROWN_EXP_BOTTLE":
case "WITHER_SKULL":
case "UNKNOWN":
case "SPECTRAL_ARROW":
case "SHULKER_BULLET":
case "DRAGON_FIREBALL":
case "AREA_EFFECT_CLOUD":
case "TRIDENT":
case "LLAMA_SPIT":
}
case "ARROW", "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "EXPERIENCE_ORB", "FALLING_BLOCK", "FIREBALL",
"FIREWORK", "FISHING_HOOK", "LEASH_HITCH", "LIGHTNING", "MINECART", "MINECART_COMMAND", "MINECART_MOB_SPAWNER",
"MINECART_TNT", "PLAYER", "PRIMED_TNT", "SLIME", "SMALL_FIREBALL", "SNOWBALL", "MINECART_FURNACE", "SPLASH_POTION",
"THROWN_EXP_BOTTLE", "WITHER_SKULL", "UNKNOWN", "SPECTRAL_ARROW", "SHULKER_BULLET", "DRAGON_FIREBALL", "AREA_EFFECT_CLOUD",
"TRIDENT", "LLAMA_SPIT" -> {
// Do this stuff later
return;
}
// MISC //
case "DROPPED_ITEM":
case "DROPPED_ITEM" -> {
Item item = (Item) entity;
this.stack = item.getItemStack();
return;
case "ITEM_FRAME":
}
case "ITEM_FRAME" -> {
this.x = Math.floor(this.getX());
this.y = Math.floor(this.getY());
this.z = Math.floor(this.getZ());
@ -152,7 +128,8 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.dataByte = getOrdinal(Rotation.values(), itemFrame.getRotation());
this.stack = itemFrame.getItem().clone();
return;
case "PAINTING":
}
case "PAINTING" -> {
this.x = Math.floor(this.getX());
this.y = Math.floor(this.getY());
this.z = Math.floor(this.getZ());
@ -165,20 +142,17 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
}
this.dataString = art.name();
return;
}
// END MISC //
// INVENTORY HOLDER //
case "MINECART_CHEST":
case "MINECART_HOPPER":
case "MINECART_CHEST", "MINECART_HOPPER" -> {
storeInventory((InventoryHolder) entity);
return;
}
// START LIVING ENTITY //
// START AGEABLE //
// START TAMEABLE //
case "HORSE":
case "DONKEY":
case "LLAMA":
case "MULE":
case "SKELETON_HORSE":
case "HORSE", "DONKEY", "LLAMA", "MULE", "SKELETON_HORSE" -> {
AbstractHorse horse = (AbstractHorse) entity;
this.horse = new HorseStats();
this.horse.jump = horse.getJumpStrength();
@ -194,16 +168,17 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
storeLiving(horse);
storeInventory(horse);
return;
}
// END INVENTORY HOLDER //
case "WOLF":
case "OCELOT":
case "WOLF", "OCELOT" -> {
storeTameable((Tameable) entity);
storeAgeable((Ageable) entity);
storeLiving((LivingEntity) entity);
return;
}
// END TAMEABLE //
//todo fix sheep
case "SHEEP":
case "SHEEP" -> {
Sheep sheep = (Sheep) entity;
if (sheep.isSheared()) {
this.dataByte = (byte) 1;
@ -214,23 +189,20 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
storeAgeable(sheep);
storeLiving(sheep);
return;
case "VILLAGER":
case "CHICKEN":
case "COW":
case "MUSHROOM_COW":
case "PIG":
case "TURTLE":
case "POLAR_BEAR":
}
case "VILLAGER", "CHICKEN", "COW", "MUSHROOM_COW", "PIG", "TURTLE", "POLAR_BEAR" -> {
storeAgeable((Ageable) entity);
storeLiving((LivingEntity) entity);
return;
case "RABBIT":
}
case "RABBIT" -> {
this.dataByte = getOrdinal(Rabbit.Type.values(), ((Rabbit) entity).getRabbitType());
storeAgeable((Ageable) entity);
storeLiving((LivingEntity) entity);
return;
}
// END AGEABLE //
case "ARMOR_STAND":
case "ARMOR_STAND" -> {
ArmorStand stand = (ArmorStand) entity;
this.inventory =
new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(),
@ -238,37 +210,30 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
stand.getBoots().clone()};
storeLiving(stand);
this.stand = new ArmorStandStats();
EulerAngle head = stand.getHeadPose();
this.stand.head[0] = (float) head.getX();
this.stand.head[1] = (float) head.getY();
this.stand.head[2] = (float) head.getZ();
EulerAngle body = stand.getBodyPose();
this.stand.body[0] = (float) body.getX();
this.stand.body[1] = (float) body.getY();
this.stand.body[2] = (float) body.getZ();
EulerAngle leftLeg = stand.getLeftLegPose();
this.stand.leftLeg[0] = (float) leftLeg.getX();
this.stand.leftLeg[1] = (float) leftLeg.getY();
this.stand.leftLeg[2] = (float) leftLeg.getZ();
EulerAngle rightLeg = stand.getRightLegPose();
this.stand.rightLeg[0] = (float) rightLeg.getX();
this.stand.rightLeg[1] = (float) rightLeg.getY();
this.stand.rightLeg[2] = (float) rightLeg.getZ();
EulerAngle leftArm = stand.getLeftArmPose();
this.stand.leftArm[0] = (float) leftArm.getX();
this.stand.leftArm[1] = (float) leftArm.getY();
this.stand.leftArm[2] = (float) leftArm.getZ();
EulerAngle rightArm = stand.getRightArmPose();
this.stand.rightArm[0] = (float) rightArm.getX();
this.stand.rightArm[1] = (float) rightArm.getY();
this.stand.rightArm[2] = (float) rightArm.getZ();
if (stand.hasArms()) {
this.stand.arms = true;
}
@ -282,53 +247,38 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
this.stand.small = true;
}
return;
case "ENDERMITE":
}
case "ENDERMITE" -> {
return;
case "BAT":
}
case "BAT" -> {
if (((Bat) entity).isAwake()) {
this.dataByte = (byte) 1;
} else {
this.dataByte = (byte) 0;
}
return;
case "ENDER_DRAGON":
}
case "ENDER_DRAGON" -> {
EnderDragon entity1 = (EnderDragon) entity;
this.dataByte = (byte) entity1.getPhase().ordinal();
return;
case "SKELETON":
case "WITHER_SKELETON":
case "GUARDIAN":
case "ELDER_GUARDIAN":
case "GHAST":
case "MAGMA_CUBE":
case "SQUID":
case "PIG_ZOMBIE":
case "HOGLIN":
case "ZOMBIFIED_PIGLIN":
case "PIGLIN":
case "PIGLIN_BRUTE":
case "ZOMBIE":
case "WITHER":
case "WITCH":
case "SPIDER":
case "CAVE_SPIDER":
case "SILVERFISH":
case "GIANT":
case "ENDERMAN":
case "CREEPER":
case "BLAZE":
case "SHULKER":
case "SNOWMAN":
}
case "SKELETON", "WITHER_SKELETON", "GUARDIAN", "ELDER_GUARDIAN", "GHAST", "MAGMA_CUBE", "SQUID", "PIG_ZOMBIE", "HOGLIN",
"ZOMBIFIED_PIGLIN", "PIGLIN", "PIGLIN_BRUTE", "ZOMBIE", "WITHER", "WITCH", "SPIDER", "CAVE_SPIDER", "SILVERFISH",
"GIANT", "ENDERMAN", "CREEPER", "BLAZE", "SHULKER", "SNOWMAN" -> {
storeLiving((LivingEntity) entity);
return;
case "IRON_GOLEM":
}
case "IRON_GOLEM" -> {
if (((IronGolem) entity).isPlayerCreated()) {
this.dataByte = (byte) 1;
} else {
this.dataByte = (byte) 0;
}
storeLiving((LivingEntity) entity);
// END LIVING //
}
// END LIVING //
}
}
@ -465,20 +415,15 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
}
Entity entity;
switch (this.getType().toString()) {
case "DROPPED_ITEM":
case "DROPPED_ITEM" -> {
return world.dropItem(location, this.stack);
case "PLAYER":
case "LEASH_HITCH":
}
case "PLAYER", "LEASH_HITCH" -> {
return null;
case "ITEM_FRAME":
entity = world.spawn(location, ItemFrame.class);
break;
case "PAINTING":
entity = world.spawn(location, Painting.class);
break;
default:
entity = world.spawnEntity(location, this.getType());
break;
}
case "ITEM_FRAME" -> entity = world.spawn(location, ItemFrame.class);
case "PAINTING" -> entity = world.spawn(location, Painting.class);
default -> entity = world.spawnEntity(location, this.getType());
}
if (this.depth == 0) {
return entity;
@ -506,72 +451,46 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
entity.setGravity(false);
}
switch (entity.getType().toString()) {
case "BOAT":
case "BOAT" -> {
Boat boat = (Boat) entity;
boat.setWoodType(TreeSpecies.values()[dataByte]);
return entity;
case "SLIME":
}
case "SLIME" -> {
((Slime) entity).setSize(this.dataByte);
return entity;
case "ARROW":
case "EGG":
case "ENDER_CRYSTAL":
case "ENDER_PEARL":
case "ENDER_SIGNAL":
case "DROPPED_ITEM":
case "EXPERIENCE_ORB":
case "FALLING_BLOCK":
case "FIREBALL":
case "FIREWORK":
case "FISHING_HOOK":
case "LEASH_HITCH":
case "LIGHTNING":
case "MINECART":
case "MINECART_COMMAND":
case "MINECART_MOB_SPAWNER":
case "MINECART_TNT":
case "PLAYER":
case "PRIMED_TNT":
case "SMALL_FIREBALL":
case "SNOWBALL":
case "SPLASH_POTION":
case "THROWN_EXP_BOTTLE":
case "SPECTRAL_ARROW":
case "SHULKER_BULLET":
case "AREA_EFFECT_CLOUD":
case "DRAGON_FIREBALL":
case "WITHER_SKULL":
case "MINECART_FURNACE":
case "LLAMA_SPIT":
case "TRIDENT":
case "UNKNOWN":
}
case "ARROW", "EGG", "ENDER_CRYSTAL", "ENDER_PEARL", "ENDER_SIGNAL", "DROPPED_ITEM", "EXPERIENCE_ORB", "FALLING_BLOCK",
"FIREBALL", "FIREWORK", "FISHING_HOOK", "LEASH_HITCH", "LIGHTNING", "MINECART", "MINECART_COMMAND",
"MINECART_MOB_SPAWNER", "MINECART_TNT", "PLAYER", "PRIMED_TNT", "SMALL_FIREBALL", "SNOWBALL",
"SPLASH_POTION", "THROWN_EXP_BOTTLE", "SPECTRAL_ARROW", "SHULKER_BULLET", "AREA_EFFECT_CLOUD",
"DRAGON_FIREBALL", "WITHER_SKULL", "MINECART_FURNACE", "LLAMA_SPIT", "TRIDENT", "UNKNOWN" -> {
// Do this stuff later
return entity;
}
// MISC //
case "ITEM_FRAME":
case "ITEM_FRAME" -> {
ItemFrame itemframe = (ItemFrame) entity;
itemframe.setRotation(Rotation.values()[this.dataByte]);
itemframe.setItem(this.stack);
return entity;
case "PAINTING":
}
case "PAINTING" -> {
Painting painting = (Painting) entity;
painting.setFacingDirection(BlockFace.values()[this.dataByte], true);
painting.setArt(Art.getByName(this.dataString), true);
return entity;
}
// END MISC //
// INVENTORY HOLDER //
case "MINECART_CHEST":
case "MINECART_HOPPER":
case "MINECART_CHEST", "MINECART_HOPPER" -> {
restoreInventory((InventoryHolder) entity);
return entity;
}
// START LIVING ENTITY //
// START AGEABLE //
// START TAMEABLE //
case "HORSE":
case "LLAMA":
case "SKELETON_HORSE":
case "DONKEY":
case "MULE":
case "HORSE", "LLAMA", "SKELETON_HORSE", "DONKEY", "MULE" -> {
AbstractHorse horse = (AbstractHorse) entity;
horse.setJumpStrength(this.horse.jump);
if (horse instanceof ChestedHorse) {
@ -586,15 +505,16 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
restoreLiving(horse);
restoreInventory(horse);
return entity;
}
// END INVENTORY HOLDER //
case "WOLF":
case "OCELOT":
case "WOLF", "OCELOT" -> {
restoreTameable((Tameable) entity);
restoreAgeable((Ageable) entity);
restoreLiving((LivingEntity) entity);
return entity;
}
// END AGEABLE //
case "SHEEP":
case "SHEEP" -> {
Sheep sheep = (Sheep) entity;
if (this.dataByte == 1) {
sheep.setSheared(true);
@ -605,25 +525,22 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
restoreAgeable(sheep);
restoreLiving(sheep);
return sheep;
case "VILLAGER":
case "CHICKEN":
case "COW":
case "TURTLE":
case "POLAR_BEAR":
case "MUSHROOM_COW":
case "PIG":
}
case "VILLAGER", "CHICKEN", "COW", "TURTLE", "POLAR_BEAR", "MUSHROOM_COW", "PIG" -> {
restoreAgeable((Ageable) entity);
restoreLiving((LivingEntity) entity);
return entity;
}
// END AGEABLE //
case "RABBIT":
case "RABBIT" -> {
if (this.dataByte != 0) {
((Rabbit) entity).setRabbitType(Rabbit.Type.values()[this.dataByte]);
}
restoreAgeable((Ageable) entity);
restoreLiving((LivingEntity) entity);
return entity;
case "ARMOR_STAND":
}
case "ARMOR_STAND" -> {
// CHECK positions
ArmorStand stand = (ArmorStand) entity;
if (this.inventory[0] != null) {
@ -693,56 +610,38 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
}
restoreLiving(stand);
return stand;
case "BAT":
}
case "BAT" -> {
if (this.dataByte != 0) {
((Bat) entity).setAwake(true);
}
restoreLiving((LivingEntity) entity);
return entity;
case "ENDER_DRAGON":
}
case "ENDER_DRAGON" -> {
if (this.dataByte != 0) {
((EnderDragon) entity).setPhase(EnderDragon.Phase.values()[this.dataByte]);
}
restoreLiving((LivingEntity) entity);
return entity;
case "ENDERMITE":
case "GHAST":
case "MAGMA_CUBE":
case "SQUID":
case "PIG_ZOMBIE":
case "HOGLIN":
case "PIGLIN":
case "ZOMBIFIED_PIGLIN":
case "PIGLIN_BRUTE":
case "ZOMBIE":
case "WITHER":
case "WITCH":
case "SPIDER":
case "CAVE_SPIDER":
case "SILVERFISH":
case "GIANT":
case "ENDERMAN":
case "CREEPER":
case "BLAZE":
case "SNOWMAN":
case "SHULKER":
case "GUARDIAN":
case "ELDER_GUARDIAN":
case "SKELETON":
case "WITHER_SKELETON":
}
case "ENDERMITE", "GHAST", "MAGMA_CUBE", "SQUID", "PIG_ZOMBIE", "HOGLIN", "PIGLIN", "ZOMBIFIED_PIGLIN", "PIGLIN_BRUTE", "ZOMBIE", "WITHER", "WITCH", "SPIDER", "CAVE_SPIDER", "SILVERFISH", "GIANT", "ENDERMAN", "CREEPER", "BLAZE", "SNOWMAN", "SHULKER", "GUARDIAN", "ELDER_GUARDIAN", "SKELETON", "WITHER_SKELETON" -> {
restoreLiving((LivingEntity) entity);
return entity;
case "IRON_GOLEM":
}
case "IRON_GOLEM" -> {
if (this.dataByte != 0) {
((IronGolem) entity).setPlayerCreated(true);
}
restoreLiving((LivingEntity) entity);
return entity;
default:
}
default -> {
if (Settings.DEBUG) {
LOGGER.info("Could not identify entity: {}", entity.getType());
}
return entity;
}
// END LIVING
}
}