mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
more more work (757)
This commit is contained in:
parent
b8911367e6
commit
3ea4a03fbc
37 changed files with 64 additions and 55 deletions
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
|
||||
this.level().getProfiler().push("portal");
|
||||
this.portalTime = i;
|
||||
|
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
this.setPortalCooldown();
|
||||
// CraftBukkit start
|
||||
if (this instanceof ServerPlayer) {
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
} else {
|
||||
this.changeDimension(worldserver1);
|
||||
}
|
|
@ -138,16 +138,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- 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 ServerLoginPacketListener,
|
||||
private final String serverId;
|
||||
private final boolean transferred;
|
||||
private ServerPlayer player; // CraftBukkit
|
||||
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
||||
+ private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
||||
|
||||
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) {
|
||||
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
||||
this.state = ServerLoginPacketListenerImpl.State.HELLO;
|
||||
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
this.state = ServerLoginPacketListenerImpl.State.KEY;
|
||||
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge));
|
||||
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true));
|
||||
} else {
|
||||
+ // Paper start - Add Velocity IP Forwarding Support
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) {
|
||||
|
@ -224,7 +224,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Add Velocity IP Forwarding Support
|
||||
this.disconnect(ServerLoginPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@ -35,5 +35,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ amount = event.getNewAnger() - activeAnger;
|
||||
+ // Paper end - Add WardenAngerChangeEvent
|
||||
WardenAi.setDigCooldown(this);
|
||||
boolean flag1 = !(this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null) instanceof Player); // CraftBukkit - decompile error
|
||||
boolean flag1 = !(this.getTarget() instanceof Player);
|
||||
int j = this.angerManagement.increaseAnger(entity, amount);
|
|
@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
alsoShade(log4jPlugins.output)
|
||||
+ implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol
|
||||
// Paper end
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm-commons:9.7")
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe
|
||||
|
||||
entityitem.setDefaultPickUpDelay();
|
|
@ -10,10 +10,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
@@ -0,0 +0,0 @@ public class WrittenBookItem extends Item {
|
||||
|
||||
public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) {
|
||||
CompoundTag compoundTag = book.getTag();
|
||||
- if (compoundTag != null && !compoundTag.getBoolean("resolved")) {
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper - Disable component selector resolving in books by default
|
||||
compoundTag.putBoolean("resolved", true);
|
||||
if (!makeSureTagIsValid(compoundTag)) {
|
||||
return false;
|
||||
public static boolean resolveBookComponents(ItemStack book, CommandSourceStack commandSource, @Nullable Player player) {
|
||||
WrittenBookContent writtenBookContent = book.get(DataComponents.WRITTEN_BOOK_CONTENT);
|
||||
- if (writtenBookContent != null && !writtenBookContent.resolved()) {
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && writtenBookContent != null && !writtenBookContent.resolved()) { // Paper - Disable component selector resolving in books by default
|
||||
WrittenBookContent writtenBookContent2 = writtenBookContent.resolve(commandSource, player);
|
||||
if (writtenBookContent2 != null) {
|
||||
book.set(DataComponents.WRITTEN_BOOK_CONTENT, writtenBookContent2);
|
|
@ -11,21 +11,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/net/minecraft/core/cauldron/CauldronInteraction.java
|
||||
+++ b/src/main/java/net/minecraft/core/cauldron/CauldronInteraction.java
|
||||
@@ -0,0 +0,0 @@ public interface CauldronInteraction {
|
||||
} else {
|
||||
if (potioncontents != null && potioncontents.is(Potions.WATER)) {
|
||||
if (!world.isClientSide) {
|
||||
// CraftBukkit start
|
||||
- if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
return InteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -0,0 +0,0 @@ public interface CauldronInteraction {
|
||||
if ((Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtils.getPotion(itemstack) == Potions.WATER) {
|
||||
if (potioncontents != null && potioncontents.is(Potions.WATER)) {
|
||||
if (!world.isClientSide) {
|
||||
// CraftBukkit start
|
||||
- if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
return InteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -0,0 +0,0 @@ public interface CauldronInteraction {
|
||||
|
@ -34,16 +34,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
// CraftBukkit start
|
||||
- if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.CAULDRON.defaultBlockState(), player, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.CAULDRON.defaultBlockState(), player, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
return InteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -0,0 +0,0 @@ public interface CauldronInteraction {
|
||||
static InteractionResult emptyBucket(Level world, BlockPos pos, Player player, InteractionHand hand, ItemStack stack, BlockState state, SoundEvent soundEvent) {
|
||||
static ItemInteractionResult emptyBucket(Level world, BlockPos pos, Player player, InteractionHand hand, ItemStack stack, BlockState state, SoundEvent soundEvent) {
|
||||
if (!world.isClientSide) {
|
||||
// CraftBukkit start
|
||||
- if (!LayeredCauldronBlock.changeLevel(state, world, pos, state, player, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, state, player, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
return InteractionResult.SUCCESS;
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
|
||||
|
@ -54,23 +54,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
public void handlePrecipitation(BlockState state, Level world, BlockPos pos, Biome.Precipitation precipitation) {
|
||||
if (CauldronBlock.shouldHandlePrecipitation(world, precipitation)) {
|
||||
if (precipitation == Biome.Precipitation.RAIN) {
|
||||
- world.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState());
|
||||
+ // Paper start - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
world.gameEvent((Entity) null, GameEvent.BLOCK_CHANGE, pos);
|
||||
world.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState());
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_CHANGE, pos);
|
||||
} else if (precipitation == Biome.Precipitation.SNOW) {
|
||||
- world.setBlockAndUpdate(pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState());
|
||||
+ // Paper start - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, world, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
world.gameEvent((Entity) null, GameEvent.BLOCK_CHANGE, pos);
|
||||
world.setBlockAndUpdate(pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState());
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_CHANGE, pos);
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class CauldronBlock extends AbstractCauldronBlock {
|
||||
|
||||
if (fluid == Fluids.WATER) {
|
||||
|
@ -116,8 +115,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
return false;
|
||||
}
|
||||
newState.update(true);
|
||||
- world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock));
|
||||
+ if (sendGameEvent) world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock)); // Paper - Call CauldronLevelChangeEvent
|
||||
- world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock));
|
||||
+ if (sendGameEvent) world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock)); // Paper - Call CauldronLevelChangeEvent
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
|
@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
|
||||
@@ -0,0 +0,0 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||
public CraftBanner copy() {
|
||||
return new CraftBanner(this);
|
||||
public CraftBanner copy(Location location) {
|
||||
return new CraftBanner(this, location);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
|
@ -8,12 +8,12 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
public void baseTick() {
|
||||
this.level().getProfiler().push("entityBaseTick");
|
||||
+ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups
|
||||
this.feetBlockState = null;
|
||||
this.inBlockState = null;
|
||||
if (this.isPassenger() && this.getVehicle().isRemoved()) {
|
||||
this.stopRiding();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/NeutralMob.java b/src/main/java/net/minecraft/world/entity/NeutralMob.java
|
||||
|
@ -28,11 +28,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
-
|
||||
- if (entity != null) {
|
||||
- if (entity instanceof Mob) {
|
||||
- this.setLastHurtByMob((Mob) entity);
|
||||
- Mob entityinsentient = (Mob) entity;
|
||||
-
|
||||
- this.setTarget(entityinsentient);
|
||||
- this.setLastHurtByMob(entityinsentient);
|
||||
- }
|
||||
-
|
||||
- if (entity.getType() == EntityType.PLAYER) {
|
||||
- this.setLastHurtByPlayer((Player) entity);
|
||||
- if (entity instanceof Player) {
|
||||
- Player entityhuman = (Player) entity;
|
||||
-
|
||||
- this.setTarget(entityhuman);
|
||||
- this.setLastHurtByPlayer(entityhuman);
|
||||
- }
|
||||
-
|
||||
- }
|
||||
|
@ -60,14 +66,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ Entity entity = ((ServerLevel) level).getEntity(target);
|
||||
+
|
||||
+ if (entity != null) {
|
||||
+ if (entity instanceof Mob) {
|
||||
+ this.setLastHurtByMob((Mob) entity);
|
||||
+ if (entity instanceof Mob mob) {
|
||||
+ this.setTarget(mob);
|
||||
+ this.setLastHurtByMob(mob);
|
||||
+ }
|
||||
+
|
||||
+ if (entity.getType() == EntityType.PLAYER) {
|
||||
+ this.setLastHurtByPlayer((Player) entity);
|
||||
+ if (entity instanceof Player player) {
|
||||
+ this.setTarget(player);
|
||||
+ this.setLastHurtByPlayer(player);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Prevent entity loading causing async lookups
|
|
@ -9,11 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
||||
@@ -0,0 +0,0 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket
|
||||
private final CompoundTag tag;
|
||||
|
||||
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, Function<BlockEntity, CompoundTag> nbtGetter) {
|
||||
- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), nbtGetter.apply(blockEntity));
|
||||
+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(nbtGetter.apply(blockEntity))); // Paper - Sanitize sent data
|
||||
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, BiFunction<BlockEntity, RegistryAccess, CompoundTag> nbtGetter) {
|
||||
RegistryAccess registryAccess = blockEntity.getLevel().registryAccess();
|
||||
- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), nbtGetter.apply(blockEntity, registryAccess));
|
||||
+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(nbtGetter.apply(blockEntity, registryAccess))); // Paper - Sanitize sent data
|
||||
}
|
||||
|
||||
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) {
|
||||
|
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
||||
@@ -0,0 +0,0 @@ public class ClientboundLevelChunkPacketData {
|
||||
CompoundTag compoundTag = blockEntity.getUpdateTag();
|
||||
CompoundTag compoundTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess());
|
||||
BlockPos blockPos = blockEntity.getBlockPos();
|
||||
int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ());
|
||||
+ blockEntity.sanitizeSentNbt(compoundTag); // Paper - Sanitize sent data
|
||||
|
@ -34,9 +34,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class BlockEntity {
|
||||
return null;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start - Sanitize sent data
|
||||
+ public CompoundTag sanitizeSentNbt(CompoundTag tag) {
|
||||
+ tag.remove("PublicBukkitValues");
|
||||
|
@ -44,4 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return tag;
|
||||
+ }
|
||||
+ // Paper end - Sanitize sent data
|
||||
}
|
||||
+
|
||||
private static class ComponentHelper {
|
||||
|
||||
public static final Codec<DataComponentMap> COMPONENTS_CODEC = DataComponentMap.CODEC.optionalFieldOf("components", DataComponentMap.EMPTY).codec();
|
Loading…
Reference in a new issue