compile fixes

This commit is contained in:
Jason Penilla 2024-04-25 12:16:00 -07:00
parent 820f999ba4
commit ca9001a936
No known key found for this signature in database
GPG Key ID: 0E75A301420E48F8
17 changed files with 119 additions and 148 deletions

View File

@ -7,12 +7,13 @@ Co-authored-by: Luis <luisc99@icloud.com>
diff --git a/src/main/java/io/papermc/paper/enchantments/EnchantmentRarity.java b/src/main/java/io/papermc/paper/enchantments/EnchantmentRarity.java
new file mode 100644
index 0000000000000000000000000000000000000000..e6a40c1fcea761bd66743b50e3da3d14797d05b0
index 0000000000000000000000000000000000000000..50c49739cc25679c9d241466e3069c9c232a22c4
--- /dev/null
+++ b/src/main/java/io/papermc/paper/enchantments/EnchantmentRarity.java
@@ -0,0 +1,24 @@
@@ -0,0 +1,25 @@
+package io.papermc.paper.enchantments;
+
+@Deprecated(forRemoval = true, since = "As of 1.20.5 enchantments do not have a rarity.")
+public enum EnchantmentRarity {
+
+ COMMON(10),
@ -36,7 +37,7 @@ index 0000000000000000000000000000000000000000..e6a40c1fcea761bd66743b50e3da3d14
+ }
+}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index 3375ce0f9ac50cd3f145291ceb587d4e6f72569c..a72202b653549b4074feb89748849fcb495ba0d4 100644
index 3375ce0f9ac50cd3f145291ceb587d4e6f72569c..5e192105851436dbfe73a6e47c64bbb10e1ac41a 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -291,11 +291,7 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
@ -51,7 +52,7 @@ index 3375ce0f9ac50cd3f145291ceb587d4e6f72569c..a72202b653549b4074feb89748849fcb
public abstract boolean isCursed();
/**
@@ -329,6 +325,84 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
@@ -329,6 +325,87 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
* @return the name of the enchantment with {@code level} applied
*/
public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
@ -99,8 +100,11 @@ index 3375ce0f9ac50cd3f145291ceb587d4e6f72569c..a72202b653549b4074feb89748849fcb
+ * Gets the rarity of this enchantment.
+ *
+ * @return the rarity
+ * @deprecated As of 1.20.5 enchantments do not have a rarity.
+ */
+ @NotNull
+ @Deprecated(forRemoval = true, since = "1.20.5")
+ @Contract("-> fail")
+ public abstract io.papermc.paper.enchantments.EnchantmentRarity getRarity();
+
+ /**

View File

@ -1620,18 +1620,17 @@ index 0000000000000000000000000000000000000000..94a0a5850c97df08019c5b0f5d4e02a9
+}
diff --git a/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..0a7764797b0f1f346fb35f09377d5639bc382bff
index 0000000000000000000000000000000000000000..c7da1c8395244803872601bb95de95ad91c93e29
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java
@@ -0,0 +1,39 @@
@@ -0,0 +1,30 @@
+package io.papermc.paper.adventure;
+
+import com.mojang.datafixers.util.Pair;
+import java.util.function.Function;
+import com.mojang.serialization.JavaOps;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.ComponentSerializer;
+import net.minecraft.network.chat.ComponentSerialization;
+import net.minecraft.util.JavaOps;
+
+final class WrapperAwareSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> {
+ @Override
@ -1640,26 +1639,18 @@ index 0000000000000000000000000000000000000000..0a7764797b0f1f346fb35f09377d5639
+ return ((AdventureComponent) input).adventure;
+ }
+ final Object obj = ComponentSerialization.CODEC.encodeStart(JavaOps.INSTANCE, input)
+ .get().map(Function.identity(), partial -> {
+ throw new RuntimeException("Failed to encode Minecraft Component: " + input + "; " + partial.message());
+ });
+ .getOrThrow(s -> new RuntimeException("Failed to encode Minecraft Component: " + input + "; " + s));
+ final Pair<Component, Object> converted = AdventureCodecs.COMPONENT_CODEC.decode(JavaOps.INSTANCE, obj)
+ .get().map(Function.identity(), partial -> {
+ throw new RuntimeException("Failed to decode to adventure Component: " + obj + "; " + partial.message());
+ });
+ .getOrThrow(s -> new RuntimeException("Failed to decode to adventure Component: " + obj + "; " + s));
+ return converted.getFirst();
+ }
+
+ @Override
+ public net.minecraft.network.chat.Component serialize(final Component component) {
+ final Object obj = AdventureCodecs.COMPONENT_CODEC.encodeStart(JavaOps.INSTANCE, component)
+ .get().map(Function.identity(), partial -> {
+ throw new RuntimeException("Failed to encode adventure Component: " + component + "; " + partial.message());
+ });
+ .getOrThrow(s -> new RuntimeException("Failed to encode adventure Component: " + component + "; " + s));
+ final Pair<net.minecraft.network.chat.Component, Object> converted = ComponentSerialization.CODEC.decode(JavaOps.INSTANCE, obj)
+ .get().map(Function.identity(), partial -> {
+ throw new RuntimeException("Failed to decode to Minecraft Component: " + obj + "; " + partial.message());
+ });
+ .getOrThrow(s -> new RuntimeException("Failed to decode to Minecraft Component: " + obj + "; " + s));
+ return converted.getFirst();
+ }
+}
@ -5598,10 +5589,10 @@ index 0000000000000000000000000000000000000000..3aedd0bbc97edacc1ebf71264b310e55
+}
diff --git a/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java b/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..fdf9f95d6c65ba13108352c83d793b3a2126d69b
index 0000000000000000000000000000000000000000..ff9e3013e4f5049c6cfa35803676516dfe8b9af1
--- /dev/null
+++ b/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java
@@ -0,0 +1,402 @@
@@ -0,0 +1,399 @@
+package io.papermc.paper.adventure;
+
+import com.mojang.datafixers.util.Pair;
@ -5854,10 +5845,7 @@ index 0000000000000000000000000000000000000000..fdf9f95d6c65ba13108352c83d793b3a
+ }
+
+ static <R> R require(final DataResult<R> result, final Function<String, String> errorMessage) {
+ return switch (result) {
+ case final DataResult.Error<R> error -> throw new RuntimeException(errorMessage.apply(error.message()));
+ case final DataResult.Success<R> success -> success.value();
+ };
+ return result.getOrThrow(s -> new RuntimeException(errorMessage.apply(s)));
+ }
+
+ static List<Tag> invalidData() {

View File

@ -592,6 +592,32 @@ index 8390f5b5b957b5435efece26507a89756d0a7b3c..c6e8441e299f477ddb22c1ce26187107
} catch (Exception e) {
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalCompletionHandler.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalCompletionHandler.java
index 7d1c0810181c51ffa64f9a23b251e05c789870b0..09804513265e6db0c1f3501355335551100a36a8 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/TerminalCompletionHandler.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/TerminalCompletionHandler.java
@@ -4,14 +4,12 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import jline.console.ConsoleReader;
-import jline.console.completer.CompletionHandler;
/**
* SPIGOT-6705: Make sure we print the display line again on tab completion, so that the user does not get stuck on it
* e.g. The user needs to press y / n to continue
*/
-public class TerminalCompletionHandler implements CompletionHandler {
+public class TerminalCompletionHandler /* implements CompletionHandler */ { /* Paper - comment out whole class
private final TerminalConsoleWriterThread writerThread;
private final CompletionHandler delegate;
@@ -50,4 +48,5 @@ public class TerminalCompletionHandler implements CompletionHandler {
return result;
}
+*/ // Paper end - comment out whole class
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
index 2e5101fca081548bb616bc5eaa0134698719b63a..6e4d50a4863d43a2d6a2d574350c74d0819df402 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerShearBlockEvent
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
index ce108f1cea8027aa7aab444689f7a29f2e54cc20..7b311f60ceae9942eeee0d2c7a170278e5983f2d 100644
index ce108f1cea8027aa7aab444689f7a29f2e54cc20..ef804067ee05870e9331237b44ca1ffeb8df99c7 100644
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
@@ -127,7 +127,7 @@ public class BeehiveBlock extends BaseEntityBlock {
@ -22,10 +22,10 @@ index ce108f1cea8027aa7aab444689f7a29f2e54cc20..7b311f60ceae9942eeee0d2c7a170278
if (stack.is(Items.SHEARS)) {
+ // Paper start - Add PlayerShearBlockEvent
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>());
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>());
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.HONEYCOMB, 3)));
+ if (!event.callEvent()) {
+ return InteractionResult.PASS;
+ return ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
+ }
+ // Paper end
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.BLOCKS, 1.0F, 1.0F);
@ -39,7 +39,7 @@ index ce108f1cea8027aa7aab444689f7a29f2e54cc20..7b311f60ceae9942eeee0d2c7a170278
flag = true;
world.gameEvent((Entity) player, (Holder) GameEvent.SHEAR, pos);
diff --git a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
index aa8667f0b14dc8944dd3457b431162e59bf54ada..d52abece78866fb4202e54d21be8105261401d9b 100644
index aa8667f0b14dc8944dd3457b431162e59bf54ada..3b94888516e4dd1a8e56c31fd71bb21f84b8cfbd 100644
--- a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
@@ -40,10 +40,18 @@ public class PumpkinBlock extends Block {
@ -47,10 +47,10 @@ index aa8667f0b14dc8944dd3457b431162e59bf54ada..d52abece78866fb4202e54d21be81052
return ItemInteractionResult.sidedSuccess(world.isClientSide);
} else {
+ // Paper start - Add PlayerShearBlockEvent
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>());
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>());
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4)));
+ if (!event.callEvent()) {
+ return ItemInteractionResult.PASS;
+ return ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION;
+ }
+ // Paper end - Add PlayerShearBlockEvent
Direction direction = hit.getDirection();

View File

@ -4,12 +4,12 @@ Date: Thu, 6 May 2021 19:57:58 -0700
Subject: [PATCH] More Enchantment API
== AT ==
public net.minecraft.world.item.enchantment.Enchantment slots
public net.minecraft.world.item.enchantment.Enchantment definition
Co-authored-by: Luis <luisc99@icloud.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
index bb8a3e670924ebcce48669c5dce57e2df03fad77..58a24e149ae9500c9db90693ac9eb6446794535c 100644
index bb8a3e670924ebcce48669c5dce57e2df03fad77..bb45dde0fd91796d5fd83a5fd20f5f1d5ad63ee7 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@@ -71,7 +71,7 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
@ -21,7 +21,7 @@ index bb8a3e670924ebcce48669c5dce57e2df03fad77..58a24e149ae9500c9db90693ac9eb644
}
@Override
@@ -150,6 +150,77 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
@@ -150,6 +150,63 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
public String translationKey() {
return this.handle.getDescriptionId();
}
@ -48,7 +48,7 @@ index bb8a3e670924ebcce48669c5dce57e2df03fad77..58a24e149ae9500c9db90693ac9eb644
+
+ @Override
+ public io.papermc.paper.enchantments.EnchantmentRarity getRarity() {
+ return fromNMSRarity(handle.getRarity());
+ throw new UnsupportedOperationException("Enchantments don't have a rarity anymore in 1.20.5+.");
+ }
+
+ @Override
@ -80,49 +80,11 @@ index bb8a3e670924ebcce48669c5dce57e2df03fad77..58a24e149ae9500c9db90693ac9eb644
+
+ @Override
+ public java.util.Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots() {
+ return java.util.stream.Stream.of(handle.slots).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
+ }
+
+ public static io.papermc.paper.enchantments.EnchantmentRarity fromNMSRarity(net.minecraft.world.item.enchantment.Enchantment.Rarity nmsRarity) {
+ if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.COMMON) {
+ return io.papermc.paper.enchantments.EnchantmentRarity.COMMON;
+ } else if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.UNCOMMON) {
+ return io.papermc.paper.enchantments.EnchantmentRarity.UNCOMMON;
+ } else if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.RARE) {
+ return io.papermc.paper.enchantments.EnchantmentRarity.RARE;
+ } else if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.VERY_RARE) {
+ return io.papermc.paper.enchantments.EnchantmentRarity.VERY_RARE;
+ }
+
+ throw new IllegalArgumentException(String.format("Unable to convert %s to a enum value of %s.", nmsRarity, io.papermc.paper.enchantments.EnchantmentRarity.class));
+ return java.util.stream.Stream.of(handle.definition.slots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
+ }
// Paper end
@Override
diff --git a/src/test/java/io/papermc/paper/enchantments/EnchantmentRarityTest.java b/src/test/java/io/papermc/paper/enchantments/EnchantmentRarityTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..03a53ceb0dc3aaff7b5d10ec57f74d71be90ec3a
--- /dev/null
+++ b/src/test/java/io/papermc/paper/enchantments/EnchantmentRarityTest.java
@@ -0,0 +1,18 @@
+package io.papermc.paper.enchantments;
+
+import net.minecraft.world.item.enchantment.Enchantment.Rarity;
+import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class EnchantmentRarityTest {
+
+ @Test
+ public void test() {
+ for (Rarity nmsRarity : Rarity.values()) {
+ // Will throw exception if a bukkit counterpart is not found
+ CraftEnchantment.fromNMSRarity(nmsRarity);
+ }
+ }
+}
diff --git a/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java b/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4ee48ef89f0e31a7bda4b04453fca8177874f540

View File

@ -30,6 +30,8 @@ public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks
public net.minecraft.world.entity.AreaEffectCloud ownerUUID
public net.minecraft.world.entity.animal.MushroomCow stewEffects
public net.minecraft.world.entity.Entity FLAG_INVISIBLE
public net.minecraft.world.entity.animal.Cat setRelaxStateOne(Z)V
public net.minecraft.world.entity.animal.Cat isRelaxStateOne()Z
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>

View File

@ -10,7 +10,7 @@ indefinitely. Instead of using the world state, we use the already
supplied ServerLevelAccessor which will always have the chunk available.
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
index f3b0e5a97ad5d344741dfa3b7c864712c7ba8802..d2e273f58b4c9b65642980d3f47e01ae92166e46 100644
index 951b7f252e67b29092964019bb3463cb00e497e3..b5f13d1bf1cccb9a15d8956f68c960e25098dc98 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
@@ -367,7 +367,7 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian

View File

@ -40,7 +40,7 @@ index f080322bc766361b9d2d8b1214c3dff1c3df9ae8..d8c5f8e584976a97bd909bfa20023993
return true;
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
index 7b311f60ceae9942eeee0d2c7a170278e5983f2d..4e8bafa97127632799a1f0260c1ef3367cb8a54c 100644
index ef804067ee05870e9331237b44ca1ffeb8df99c7..21a7f9414e27c73b58fd75fbe68cf889f52a5d01 100644
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
@@ -95,7 +95,7 @@ public class BeehiveBlock extends BaseEntityBlock {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add EntityDyeEvent and CollarColorable interface
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
index d2e273f58b4c9b65642980d3f47e01ae92166e46..57c22ca91e9f3a161f5277914e379ea9dc8eeeef 100644
index b5f13d1bf1cccb9a15d8956f68c960e25098dc98..118be62539bb0266c2e89bd68abbc4a975fcd833 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
@@ -388,6 +388,13 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Missing eating regain reason
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
index 57c22ca91e9f3a161f5277914e379ea9dc8eeeef..827c5800b9e898418ff7a641c97ffb86935a914c 100644
index 118be62539bb0266c2e89bd68abbc4a975fcd833..07559b9629d4ecb40b511256f400a781e39820e0 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
@@ -408,7 +408,7 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian

View File

@ -24,7 +24,7 @@ index ee7f36700863b9f504a70a56c5f28c8e39b45c91..7b4426ac0435d3f419d9ece29dc9eccd
// return true; // CraftBukkit
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
index 4e8bafa97127632799a1f0260c1ef3367cb8a54c..6ef43d544e9d3dd31506c5a55b0db428fb074b47 100644
index 21a7f9414e27c73b58fd75fbe68cf889f52a5d01..f6bed27ddbc47c894e315fc59c2721923b486ef8 100644
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
@@ -86,8 +86,8 @@ public class BeehiveBlock extends BaseEntityBlock {

View File

@ -33,7 +33,7 @@ this fix, as the data will remain in the oversized file. Once the server returns
to a jar with this fix, the data will be restored.
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index 307196b2a58d4f8db3e6e3c3517a8004d4908b13..69d7a7c2dcee40552d229288c52ed7dd6ad0c2a8 100644
index 307196b2a58d4f8db3e6e3c3517a8004d4908b13..c9fd589b1354ac788b63d163d427e8cc5fbba3c5 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -18,10 +18,13 @@ import java.nio.file.LinkOption;
@ -50,24 +50,15 @@ index 307196b2a58d4f8db3e6e3c3517a8004d4908b13..69d7a7c2dcee40552d229288c52ed7dd
import net.minecraft.world.level.ChunkPos;
import org.slf4j.Logger;
@@ -49,6 +52,7 @@ public class RegionFile implements AutoCloseable {
@VisibleForTesting
protected final RegionBitmap usedSectors;
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(); // Paper
+ public final Path regionFile; // Paper
public RegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException {
this(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format
@@ -56,6 +60,8 @@ public class RegionFile implements AutoCloseable {
@@ -56,6 +59,7 @@ public class RegionFile implements AutoCloseable {
public RegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync) throws IOException {
this.header = ByteBuffer.allocateDirect(8192);
+ this.regionFile = file; // Paper
+ initOversizedState(); // Paper
this.usedSectors = new RegionBitmap();
this.info = storageKey;
this.path = path;
@@ -453,6 +459,74 @@ public class RegionFile implements AutoCloseable {
@@ -453,6 +457,74 @@ public class RegionFile implements AutoCloseable {
}
public static final int MAX_CHUNK_SIZE = 500 * 1024 * 1024; // Paper - don't write garbage data to disk if writing serialization fails
@ -124,11 +115,11 @@ index 307196b2a58d4f8db3e6e3c3517a8004d4908b13..69d7a7c2dcee40552d229288c52ed7dd
+ }
+
+ private Path getOversizedMetaFile() {
+ return this.regionFile.getParent().resolve(this.regionFile.getFileName().toString().replaceAll("\\.mca$", "") + ".oversized.nbt");
+ return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + ".oversized.nbt");
+ }
+
+ private Path getOversizedFile(int x, int z) {
+ return this.regionFile.getParent().resolve(this.regionFile.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
+ return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
+ }
+
+ synchronized CompoundTag getOversizedData(int x, int z) throws IOException {

View File

@ -90,20 +90,20 @@ index 721b63f7471ace33ae22f4205f554ee3be0e033d..c22b40790a28c9a670538a8cc97821b3
// Spigot start
return this.anyPlayerCloseEnoughForSpawning(pos, false);
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index 69d7a7c2dcee40552d229288c52ed7dd6ad0c2a8..36cdf165334c4d7c1ca28ba42b1006b163e45a95 100644
index c9fd589b1354ac788b63d163d427e8cc5fbba3c5..27d3209275d621a211a82436667ba1a8eae605c7 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -53,6 +53,29 @@ public class RegionFile implements AutoCloseable {
@@ -52,6 +52,29 @@ public class RegionFile implements AutoCloseable {
@VisibleForTesting
protected final RegionBitmap usedSectors;
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(); // Paper
public final Path regionFile; // Paper
+ // Paper start - Cache chunk status
+ private final net.minecraft.world.level.chunk.ChunkStatus[] statuses = new net.minecraft.world.level.chunk.ChunkStatus[32 * 32];
+ private final net.minecraft.world.level.chunk.status.ChunkStatus[] statuses = new net.minecraft.world.level.chunk.status.ChunkStatus[32 * 32];
+
+ private boolean closed;
+
+ // invoked on write/read
+ public void setStatus(int x, int z, net.minecraft.world.level.chunk.ChunkStatus status) {
+ public void setStatus(int x, int z, net.minecraft.world.level.chunk.status.ChunkStatus status) {
+ if (this.closed) {
+ // We've used an invalid region file.
+ throw new IllegalStateException("RegionFile is closed");
@ -111,7 +111,7 @@ index 69d7a7c2dcee40552d229288c52ed7dd6ad0c2a8..36cdf165334c4d7c1ca28ba42b1006b1
+ this.statuses[getChunkLocation(x, z)] = status;
+ }
+
+ public net.minecraft.world.level.chunk.ChunkStatus getStatusIfCached(int x, int z) {
+ public net.minecraft.world.level.chunk.status.ChunkStatus getStatusIfCached(int x, int z) {
+ if (this.closed) {
+ // We've used an invalid region file.
+ throw new IllegalStateException("RegionFile is closed");
@ -123,7 +123,7 @@ index 69d7a7c2dcee40552d229288c52ed7dd6ad0c2a8..36cdf165334c4d7c1ca28ba42b1006b1
public RegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException {
this(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format
@@ -419,6 +442,7 @@ public class RegionFile implements AutoCloseable {
@@ -417,6 +440,7 @@ public class RegionFile implements AutoCloseable {
return this.getOffset(pos) != 0;
}
@ -131,7 +131,7 @@ index 69d7a7c2dcee40552d229288c52ed7dd6ad0c2a8..36cdf165334c4d7c1ca28ba42b1006b1
private static int getOffsetIndex(ChunkPos pos) {
return pos.getRegionLocalX() + pos.getRegionLocalZ() * 32;
}
@@ -429,6 +453,7 @@ public class RegionFile implements AutoCloseable {
@@ -427,6 +451,7 @@ public class RegionFile implements AutoCloseable {
synchronized (this) {
try {
// Paper end

View File

@ -1003,7 +1003,7 @@ index 883fbe5c81e3be27007a1a0489f80ba1863e5a04..a4a919d8373f1535e336de7e648d41a0
return Optional.empty();
} else {
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
index a61959700d5e00739a79eaa617ac383160335f26..52b15b52629bbf79af4f7bd8e0992d3f17f3eacc 100644
index a61959700d5e00739a79eaa617ac383160335f26..2407d93c11b806701fc7d192f39d535128281e80 100644
--- a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
+++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
@@ -51,18 +51,39 @@ public class PortalForcer {
@ -1029,9 +1029,9 @@ index a61959700d5e00739a79eaa617ac383160335f26..52b15b52629bbf79af4f7bd8e0992d3f
+ villageplace,
+ type -> type.is(PoiTypes.NETHER_PORTAL),
+ (BlockPos pos) -> {
+ net.minecraft.world.level.chunk.ChunkAccess lowest = this.level.getChunk(pos.getX() >> 4, pos.getZ() >> 4, net.minecraft.world.level.chunk.ChunkStatus.EMPTY);
+ if (!lowest.getStatus().isOrAfter(net.minecraft.world.level.chunk.ChunkStatus.FULL)
+ && (lowest.getBelowZeroRetrogen() == null || !lowest.getBelowZeroRetrogen().targetStatus().isOrAfter(net.minecraft.world.level.chunk.ChunkStatus.SPAWN))) {
+ net.minecraft.world.level.chunk.ChunkAccess lowest = this.level.getChunk(pos.getX() >> 4, pos.getZ() >> 4, net.minecraft.world.level.chunk.status.ChunkStatus.EMPTY);
+ if (!lowest.getStatus().isOrAfter(net.minecraft.world.level.chunk.status.ChunkStatus.FULL)
+ && (lowest.getBelowZeroRetrogen() == null || !lowest.getBelowZeroRetrogen().targetStatus().isOrAfter(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN))) {
+ // why would we generate the chunk?
+ return false;
+ }

View File

@ -87,14 +87,13 @@ index a23dc2f8f4475de1ee35bf18a7a8a53233ccac12..226af44fd469053451a0403a95ffb446
this.used.set(start, start + size);
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f16573e58 100644
index 27d3209275d621a211a82436667ba1a8eae605c7..9fdbea51d96e54b52b63de04f2845c62bfd0117a 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -53,6 +53,356 @@ public class RegionFile implements AutoCloseable {
@@ -52,6 +52,354 @@ public class RegionFile implements AutoCloseable {
@VisibleForTesting
protected final RegionBitmap usedSectors;
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(); // Paper
public final Path regionFile; // Paper
+
+ // Paper start - Attempt to recalculate regionfile header if it is corrupt
+ private static long roundToSectors(long bytes) {
+ long sectors = bytes >>> 12; // 4096 = 2^12
@ -153,15 +152,15 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ }
+
+ private void backupRegionFile() {
+ Path backup = this.regionFile.getParent().resolve(this.regionFile.getFileName() + "." + new java.util.Random().nextLong() + ".backup");
+ Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new java.util.Random().nextLong() + ".backup");
+ this.backupRegionFile(backup);
+ }
+
+ private void backupRegionFile(Path to) {
+ try {
+ this.file.force(true);
+ LOGGER.warn("Backing up regionfile \"" + this.regionFile.toAbsolutePath() + "\" to " + to.toAbsolutePath());
+ java.nio.file.Files.copy(this.regionFile, to, java.nio.file.StandardCopyOption.COPY_ATTRIBUTES);
+ LOGGER.warn("Backing up regionfile \"" + this.path.toAbsolutePath() + "\" to " + to.toAbsolutePath());
+ java.nio.file.Files.copy(this.path, to, java.nio.file.StandardCopyOption.COPY_ATTRIBUTES);
+ LOGGER.warn("Backed up the regionfile to " + to.toAbsolutePath());
+ } catch (IOException ex) {
+ LOGGER.error("Failed to backup to " + to.toAbsolutePath(), ex);
@ -177,13 +176,13 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ if (!this.canRecalcHeader) {
+ return false;
+ }
+ ChunkPos ourLowerLeftPosition = RegionFileStorage.getRegionFileCoordinates(this.regionFile);
+ ChunkPos ourLowerLeftPosition = RegionFileStorage.getRegionFileCoordinates(this.path);
+ if (ourLowerLeftPosition == null) {
+ LOGGER.error("Unable to get chunk location of regionfile " + this.regionFile.toAbsolutePath() + ", cannot recover header");
+ LOGGER.error("Unable to get chunk location of regionfile " + this.path.toAbsolutePath() + ", cannot recover header");
+ return false;
+ }
+ synchronized (this) {
+ LOGGER.warn("Corrupt regionfile header detected! Attempting to re-calculate header offsets for regionfile " + this.regionFile.toAbsolutePath(), new Throwable());
+ LOGGER.warn("Corrupt regionfile header detected! Attempting to re-calculate header offsets for regionfile " + this.path.toAbsolutePath(), new Throwable());
+
+ // try to backup file so maybe it could be sent to us for further investigation
+
@ -207,7 +206,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+
+ ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(compound);
+ if (!inSameRegionfile(ourLowerLeftPosition, chunkPos)) {
+ LOGGER.error("Ignoring absolute chunk " + chunkPos + " in regionfile as it is not contained in the bounds of the regionfile '" + this.regionFile.toAbsolutePath() + "'. It should be in regionfile (" + (chunkPos.x >> 5) + "," + (chunkPos.z >> 5) + ")");
+ LOGGER.error("Ignoring absolute chunk " + chunkPos + " in regionfile as it is not contained in the bounds of the regionfile '" + this.path.toAbsolutePath() + "'. It should be in regionfile (" + (chunkPos.x >> 5) + "," + (chunkPos.z >> 5) + ")");
+ continue;
+ }
+ int location = (chunkPos.x & 31) | ((chunkPos.z & 31) << 5);
@ -229,7 +228,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ isAikarOversized = true;
+ }
+ } catch (Exception ex) {
+ LOGGER.error("Failed to read aikar oversized data for absolute chunk (" + chunkPos.x + "," + chunkPos.z + ") in regionfile " + this.regionFile.toAbsolutePath() + ", oversized data for this chunk will be lost", ex);
+ LOGGER.error("Failed to read aikar oversized data for absolute chunk (" + chunkPos.x + "," + chunkPos.z + ") in regionfile " + this.path.toAbsolutePath() + ", oversized data for this chunk will be lost", ex);
+ // fall through, if we can't read aikar oversized we can't risk corrupting chunk data
+ }
+ }
@ -337,7 +336,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ if (newSectorAllocations.tryAllocate(sectorOffset, sectorLength)) {
+ calculatedOffsets[location] = sectorOffset << 8 | (sectorLength > 255 ? 255 : sectorLength); // support forge style oversized
+ } else {
+ LOGGER.error("Failed to allocate space for local chunk (overlapping data??) at (" + chunkX + "," + chunkZ + ") in regionfile " + this.regionFile.toAbsolutePath() + ", chunk will be regenerated");
+ LOGGER.error("Failed to allocate space for local chunk (overlapping data??) at (" + chunkX + "," + chunkZ + ") in regionfile " + this.path.toAbsolutePath() + ", chunk will be regenerated");
+ }
+ }
+ }
@ -361,7 +360,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ calculatedOffsets[location] = sectorOffset << 8 | (sectorLength > 255 ? 255 : sectorLength); // support forge style oversized
+ } catch (IOException ex) {
+ newSectorAllocations.free(sectorOffset, sectorLength);
+ LOGGER.error("Failed to write new oversized chunk data holder, local chunk at (" + chunkX + "," + chunkZ + ") in regionfile " + this.regionFile.toAbsolutePath() + " will be regenerated");
+ LOGGER.error("Failed to write new oversized chunk data holder, local chunk at (" + chunkX + "," + chunkZ + ") in regionfile " + this.path.toAbsolutePath() + " will be regenerated");
+ }
+ }
+ }
@ -383,7 +382,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ try {
+ this.writeOversizedMeta();
+ } catch (Exception ex) {
+ LOGGER.error("Failed to write aikar oversized chunk meta, all aikar style oversized chunk data will be lost for regionfile " + this.regionFile.toAbsolutePath(), ex);
+ LOGGER.error("Failed to write aikar oversized chunk meta, all aikar style oversized chunk data will be lost for regionfile " + this.path.toAbsolutePath(), ex);
+ Files.deleteIfExists(this.getOversizedMetaFile());
+ }
+ } else {
@ -394,7 +393,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+
+ // before we overwrite the old sectors, print a summary of the chunks that got changed.
+
+ LOGGER.info("Starting summary of changes for regionfile " + this.regionFile.toAbsolutePath());
+ LOGGER.info("Starting summary of changes for regionfile " + this.path.toAbsolutePath());
+
+ for (int chunkX = 0; chunkX < 32; ++chunkX) {
+ for (int chunkZ = 0; chunkZ < 32; ++chunkZ) {
@ -411,16 +410,16 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+
+ if (oldOffset == 0) {
+ // found lost data
+ LOGGER.info("Found missing data for local chunk (" + chunkX + "," + chunkZ + ") in regionfile " + this.regionFile.toAbsolutePath());
+ LOGGER.info("Found missing data for local chunk (" + chunkX + "," + chunkZ + ") in regionfile " + this.path.toAbsolutePath());
+ } else if (newOffset == 0) {
+ LOGGER.warn("Data for local chunk (" + chunkX + "," + chunkZ + ") could not be recovered in regionfile " + this.regionFile.toAbsolutePath() + ", it will be regenerated");
+ LOGGER.warn("Data for local chunk (" + chunkX + "," + chunkZ + ") could not be recovered in regionfile " + this.path.toAbsolutePath() + ", it will be regenerated");
+ } else {
+ LOGGER.info("Local chunk (" + chunkX + "," + chunkZ + ") changed to point to newer data or correct chunk in regionfile " + this.regionFile.toAbsolutePath());
+ LOGGER.info("Local chunk (" + chunkX + "," + chunkZ + ") changed to point to newer data or correct chunk in regionfile " + this.path.toAbsolutePath());
+ }
+ }
+ }
+
+ LOGGER.info("End of change summary for regionfile " + this.regionFile.toAbsolutePath());
+ LOGGER.info("End of change summary for regionfile " + this.path.toAbsolutePath());
+
+ // simply destroy the timestamp header, it's not used
+
@ -432,9 +431,9 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ try {
+ this.flush();
+ this.file.force(true); // try to ensure it goes through...
+ LOGGER.info("Successfully wrote new header to disk for regionfile " + this.regionFile.toAbsolutePath());
+ LOGGER.info("Successfully wrote new header to disk for regionfile " + this.path.toAbsolutePath());
+ } catch (IOException ex) {
+ LOGGER.error("Failed to write new header to disk for regionfile " + this.regionFile.toAbsolutePath(), ex);
+ LOGGER.error("Failed to write new header to disk for regionfile " + this.path.toAbsolutePath(), ex);
+ }
+ }
+
@ -443,11 +442,10 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+
+ final boolean canRecalcHeader; // final forces compile fail on new constructor
+ // Paper end - Attempt to recalculate regionfile header if it is corrupt
+
// Paper start - Cache chunk status
private final net.minecraft.world.level.chunk.ChunkStatus[] statuses = new net.minecraft.world.level.chunk.ChunkStatus[32 * 32];
private final net.minecraft.world.level.chunk.status.ChunkStatus[] statuses = new net.minecraft.world.level.chunk.status.ChunkStatus[32 * 32];
@@ -80,8 +430,18 @@ public class RegionFile implements AutoCloseable {
@@ -79,8 +427,18 @@ public class RegionFile implements AutoCloseable {
public RegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException {
this(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format
}
@ -464,9 +462,9 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ this.canRecalcHeader = canRecalcHeader;
+ // Paper end - add can recalc flag
this.header = ByteBuffer.allocateDirect(8192);
this.regionFile = file; // Paper
initOversizedState(); // Paper
@@ -112,14 +472,16 @@ public class RegionFile implements AutoCloseable {
this.usedSectors = new RegionBitmap();
@@ -110,14 +468,16 @@ public class RegionFile implements AutoCloseable {
RegionFile.LOGGER.warn("Region file {} has truncated header: {}", path, i);
}
@ -488,7 +486,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
// Spigot start
if (j1 == 255) {
// We're maxed out, so we need to read the proper length from the section
@@ -128,21 +490,66 @@ public class RegionFile implements AutoCloseable {
@@ -126,21 +486,66 @@ public class RegionFile implements AutoCloseable {
j1 = (realLen.getInt(0) + 4) / 4096 + 1;
}
// Spigot end
@ -513,12 +511,12 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ // Paper start - recalculate header on header corruption
+ if (offset < 2 || sectorLength <= 0 || ((long)offset * 4096L) > regionFileSize) {
+ if (canRecalcHeader) {
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() + "! Recalculating header...");
+ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() + "! Recalculating header...");
+ needsHeaderRecalc = true;
+ break;
+ } else {
+ // location = chunkX | (chunkZ << 5);
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() +
+ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() +
+ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header");
+ if (!hasBackedUp) {
+ hasBackedUp = true;
@ -531,11 +529,11 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ }
+ boolean failedToAllocate = !this.usedSectors.tryAllocate(offset, sectorLength);
+ if (failedToAllocate) {
+ LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.regionFile.toAbsolutePath());
+ LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.path.toAbsolutePath());
}
+ if (failedToAllocate & !canRecalcHeader) {
+ // location = chunkX | (chunkZ << 5);
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() +
+ LOGGER.error("Detected invalid header for regionfile " + this.path.toAbsolutePath() +
+ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header");
+ if (!hasBackedUp) {
+ hasBackedUp = true;
@ -552,14 +550,14 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
+ // Paper start - recalculate header on header corruption
+ // we move the recalc here so comparison to old header is correct when logging to console
+ if (needsHeaderRecalc) { // true if header gave us overlapping allocations or had other issues
+ LOGGER.error("Recalculating regionfile " + this.regionFile.toAbsolutePath() + ", header gave erroneous offsets & locations");
+ LOGGER.error("Recalculating regionfile " + this.path.toAbsolutePath() + ", header gave erroneous offsets & locations");
+ this.recalculateHeader();
+ }
+ // Paper end
}
}
@@ -153,11 +560,36 @@ public class RegionFile implements AutoCloseable {
@@ -151,11 +556,36 @@ public class RegionFile implements AutoCloseable {
}
private Path getExternalChunkPath(ChunkPos chunkPos) {
@ -597,7 +595,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
@Nullable
public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException {
int i = this.getOffset(pos);
@@ -181,6 +613,11 @@ public class RegionFile implements AutoCloseable {
@@ -179,6 +609,11 @@ public class RegionFile implements AutoCloseable {
((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error
if (bytebuffer.remaining() < 5) {
RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", new Object[]{pos, l, bytebuffer.remaining()});
@ -609,7 +607,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
return null;
} else {
int i1 = bytebuffer.getInt();
@@ -188,6 +625,11 @@ public class RegionFile implements AutoCloseable {
@@ -186,6 +621,11 @@ public class RegionFile implements AutoCloseable {
if (i1 == 0) {
RegionFile.LOGGER.warn("Chunk {} is allocated, but stream is missing", pos);
@ -621,7 +619,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
return null;
} else {
int j1 = i1 - 1;
@@ -195,18 +637,45 @@ public class RegionFile implements AutoCloseable {
@@ -193,18 +633,45 @@ public class RegionFile implements AutoCloseable {
if (RegionFile.isExternalStreamChunk(b0)) {
if (j1 != 0) {
RegionFile.LOGGER.warn("Chunk has both internal and external streams");
@ -669,7 +667,7 @@ index 36cdf165334c4d7c1ca28ba42b1006b163e45a95..6e8c488ed05495237e06e44005d3656f
}
}
}
@@ -392,10 +861,15 @@ public class RegionFile implements AutoCloseable {
@@ -390,10 +857,15 @@ public class RegionFile implements AutoCloseable {
}
private ByteBuffer createExternalStub() {

View File

@ -105,7 +105,7 @@ index be668387f65a633c6ac497fca632a4767a1bf3a2..e08f4e39db4ee3fed62e37364d17dcc5
}
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee0331a6bc40cdde08d926fd8eb1dc642630c2e5
index 0000000000000000000000000000000000000000..ee8e9c0e3690e78f3cc621ddfca89ea4256d4803
--- /dev/null
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -0,0 +1,1851 @@
@ -127,7 +127,7 @@ index 0000000000000000000000000000000000000000..ee0331a6bc40cdde08d926fd8eb1dc64
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.border.WorldBorder;
+import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkStatus;
+import net.minecraft.world.level.chunk.status.ChunkStatus;
+import net.minecraft.world.level.chunk.LevelChunkSection;
+import net.minecraft.world.level.chunk.PalettedContainer;
+import net.minecraft.world.level.material.FluidState;

View File

@ -22,7 +22,7 @@ Alternate Current's wire handler.
diff --git a/src/main/java/alternate/current/wire/LevelHelper.java b/src/main/java/alternate/current/wire/LevelHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..7d60b8b6dd7f3a2878e75c78f329bc4158c80aec
index 0000000000000000000000000000000000000000..8b4697421d57f81ff1794c6f845258e10df91622
--- /dev/null
+++ b/src/main/java/alternate/current/wire/LevelHelper.java
@@ -0,0 +1,66 @@
@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..7d60b8b6dd7f3a2878e75c78f329bc41
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkStatus;
+import net.minecraft.world.level.chunk.status.ChunkStatus;
+import net.minecraft.world.level.chunk.LevelChunkSection;
+
+public class LevelHelper {