mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Patching patched patched patches
This commit is contained in:
parent
eac356d807
commit
00dec09758
@ -29,13 +29,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
public boolean isRealPlayer; // Paper
|
||||
public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
|
||||
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
||||
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
|
||||
+ public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event
|
||||
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, @Nullable ProfilePublicKey publicKey) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile, publicKey);
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
@@ -0,0 +0,0 @@ public abstract class WaterFluid extends FlowingFluid {
|
||||
return true;
|
||||
return world.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION);
|
||||
}
|
||||
|
||||
+ // Paper start
|
@ -56,12 +56,12 @@ diff --git a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java b/sr
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
|
||||
@@ -0,0 +0,0 @@ public abstract class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock
|
||||
@@ -0,0 +0,0 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide && this.sensitive && !(Boolean) state.getValue(ButtonBlock.POWERED)) {
|
||||
if (!world.isClientSide && this.arrowsCanPress && !(Boolean) state.getValue(ButtonBlock.POWERED)) {
|
||||
this.checkPressed(state, world, pos);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
@ -197,8 +197,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.packRepository.setSelected(dataPacks);
|
||||
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
|
||||
|
||||
this.worldData.setDataConfiguration(worlddataconfiguration);
|
||||
this.resources.managers.updateRegistryTags(this.registryAccess());
|
||||
+ io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper
|
||||
new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
|
||||
@ -225,9 +225,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
|
||||
MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, Collections.singletonList(new VanillaPackResources(ServerPacksSource.BUILT_IN_METADATA, "minecraft")));
|
||||
// add tags and loot tables for unit tests
|
||||
REGISTRY_CUSTOM = RegistryAccess.builtinCopy().freeze();
|
||||
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
REGISTRY_CUSTOM = layers.compositeAccess().freeze();
|
||||
+ // Paper start
|
||||
+ try {
|
||||
+ java.lang.reflect.Field field = io.papermc.paper.registry.PaperRegistry.class.getDeclaredField("REGISTRY_ACCESS");
|
||||
@ -238,5 +238,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ // Paper end
|
||||
// Register vanilla pack
|
||||
DATA_PACK = ReloadableServerResources.loadResources(resourceManager, REGISTRY_CUSTOM, Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
DATA_PACK = ReloadableServerResources.loadResources(resourceManager, REGISTRY_CUSTOM, FeatureFlags.REGISTRY.allFlags(), Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
// Bind tags
|
@ -95,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
||||
|
||||
this.chatPreviewThrottler.tick();
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
return this.server.isSingleplayerOwner(this.player.getGameProfile());
|
||||
}
|
||||
@ -115,13 +115,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public void disconnect(final Component reason) {
|
||||
- this.disconnect(PaperAdventure.asAdventure(reason));
|
||||
+ this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
|
||||
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
|
||||
}
|
||||
|
||||
- public void disconnect(net.kyori.adventure.text.Component reason) {
|
||||
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
|
||||
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
|
||||
+ }
|
||||
+
|
||||
+ public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
|
||||
// Paper end
|
||||
// CraftBukkit start - fire PlayerKickEvent
|
||||
@ -247,8 +247,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause
|
||||
} else {
|
||||
if (this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages())) {
|
||||
// this.server.submit(() -> { // CraftBukkit - async chat
|
||||
Optional<LastSeenMessages> optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages());
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleChatCommand(ServerboundChatCommandPacket packet) {
|
||||
@ -256,26 +256,50 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper
|
||||
} else {
|
||||
if (this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages())) {
|
||||
this.server.submit(() -> {
|
||||
Optional<LastSeenMessages> optional = this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages());
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
private boolean tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
|
||||
private Optional<LastSeenMessages> tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
|
||||
if (!this.updateChatOrder(timestamp)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message);
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event cause
|
||||
return false;
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event ca
|
||||
return Optional.empty();
|
||||
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
|
||||
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
this.detectRateSpam(s); // Spigot
|
||||
}
|
||||
|
||||
if (!message.verify(chatsender)) {
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.unsigned_chat"));
|
||||
+<<<<<<< HEAD
|
||||
+=======
|
||||
+ private boolean verifyChatMessage(PlayerChatMessage message) {
|
||||
+ ChatSender chatsender = this.player.asChatSender();
|
||||
+ ProfilePublicKey profilepublickey = chatsender.profilePublicKey();
|
||||
+
|
||||
+ if (profilepublickey != null) {
|
||||
+ if (profilepublickey.data().hasExpired()) {
|
||||
+ this.player.sendSystemMessage(Component.translatable("chat.disabled.expiredProfileKey").withStyle(ChatFormatting.RED));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!message.verify(chatsender)) {
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.unsigned_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event cause
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (message.hasExpiredServer(Instant.now())) {
|
||||
+ ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized?", this.player.getName().getString(), message.signedContent().plain());
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+>>>>>>> Add PlayerKickEvent causes
|
||||
// Spigot start - spam exclusions
|
||||
private void detectRateSpam(String s) {
|
||||
// CraftBukkit start - replaced with thread safe throttle
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// this.chatSpamTickCount += 20;
|
||||
if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
||||
@ -286,11 +310,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
|
||||
private void handleValidationFailure(Set<LastSeenMessagesValidator.ErrorCondition> reasons) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message from {}, reasons: {}", this.player.getName().getString(), reasons.stream().map(LastSeenMessagesValidator.ErrorCondition::message).collect(Collectors.joining(",")));
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.chat_validation_failed"));
|
||||
}
|
||||
+<<<<<<< HEAD
|
||||
+=======
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ private void handleValidationFailure(Set<LastSeenMessagesValidator.ErrorCondition> reasons) {
|
||||
+ ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message from {}, reasons: {}", this.player.getName().getString(), reasons.stream().map(LastSeenMessagesValidator.ErrorCondition::message).collect(Collectors.joining(",")));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.chat_validation_failed"), org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event cause
|
||||
+>>>>>>> Add PlayerKickEvent causes
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -313,8 +344,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
// Spigot End
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// CraftBukkit end
|
||||
}
|
||||
// CraftBukkit end
|
||||
} else {
|
||||
- ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked"));
|
||||
+ ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_ENTITY_ATTACKED); // Paper - add cause
|
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
||||
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
- BeehiveBlock.dropHoneycomb(world, pos);
|
||||
+ // Paper start - Add PlayerShearBlockEvent
|
||||
+ for (org.bukkit.inventory.ItemStack itemDrop : event.getDrops()) {
|
@ -124,44 +124,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@@ -0,0 +0,0 @@ public class MerchantMenu extends AbstractContainerMenu {
|
||||
|
||||
itemstack = itemstack1.copy();
|
||||
if (index == 2) {
|
||||
if (slot == 2) {
|
||||
- if (!this.moveItemStackTo(itemstack1, 3, 39, true)) {
|
||||
+ if (!this.moveItemStackTo(itemstack1, 3, 39, true, true)) { // Paper
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
- slot.onQuickCraft(itemstack1, itemstack);
|
||||
- slot1.onQuickCraft(itemstack1, itemstack);
|
||||
- this.playTradeSound();
|
||||
+ // slot.onQuickCraft(itemstack1, itemstack); // Paper - moved to after the non-check moveItemStackTo call
|
||||
+ // slot1.onQuickCraft(itemstack1, itemstack); // Paper - moved to after the non-check moveItemStackTo call
|
||||
+ // this.playTradeSound();
|
||||
} else if (index != 0 && index != 1) {
|
||||
if (index >= 3 && index < 30) {
|
||||
} else if (slot != 0 && slot != 1) {
|
||||
if (slot >= 3 && slot < 30) {
|
||||
if (!this.moveItemStackTo(itemstack1, 30, 39, false)) {
|
||||
@@ -0,0 +0,0 @@ public class MerchantMenu extends AbstractContainerMenu {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
+ if (index != 2) { // Paper - moved down for slot 2
|
||||
+ if (slot != 2) { // Paper - moved down for slot 2
|
||||
if (itemstack1.isEmpty()) {
|
||||
slot.set(ItemStack.EMPTY);
|
||||
slot1.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
@@ -0,0 +0,0 @@ public class MerchantMenu extends AbstractContainerMenu {
|
||||
}
|
||||
|
||||
slot.onTake(player, itemstack1);
|
||||
slot1.onTake(player, itemstack1);
|
||||
+ } // Paper start - handle slot 2
|
||||
+ if (index == 2) { // is merchant result slot
|
||||
+ slot.onTake(player, itemstack1);
|
||||
+ if (slot == 2) { // is merchant result slot
|
||||
+ slot1.onTake(player, itemstack1);
|
||||
+ if (itemstack1.isEmpty()) {
|
||||
+ slot.set(ItemStack.EMPTY);
|
||||
+ slot1.set(ItemStack.EMPTY);
|
||||
+ return ItemStack.EMPTY;
|
||||
+ }
|
||||
+
|
||||
+ this.moveItemStackTo(itemstack1, 3, 39, true, false); // This should always succeed because it's checked above
|
||||
+
|
||||
+ slot.onQuickCraft(itemstack1, itemstack);
|
||||
+ slot1.onQuickCraft(itemstack1, itemstack);
|
||||
+ this.playTradeSound();
|
||||
+ slot.set(ItemStack.EMPTY); // itemstack1 should ALWAYS be empty
|
||||
+ slot1.set(ItemStack.EMPTY); // itemstack1 should ALWAYS be empty
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
||||
@@ -0,0 +0,0 @@ public class SmithingMenu extends ItemCombinerMenu {
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
@ -99,16 +99,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures());
|
||||
+ }
|
||||
+ // Paper end
|
||||
ChunkGeneratorStructureState chunkgeneratorstructurestate = world.getChunkSource().getGeneratorState();
|
||||
Map<StructurePlacement, Set<Holder<Structure>>> map = new Object2ObjectArrayMap();
|
||||
Iterator iterator = structures.iterator();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Structure {
|
||||
public static final Codec<Structure> DIRECT_CODEC = Registry.STRUCTURE_TYPES.byNameCodec().dispatch(Structure::type, StructureType::codec);
|
||||
public static final Codec<Holder<Structure>> CODEC = RegistryFileCodec.create(Registry.STRUCTURE_REGISTRY, DIRECT_CODEC);
|
||||
public static final Codec<Structure> DIRECT_CODEC = BuiltInRegistries.STRUCTURE_TYPE.byNameCodec().dispatch(Structure::type, StructureType::codec);
|
||||
public static final Codec<Holder<Structure>> CODEC = RegistryFileCodec.create(Registries.STRUCTURE, DIRECT_CODEC);
|
||||
protected final Structure.StructureSettings settings;
|
||||
+ static { io.papermc.paper.world.structure.PaperConfiguredStructure.init(); } // Paper
|
||||
|
||||
@ -212,3 +212,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ System.setOut(out);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
|
||||
REGISTRY_CUSTOM = layers.compositeAccess().freeze();
|
||||
// Paper start
|
||||
try {
|
||||
- java.lang.reflect.Field field = io.papermc.paper.registry.PaperRegistry.class.getDeclaredField("REGISTRY_ACCESS");
|
||||
+ java.lang.reflect.Field field = io.papermc.paper.registry.PaperRegistry.class.getDeclaredField("REGISTRgY_ACCESS");
|
||||
field.trySetAccessible();
|
||||
field.set(null, com.google.common.base.Suppliers.ofInstance(REGISTRY_CUSTOM));
|
||||
} catch (ReflectiveOperationException ex) {
|
@ -26,8 +26,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static DamageSource sting(LivingEntity attacker) {
|
||||
return new EntityDamageSource("sting", attacker);
|
||||
public static DamageSource fallingBlock(Entity attacker) {
|
||||
return (new EntityDamageSource("fallingBlock", attacker)).damageHelmet();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListene
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
|
||||
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
public void fireEvents() throws Exception {
|
||||
String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName();
|
||||
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
|
@ -33,11 +33,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}).orElse(itemstack);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
||||
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
|
||||
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
|
||||
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
|
||||
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
|
||||
|
||||
- BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result);
|
||||
- BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result);
|
||||
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result, (org.bukkit.inventory.CookingRecipe<?>) recipe.map(CampfireCookingRecipe::toBukkitRecipe).orElse(null)); // Paper
|
||||
world.getCraftServer().getPluginManager().callEvent(blockCookEvent);
|
||||
world.getCraftServer().getPluginManager().callEvent(blockCookEvent);
|
||||
|
||||
if (blockCookEvent.isCancelled()) {
|
||||
if (blockCookEvent.isCancelled()) {
|
@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
public final PlayerDataStorage playerIo;
|
||||
private boolean doWhiteList;
|
||||
private final RegistryAccess.Frozen registryHolder;
|
||||
private final LayeredRegistryAccess<RegistryLayer> registries;
|
||||
private final RegistryAccess.Frozen synchronizedRegistries;
|
||||
- protected final int maxPlayers;
|
||||
+ protected int maxPlayers; public final void setMaxPlayers(int maxPlayers) { this.maxPlayers = maxPlayers; } // Paper - remove final and add setter
|
||||
private int viewDistance;
|
@ -11,9 +11,9 @@ diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.util.VisibleForDebug;
|
||||
|
||||
@@ -0,0 +0,0 @@ import org.slf4j.Logger;
|
||||
public class GossipContainer {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final int DISCARD_THRESHOLD = 2;
|
||||
- private final Map<UUID, GossipContainer.EntityGossips> gossips = Maps.newHashMap();
|
||||
+ private final Map<UUID, GossipContainer.EntityGossips> gossips = Maps.newHashMap(); public Map<UUID, GossipContainer.EntityGossips> getReputations() { return this.gossips; } // Paper - add getter for reputations
|
||||
@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
static class GossipEntry {
|
||||
static record GossipEntry(UUID target, GossipType type, int value) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.Villager entity) {
|
||||
@@ -0,0 +0,0 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
public static VillagerProfession bukkitToNmsProfession(Profession bukkit) {
|
||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
|
||||
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
|
||||
}
|
||||
+
|
||||
+ // Paper start - Add villager reputation API
|
@ -19,12 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ public CompletableFuture<Void> reloadResources(Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) {
|
||||
+ // Paper end
|
||||
RegistryAccess.Frozen iregistrycustom_dimension = this.registryAccess();
|
||||
RegistryAccess.Frozen iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.packRepository.setSelected(dataPacks);
|
||||
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
|
||||
|
||||
this.worldData.setDataConfiguration(worlddataconfiguration);
|
||||
this.resources.managers.updateRegistryTags(this.registryAccess());
|
||||
+ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
|
||||
// Paper start
|
@ -146,14 +146,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ final @Nullable ServerPlayer player;
|
||||
+ final @Nullable CommandSourceStack commandSourceStack;
|
||||
+ final Component originalMessage;
|
||||
+ final boolean isPreview;
|
||||
+
|
||||
+ public ChatDecorationProcessor(final MinecraftServer server, final @Nullable ServerPlayer player, final @Nullable CommandSourceStack commandSourceStack, final net.minecraft.network.chat.Component originalMessage, final boolean isPreview) {
|
||||
+ public ChatDecorationProcessor(final MinecraftServer server, final @Nullable ServerPlayer player, final @Nullable CommandSourceStack commandSourceStack, final net.minecraft.network.chat.Component originalMessage) {
|
||||
+ this.server = server;
|
||||
+ this.player = player;
|
||||
+ this.commandSourceStack = commandSourceStack;
|
||||
+ this.originalMessage = PaperAdventure.asAdventure(originalMessage);
|
||||
+ this.isPreview = isPreview;
|
||||
+ }
|
||||
+
|
||||
+ public CompletableFuture<ChatDecorator.Result> process() {
|
||||
@ -190,11 +188,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ final Component initialResult = input.message().component();
|
||||
+ final AsyncChatDecorateEvent event;
|
||||
+ //TODO
|
||||
+ if (this.commandSourceStack != null) {
|
||||
+ // TODO more command decorate context
|
||||
+ event = new AsyncChatCommandDecorateEvent(true, player, this.originalMessage, this.isPreview, initialResult);
|
||||
+ event = new AsyncChatCommandDecorateEvent(true, player, this.originalMessage, false, initialResult);
|
||||
+ } else {
|
||||
+ event = new AsyncChatDecorateEvent(true, player, this.originalMessage, this.isPreview, initialResult);
|
||||
+ event = new AsyncChatDecorateEvent(true, player, this.originalMessage, false, initialResult);
|
||||
+ }
|
||||
+ this.post(event);
|
||||
+ if (!event.isCancelled() && !event.result().equals(initialResult)) {
|
||||
@ -1902,8 +1901,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- }, chatExecutor);
|
||||
- };
|
||||
+ // Paper start - moved to ChatPreviewProcessor
|
||||
+ return ChatDecorator.create((sender, commandSourceStack, message, isPreview) -> {
|
||||
+ final io.papermc.paper.adventure.ChatDecorationProcessor processor = new io.papermc.paper.adventure.ChatDecorationProcessor(this, sender, commandSourceStack, message, isPreview);
|
||||
+ return ChatDecorator.create((sender, commandSourceStack, message) -> {
|
||||
+ final io.papermc.paper.adventure.ChatDecorationProcessor processor = new io.papermc.paper.adventure.ChatDecorationProcessor(this, sender, commandSourceStack, message);
|
||||
+ return processor.process();
|
||||
+ });
|
||||
+ // Paper end
|
||||
|
@ -9,11 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
int i = this.player.level.getMaxBuildHeight();
|
||||
int i = this.player.level.getMaxBuildHeight();
|
||||
|
||||
if (blockposition.getY() < i) {
|
||||
- if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
|
||||
if (blockposition.getY() < i) {
|
||||
- if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
|
||||
+ if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && (worldserver.mayInteract(this.player, blockposition) || (worldserver.paperConfig().spawn.allowUsingSignsInsideSpawnProtection && worldserver.getBlockState(blockposition).getBlock() instanceof net.minecraft.world.level.block.SignBlock))) { // Paper - sign check
|
||||
this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEnt
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
return (BeaconBlockEntity.hasSecondaryEffect(this.levels, this.primaryPower, this.secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffectInstance(this.secondaryPower, BeaconBlockEntity.getLevel(this.levels), BeaconBlockEntity.getAmplification(this.levels, this.primaryPower, this.secondaryPower), true, true)) : null;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
public BeaconBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.BEACON, pos, state);
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
|
||||
if (blockEntity.levels > 0 && !blockEntity.beamSections.isEmpty()) {
|
||||
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
BeaconBlockEntity.playSound(world, pos, SoundEvents.BEACON_AMBIENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
|
||||
public static List getHumansInRange(Level world, BlockPos blockposition, int i) {
|
||||
@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
AABB axisalignedbb = (new AABB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
|
||||
List<Player> list = world.getEntitiesOfClass(Player.class, axisalignedbb);
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
|
||||
private static void applyEffects(Level world, BlockPos pos, int beaconLevel, @Nullable MobEffect primaryEffect, @Nullable MobEffect secondaryEffect) {
|
||||
@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0, true, pos); // Paper - BeaconEffectEvent
|
||||
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
|
||||
this.lockKey = LockCode.fromTag(nbt);
|
||||
@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
|
||||
this.lockKey.addToTag(nbt);
|
@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
|
||||
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
|
||||
this.lastSeenMessagesValidator = new LastSeenMessagesValidator();
|
||||
this.lastSeenMessages = new LastSeenMessagesValidator(20);
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
|
||||
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user