[ci skip] Add more patch identifying comments

This commit is contained in:
Nassim Jahnke 2024-01-13 18:34:33 +01:00
parent 2307466a54
commit 393db207da
20 changed files with 137 additions and 132 deletions

View file

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void readAdditionalSaveData(CompoundTag nbt) {} public void readAdditionalSaveData(CompoundTag nbt) {}
+ // Paper start - add hand parameter + // Paper start - Add hand parameter to PlayerFishEvent
+ @Deprecated + @Deprecated
+ @io.papermc.paper.annotation.DoNotUse + @io.papermc.paper.annotation.DoNotUse
public int retrieve(ItemStack usedItem) { public int retrieve(ItemStack usedItem) {
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ public int retrieve(net.minecraft.world.InteractionHand hand, ItemStack usedItem) { + public int retrieve(net.minecraft.world.InteractionHand hand, ItemStack usedItem) {
+ // Paper end + // Paper end - Add hand parameter to PlayerFishEvent
net.minecraft.world.entity.player.Player entityhuman = this.getPlayerOwner(); net.minecraft.world.entity.player.Player entityhuman = this.getPlayerOwner();
if (!this.level().isClientSide && entityhuman != null && !this.shouldStopFishing(entityhuman)) { if (!this.level().isClientSide && entityhuman != null && !this.shouldStopFishing(entityhuman)) {
@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.hookedIn != null) { if (this.hookedIn != null) {
// CraftBukkit start // CraftBukkit start
- PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.CAUGHT_ENTITY); // Paper - add hand + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.CAUGHT_ENTITY); // Paper - Add hand parameter to PlayerFishEvent
this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) { if (playerFishEvent.isCancelled()) {
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end // Paper end
// CraftBukkit start // CraftBukkit start
- PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem != null ? entityitem.getBukkitEntity() : null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); // Paper - entityitem may be null - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem != null ? entityitem.getBukkitEntity() : null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); // Paper - entityitem may be null
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem != null ? entityitem.getBukkitEntity() : null, (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.CAUGHT_FISH); // Paper - entityitem may be null // Paper - add hand + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem != null ? entityitem.getBukkitEntity() : null, (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.CAUGHT_FISH); // Paper - entityitem may be null // Paper - Add hand parameter to PlayerFishEvent
playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.onGround()) { if (this.onGround()) {
// CraftBukkit start // CraftBukkit start
- PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.IN_GROUND); // Paper - add hand + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.IN_GROUND); // Paper - Add hand parameter to PlayerFishEvent
this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) { if (playerFishEvent.isCancelled()) {
@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
if (i == 0) { if (i == 0) {
- PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN); - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.REEL_IN); // Paper - add hand + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.REEL_IN); // Paper - Add hand parameter to PlayerFishEvent
this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) { if (playerFishEvent.isCancelled()) {
return 0; return 0;
@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (user.fishing != null) { if (user.fishing != null) {
if (!world.isClientSide) { if (!world.isClientSide) {
- i = user.fishing.retrieve(itemstack); - i = user.fishing.retrieve(itemstack);
+ i = user.fishing.retrieve(hand, itemstack); // Paper - add hand parameter + i = user.fishing.retrieve(hand, itemstack); // Paper - Add hand parameter to PlayerFishEvent
itemstack.hurtAndBreak(i, user, (entityhuman1) -> { itemstack.hurtAndBreak(i, user, (entityhuman1) -> {
entityhuman1.broadcastBreakEvent(hand); entityhuman1.broadcastBreakEvent(hand);
}); });

View file

@ -34,11 +34,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public org.bukkit.inventory.InventoryHolder getOwner() { public org.bukkit.inventory.InventoryHolder getOwner() {
+ // Paper start + // Paper start - Add missing InventoryHolders
+ if (this.bukkitOwner == null && this.bukkitOwnerCreator != null) { + if (this.bukkitOwner == null && this.bukkitOwnerCreator != null) {
+ this.bukkitOwner = this.bukkitOwnerCreator.get(); + this.bukkitOwner = this.bukkitOwnerCreator.get();
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
return this.bukkitOwner; return this.bukkitOwner;
} }
@ -46,13 +46,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public SimpleContainer(int size) { public SimpleContainer(int size) {
this(size, null); this(size, null);
} }
+ // Paper start + // Paper start - Add missing InventoryHolders
+ private @Nullable java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> bukkitOwnerCreator; + private @Nullable java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> bukkitOwnerCreator;
+ public SimpleContainer(java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> bukkitOwnerCreator, int size) { + public SimpleContainer(java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> bukkitOwnerCreator, int size) {
+ this(size); + this(size);
+ this.bukkitOwnerCreator = bukkitOwnerCreator; + this.bukkitOwnerCreator = bukkitOwnerCreator;
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
public SimpleContainer(int i, org.bukkit.inventory.InventoryHolder owner) { public SimpleContainer(int i, org.bukkit.inventory.InventoryHolder owner) {
this.bukkitOwner = owner; this.bukkitOwner = owner;
@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.stateId; return this.stateId;
} }
+ +
+ // Paper start - add missing BlockInventoryHolder to inventories + // Paper start - Add missing InventoryHolders
+ // The reason this is a supplier, is that the createHolder method uses the bukkit InventoryView#getTopInventory to get the inventory in question + // The reason this is a supplier, is that the createHolder method uses the bukkit InventoryView#getTopInventory to get the inventory in question
+ // and that can't be obtained safely until the AbstractContainerMenu has been fully constructed. Using a supplier lazily + // and that can't be obtained safely until the AbstractContainerMenu has been fully constructed. Using a supplier lazily
+ // initializes the InventoryHolder safely. + // initializes the InventoryHolder safely.
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Preconditions.checkArgument(context != null, "context was null"); + Preconditions.checkArgument(context != null, "context was null");
+ return () -> context.createBlockHolder(this); + return () -> context.createBlockHolder(this);
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
} }
diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -85,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(MenuType.BEACON, syncId); super(MenuType.BEACON, syncId);
this.player = (Inventory) inventory; // CraftBukkit - TODO: check this this.player = (Inventory) inventory; // CraftBukkit - TODO: check this
- this.beacon = new SimpleContainer(1) { - this.beacon = new SimpleContainer(1) {
+ this.beacon = new SimpleContainer(this.createBlockHolder(context), 1) { // Paper + this.beacon = new SimpleContainer(this.createBlockHolder(context), 1) { // Paper - Add missing InventoryHolders
@Override @Override
public boolean canPlaceItem(int slot, ItemStack stack) { public boolean canPlaceItem(int slot, ItemStack stack) {
return stack.is(ItemTags.BEACON_PAYMENT_ITEMS); return stack.is(ItemTags.BEACON_PAYMENT_ITEMS);
@ -98,7 +98,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public CartographyTableMenu(int syncId, Inventory inventory, final ContainerLevelAccess context) { public CartographyTableMenu(int syncId, Inventory inventory, final ContainerLevelAccess context) {
super(MenuType.CARTOGRAPHY_TABLE, syncId); super(MenuType.CARTOGRAPHY_TABLE, syncId);
- this.container = new SimpleContainer(2) { - this.container = new SimpleContainer(2) {
+ this.container = new SimpleContainer(this.createBlockHolder(context), 2) { // Paper + this.container = new SimpleContainer(this.createBlockHolder(context), 2) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
CartographyTableMenu.this.slotsChanged(this); CartographyTableMenu.this.slotsChanged(this);
@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end // CraftBukkit end
}; };
- this.resultContainer = new ResultContainer() { - this.resultContainer = new ResultContainer() {
+ this.resultContainer = new ResultContainer(this.createBlockHolder(context)) { // Paper + this.resultContainer = new ResultContainer(this.createBlockHolder(context)) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
CartographyTableMenu.this.slotsChanged(this); CartographyTableMenu.this.slotsChanged(this);
@ -119,7 +119,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return new org.bukkit.Location(this.getWorld().getWorld(), this.getPosition().getX(), this.getPosition().getY(), this.getPosition().getZ()); return new org.bukkit.Location(this.getWorld().getWorld(), this.getPosition().getX(), this.getPosition().getY(), this.getPosition().getZ());
} }
// CraftBukkit end // CraftBukkit end
+ // Paper start + // Paper start - Add missing InventoryHolders
+ default boolean isBlock() { + default boolean isBlock() {
+ return false; + return false;
+ } + }
@ -130,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ return new org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder(this, menu.getBukkitView().getTopInventory()); + return new org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder(this, menu.getBukkitView().getTopInventory());
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
ContainerLevelAccess NULL = new ContainerLevelAccess() { ContainerLevelAccess NULL = new ContainerLevelAccess() {
@Override @Override
@ -138,12 +138,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return pos; return pos;
} }
// CraftBukkit end // CraftBukkit end
+ // Paper start + // Paper start - Add missing InventoryHolders
+ @Override + @Override
+ public boolean isBlock() { + public boolean isBlock() {
+ return true; + return true;
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
@Override @Override
public <T> Optional<T> evaluate(BiFunction<Level, BlockPos, T> getter) { public <T> Optional<T> evaluate(BiFunction<Level, BlockPos, T> getter) {
@ -156,7 +156,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public EnchantmentMenu(int syncId, Inventory playerInventory, ContainerLevelAccess context) { public EnchantmentMenu(int syncId, Inventory playerInventory, ContainerLevelAccess context) {
super(MenuType.ENCHANTMENT, syncId); super(MenuType.ENCHANTMENT, syncId);
- this.enchantSlots = new SimpleContainer(2) { - this.enchantSlots = new SimpleContainer(2) {
+ this.enchantSlots = new SimpleContainer(this.createBlockHolder(context), 2) { // Paper + this.enchantSlots = new SimpleContainer(this.createBlockHolder(context), 2) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
super.setChanged(); super.setChanged();
@ -170,8 +170,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(MenuType.GRINDSTONE, syncId); super(MenuType.GRINDSTONE, syncId);
- this.resultSlots = new ResultContainer(); - this.resultSlots = new ResultContainer();
- this.repairSlots = new SimpleContainer(2) { - this.repairSlots = new SimpleContainer(2) {
+ this.resultSlots = new ResultContainer(this.createBlockHolder(context)); // Paper + this.resultSlots = new ResultContainer(this.createBlockHolder(context)); // Paper - Add missing InventoryHolders
+ this.repairSlots = new SimpleContainer(this.createBlockHolder(context), 2) { // Paper + this.repairSlots = new SimpleContainer(this.createBlockHolder(context), 2) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
super.setChanged(); super.setChanged();
@ -184,7 +184,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected final Container inputSlots; protected final Container inputSlots;
private final List<Integer> inputSlotIndexes; private final List<Integer> inputSlotIndexes;
- protected final ResultContainer resultSlots = new ResultContainer(); - protected final ResultContainer resultSlots = new ResultContainer();
+ protected final ResultContainer resultSlots; // Paper - delay field init + protected final ResultContainer resultSlots; // Paper - Add missing InventoryHolders; delay field init
private final int resultSlotIndex; private final int resultSlotIndex;
protected abstract boolean mayPickup(Player player, boolean present); protected abstract boolean mayPickup(Player player, boolean present);
@ -192,7 +192,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public ItemCombinerMenu(@Nullable MenuType<?> type, int syncId, Inventory playerInventory, ContainerLevelAccess context) { public ItemCombinerMenu(@Nullable MenuType<?> type, int syncId, Inventory playerInventory, ContainerLevelAccess context) {
super(type, syncId); super(type, syncId);
this.access = context; this.access = context;
+ this.resultSlots = new ResultContainer(this.createBlockHolder(this.access)); // Paper - delay field init + this.resultSlots = new ResultContainer(this.createBlockHolder(this.access)); // Paper - Add missing InventoryHolders; delay field init
this.player = playerInventory.player; this.player = playerInventory.player;
ItemCombinerMenuSlotDefinition itemcombinermenuslotdefinition = this.createInputSlotDefinitions(); ItemCombinerMenuSlotDefinition itemcombinermenuslotdefinition = this.createInputSlotDefinitions();
@ -201,7 +201,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private SimpleContainer createContainer(int size) { private SimpleContainer createContainer(int size) {
- return new SimpleContainer(size) { - return new SimpleContainer(size) {
+ return new SimpleContainer(this.createBlockHolder(this.access), size) { // Paper + return new SimpleContainer(this.createBlockHolder(this.access), size) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
super.setChanged(); super.setChanged();
@ -214,7 +214,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.slotUpdateListener = () -> { this.slotUpdateListener = () -> {
}; };
- this.inputContainer = new SimpleContainer(3) { - this.inputContainer = new SimpleContainer(3) {
+ this.inputContainer = new SimpleContainer(this.createBlockHolder(context), 3) { // Paper + this.inputContainer = new SimpleContainer(this.createBlockHolder(context), 3) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
super.setChanged(); super.setChanged();
@ -223,7 +223,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end // CraftBukkit end
}; };
- this.outputContainer = new SimpleContainer(1) { - this.outputContainer = new SimpleContainer(1) {
+ this.outputContainer = new SimpleContainer(this.createBlockHolder(context), 1) { // Paper + this.outputContainer = new SimpleContainer(this.createBlockHolder(context), 1) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
super.setChanged(); super.setChanged();
@ -236,12 +236,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public org.bukkit.inventory.InventoryHolder getOwner() { public org.bukkit.inventory.InventoryHolder getOwner() {
- return null; // Result slots don't get an owner - return null; // Result slots don't get an owner
+ // Paper start + // Paper start - Add missing InventoryHolders
+ if (this.holder == null && this.holderCreator != null) { + if (this.holder == null && this.holderCreator != null) {
+ this.holder = this.holderCreator.get(); + this.holder = this.holderCreator.get();
+ } + }
+ return this.holder; // Result slots don't get an owner + return this.holder; // Result slots don't get an owner
+ // Paper end - yes they do + // Paper end - Add missing InventoryHolders
} }
// Don't need a transaction; the InventoryCrafting keeps track of it for us // Don't need a transaction; the InventoryCrafting keeps track of it for us
@ -249,14 +249,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return null; return null;
} }
// CraftBukkit end // CraftBukkit end
+ // Paper start + // Paper start - Add missing InventoryHolders
+ private @Nullable java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> holderCreator; + private @Nullable java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> holderCreator;
+ private @Nullable org.bukkit.inventory.InventoryHolder holder; + private @Nullable org.bukkit.inventory.InventoryHolder holder;
+ public ResultContainer(java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> holderCreator) { + public ResultContainer(java.util.function.Supplier<? extends org.bukkit.inventory.InventoryHolder> holderCreator) {
+ this(); + this();
+ this.holderCreator = holderCreator; + this.holderCreator = holderCreator;
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
public ResultContainer() { public ResultContainer() {
this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); this.itemStacks = NonNullList.withSize(1, ItemStack.EMPTY);
@ -269,7 +269,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.slotUpdateListener = () -> { this.slotUpdateListener = () -> {
}; };
- this.container = new SimpleContainer(1) { - this.container = new SimpleContainer(1) {
+ this.container = new SimpleContainer(this.createBlockHolder(context), 1) { // Paper + this.container = new SimpleContainer(this.createBlockHolder(context), 1) { // Paper - Add missing InventoryHolders
@Override @Override
public void setChanged() { public void setChanged() {
super.setChanged(); super.setChanged();
@ -278,7 +278,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end // CraftBukkit end
}; };
- this.resultContainer = new ResultContainer(); - this.resultContainer = new ResultContainer();
+ this.resultContainer = new ResultContainer(this.createBlockHolder(context)); // Paper + this.resultContainer = new ResultContainer(this.createBlockHolder(context)); // Paper - Add missing InventoryHolders
this.access = context; this.access = context;
this.level = playerInventory.player.level(); this.level = playerInventory.player.level();
this.inputSlot = this.addSlot(new Slot(this.container, 0, 20, 33)); this.inputSlot = this.addSlot(new Slot(this.container, 0, 20, 33));
@ -290,13 +290,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.block = CraftBlock.at(world, pos); this.block = CraftBlock.at(world, pos);
this.inventory = new CraftInventory(inv); this.inventory = new CraftInventory(inv);
} }
+ // Paper start + // Paper start - Add missing InventoryHolders
+ public CraftBlockInventoryHolder(net.minecraft.world.inventory.ContainerLevelAccess levelAccess, Inventory inventory) { + public CraftBlockInventoryHolder(net.minecraft.world.inventory.ContainerLevelAccess levelAccess, Inventory inventory) {
+ com.google.common.base.Preconditions.checkArgument(levelAccess.isBlock()); + com.google.common.base.Preconditions.checkArgument(levelAccess.isBlock());
+ this.block = CraftBlock.at(levelAccess.getWorld(), levelAccess.getPosition()); + this.block = CraftBlock.at(levelAccess.getWorld(), levelAccess.getPosition());
+ this.inventory = inventory; + this.inventory = inventory;
+ } + }
+ // Paper end + // Paper end - Add missing InventoryHolders
@Override @Override
public Block getBlock() { public Block getBlock() {

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (i == 0) { if (i == 0) {
- LegacyQueryHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress); - LegacyQueryHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress);
+ LegacyQueryHandler.LOGGER.debug("Ping: (<1.3.x) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? socketaddress: "<ip address withheld>"); // Paper + LegacyQueryHandler.LOGGER.debug("Ping: (<1.3.x) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? socketaddress: "<ip address withheld>"); // Paper - Respect logIPs option
// Paper start - Call PaperServerListPingEvent and use results // Paper start - Call PaperServerListPingEvent and use results
event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest(net.minecraft.server.MinecraftServer.getServer(), (java.net.InetSocketAddress) socketaddress, 39, null); event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest(net.minecraft.server.MinecraftServer.getServer(), (java.net.InetSocketAddress) socketaddress, 39, null);
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end // Paper end
} else { } else {
- LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress); - LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress);
+ LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? socketaddress: "<ip address withheld>"); // Paper + LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? socketaddress: "<ip address withheld>"); // Paper - Respect logIPs option
} }
if (s == null) { if (s == null) {
@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.buf = null; this.buf = null;
- LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress()); - LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress());
+ LOGGER.debug("Ping: (1.6) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? ctx.channel().remoteAddress(): "<ip address withheld>"); // Paper + LOGGER.debug("Ping: (1.6) from {}", net.minecraft.server.MinecraftServer.getServer().logIPs() ? ctx.channel().remoteAddress(): "<ip address withheld>"); // Paper - Respect logIPs option
java.net.InetSocketAddress virtualHost = com.destroystokyo.paper.network.PaperNetworkClient.prepareVirtualHost(host, port); java.net.InetSocketAddress virtualHost = com.destroystokyo.paper.network.PaperNetworkClient.prepareVirtualHost(host, port);
com.destroystokyo.paper.event.server.PaperServerListPingEvent event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest( com.destroystokyo.paper.event.server.PaperServerListPingEvent event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest(

View file

@ -12,12 +12,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
+ // Paper start + // Paper start - Add predicate for blocks when raytracing
+ return clip(raytrace1, blockposition, null); + return clip(raytrace1, blockposition, null);
+ } + }
+ +
+ default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition, java.util.function.Predicate<? super org.bukkit.block.Block> canCollide) { + default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition, java.util.function.Predicate<? super org.bukkit.block.Block> canCollide) {
+ // Paper end + // Paper end - Add predicate for blocks when raytracing
// Paper start - Prevent raytrace from loading chunks // Paper start - Prevent raytrace from loading chunks
BlockState iblockdata = this.getBlockStateIfLoaded(blockposition); BlockState iblockdata = this.getBlockStateIfLoaded(blockposition);
if (iblockdata == null) { if (iblockdata == null) {
@ -34,15 +34,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end // CraftBukkit end
default BlockHitResult clip(ClipContext context) { default BlockHitResult clip(ClipContext context) {
+ // Paper start + // Paper start - Add predicate for blocks when raytracing
+ return clip(context, (java.util.function.Predicate<org.bukkit.block.Block>) null); + return clip(context, (java.util.function.Predicate<org.bukkit.block.Block>) null);
+ } + }
+ +
+ default BlockHitResult clip(ClipContext context, java.util.function.Predicate<? super org.bukkit.block.Block> canCollide) { + default BlockHitResult clip(ClipContext context, java.util.function.Predicate<? super org.bukkit.block.Block> canCollide) {
+ // Paper end + // Paper end - Add predicate for blocks when raytracing
return (BlockHitResult) BlockGetter.traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> { return (BlockHitResult) BlockGetter.traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> {
- return this.clip(raytrace1, blockposition); // CraftBukkit - moved into separate method - return this.clip(raytrace1, blockposition); // CraftBukkit - moved into separate method
+ return this.clip(raytrace1, blockposition, canCollide); // CraftBukkit - moved into separate method // Paper - use method with canCollide predicate + return this.clip(raytrace1, blockposition, canCollide); // CraftBukkit - moved into separate method // Paper - Add predicate for blocks when raytracing
}, (raytrace1) -> { }, (raytrace1) -> {
Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());
@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<? super Entity> filter) { public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<? super Entity> filter) {
+ // Paper start + // Paper start - Add predicate for blocks when raytracing
+ return rayTraceEntities((io.papermc.paper.math.Position) start, direction, maxDistance, raySize, filter); + return rayTraceEntities((io.papermc.paper.math.Position) start, direction, maxDistance, raySize, filter);
+ } + }
+ +
@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- start.checkFinite(); - start.checkFinite();
+ Preconditions.checkArgument(!(start instanceof Location location) || this.equals(location.getWorld()), "Location start cannot be in a different world"); + Preconditions.checkArgument(!(start instanceof Location location) || this.equals(location.getWorld()), "Location start cannot be in a different world");
+ Preconditions.checkArgument(start.isFinite(), "Location start is not finite"); + Preconditions.checkArgument(start.isFinite(), "Location start is not finite");
+ // Paper end + // Paper end - Add predicate for blocks when raytracing
Preconditions.checkArgument(direction != null, "Vector direction cannot be null"); Preconditions.checkArgument(direction != null, "Vector direction cannot be null");
direction.checkFinite(); direction.checkFinite();
@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) {
+ // Paper start + // Paper start - Add predicate for blocks when raytracing
+ return this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks, null); + return this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks, null);
+ } + }
+ +
@ -83,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- start.checkFinite(); - start.checkFinite();
+ Preconditions.checkArgument(!(start instanceof Location location) || this.equals(location.getWorld()), "Location start cannot be in a different world"); + Preconditions.checkArgument(!(start instanceof Location location) || this.equals(location.getWorld()), "Location start cannot be in a different world");
+ Preconditions.checkArgument(start.isFinite(), "Location start is not finite"); + Preconditions.checkArgument(start.isFinite(), "Location start is not finite");
+ // Paper end + // Paper end - Add predicate for blocks when raytracing
Preconditions.checkArgument(direction != null, "Vector direction cannot be null"); Preconditions.checkArgument(direction != null, "Vector direction cannot be null");
direction.checkFinite(); direction.checkFinite();
@ -92,10 +92,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Vector dir = direction.clone().normalize().multiply(maxDistance); Vector dir = direction.clone().normalize().multiply(maxDistance);
- Vec3 startPos = CraftLocation.toVec3D(start); - Vec3 startPos = CraftLocation.toVec3D(start);
+ Vec3 startPos = io.papermc.paper.util.MCUtil.toVec3(start); // Paper + Vec3 startPos = io.papermc.paper.util.MCUtil.toVec3(start); // Paper - Add predicate for blocks when raytracing
Vec3 endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ()); Vec3 endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ());
- HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty())); - HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()));
+ HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()), canCollide); // Paper - use method with canCollide predicate + HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()), canCollide); // Paper - Add predicate for blocks when raytracing
return CraftRayTraceResult.fromNMS(this, nmsHitResult); return CraftRayTraceResult.fromNMS(this, nmsHitResult);
} }
@ -103,14 +103,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<? super Entity> filter) { public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<? super Entity> filter) {
- RayTraceResult blockHit = this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks); - RayTraceResult blockHit = this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks);
+ // Paper start + // Paper start - Add predicate for blocks when raytracing
+ return this.rayTrace(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks, raySize, filter, null); + return this.rayTrace(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks, raySize, filter, null);
+ } + }
+ +
+ @Override + @Override
+ public RayTraceResult rayTrace(io.papermc.paper.math.Position start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<? super Entity> filter, Predicate<? super Block> canCollide) { + public RayTraceResult rayTrace(io.papermc.paper.math.Position start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<? super Entity> filter, Predicate<? super Block> canCollide) {
+ RayTraceResult blockHit = this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks, canCollide); + RayTraceResult blockHit = this.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode, ignorePassableBlocks, canCollide);
+ // Paper end + // Paper end - Add predicate for blocks when raytracing
Vector startVec = null; Vector startVec = null;
double blockHitDistance = maxDistance; double blockHitDistance = maxDistance;

View file

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public boolean isEmpty() { + public boolean isEmpty() {
+ return handle == null || handle.isEmpty(); + return handle == null || handle.isEmpty();
+ } + }
+ // Paper end + // Paper end - override isEmpty to use vanilla's impl
+ +
public static net.minecraft.world.item.ItemStack asNMSCopy(ItemStack original) { public static net.minecraft.world.item.ItemStack asNMSCopy(ItemStack original) {
if (original instanceof CraftItemStack) { if (original instanceof CraftItemStack) {
@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return stack.handle == null ? net.minecraft.world.item.ItemStack.EMPTY : stack.handle.copy(); return stack.handle == null ? net.minecraft.world.item.ItemStack.EMPTY : stack.handle.copy();
} }
- if (original == null || original.getType() == Material.AIR) { - if (original == null || original.getType() == Material.AIR) {
+ if (original == null || original.isEmpty()) { // Paper - use isEmpty + if (original == null || original.isEmpty()) { // Paper - override isEmpty to use vanilla's impl; use isEmpty
return net.minecraft.world.item.ItemStack.EMPTY; return net.minecraft.world.item.ItemStack.EMPTY;
} }

View file

@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot
+ entity.generation = false; // Reset flag if it was added during a ServerLevel generation process + entity.generation = false; // Paper - Don't fire sync event during generation; Reset flag if it was added during a ServerLevel generation process
// Paper start // Paper start
if (entity.valid) { if (entity.valid) {
MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable());
@ -39,11 +39,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return; return;
} }
- this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[pose.ordinal()])); - this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[pose.ordinal()]));
+ // Paper start - don't fire event during generation + // Paper start - Don't fire sync event during generation
+ if (!this.generation) { + if (!this.generation) {
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[pose.ordinal()])); + this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[pose.ordinal()]));
+ } + }
+ // Paper end - don't fire event during generation + // Paper end - Don't fire sync event during generation
// CraftBukkit end // CraftBukkit end
this.entityData.set(Entity.DATA_POSE, pose); this.entityData.set(Entity.DATA_POSE, pose);
} }
@ -55,15 +55,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public static Optional<Entity> create(CompoundTag nbt, Level world) { public static Optional<Entity> create(CompoundTag nbt, Level world) {
+ // Paper start - add generation bool param + // Paper start - Don't fire sync event during generation
+ return create(nbt, world, false); + return create(nbt, world, false);
+ } + }
+ public static Optional<Entity> create(CompoundTag nbt, Level world, boolean generation) { + public static Optional<Entity> create(CompoundTag nbt, Level world, boolean generation) {
+ // Paper end - add generation bool param + // Paper end - Don't fire sync event during generation
return Util.ifElse(EntityType.by(nbt).map((entitytypes) -> { return Util.ifElse(EntityType.by(nbt).map((entitytypes) -> {
return entitytypes.create(world); return entitytypes.create(world);
}), (entity) -> { }), (entity) -> {
+ if (generation) entity.generation = true; // Paper - add generation bool param + if (generation) entity.generation = true; // Paper - Don't fire sync event during generation
entity.load(nbt); entity.load(nbt);
}, () -> { }, () -> {
EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
@ -75,11 +75,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) { public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) {
+ // Paper start - add boolean param to optionally fire the event + // Paper start - Don't fire sync event during generation
+ return this.addEffect(mobeffect, entity, cause, true); + return this.addEffect(mobeffect, entity, cause, true);
+ } + }
+ public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) { + public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) {
+ // Paper end + // Paper end - Don't fire sync event during generation
// org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API
if (this.isTickingEffects) { if (this.isTickingEffects) {
this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
@ -87,13 +87,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
override = new MobEffectInstance(mobeffect1).update(mobeffect); override = new MobEffectInstance(mobeffect1).update(mobeffect);
} }
+ if (fireEvent) { // Paper + if (fireEvent) { // Paper - Don't fire sync event during generation
EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override); EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override);
+ override = event.isOverride(); // Paper + override = event.isOverride(); // Paper - Don't fire sync event during generation
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
} }
+ } // Paper + } // Paper - Don't fire sync event during generation
// CraftBukkit end // CraftBukkit end
if (mobeffect1 == null) { if (mobeffect1 == null) {
@ -102,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
flag = true; flag = true;
// CraftBukkit start // CraftBukkit start
- } else if (event.isOverride()) { - } else if (event.isOverride()) {
+ } else if (override) { // Paper + } else if (override) { // Paper - Don't fire sync event during generation
mobeffect1.update(mobeffect); mobeffect1.update(mobeffect);
this.onEffectUpdated(mobeffect1, true, entity); this.onEffectUpdated(mobeffect1, true, entity);
// CraftBukkit end // CraftBukkit end
@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (mobeffectlist != null) { if (mobeffectlist != null) {
- this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit - this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
+ this.addEffect(new MobEffectInstance(mobeffectlist, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit // Paper - only fire the effect event if this is happening in a ServerLevel + this.addEffect(new MobEffectInstance(mobeffectlist, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit // Paper - Don't fire sync event during generation; only if this is happening in a ServerLevel
} }
} }
@ -128,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
// try { // try {
- return EntityType.create(nbt, world.getLevel()); - return EntityType.create(nbt, world.getLevel());
+ return EntityType.create(nbt, world.getLevel(), true); // Paper - set generation bool + return EntityType.create(nbt, world.getLevel(), true); // Paper - Don't fire sync event during generation
// } catch (Exception exception) { // } catch (Exception exception) {
// return Optional.empty(); // return Optional.empty();
// } // }
@ -149,7 +149,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public void addFreshEntityWithPassengers(Entity entity) { - public void addFreshEntityWithPassengers(Entity entity) {
- this.handle.addFreshEntityWithPassengers(entity); - this.handle.addFreshEntityWithPassengers(entity);
- } - }
+ // Paper start - don't override these methods so all entities are run through addFreshEntity + // Paper start - Don't fire sync event during generation; don't override these methods so all entities are run through addFreshEntity
+ // @Override + // @Override
+ // public void addFreshEntityWithPassengers(Entity arg0, CreatureSpawnEvent.SpawnReason arg1) { + // public void addFreshEntityWithPassengers(Entity arg0, CreatureSpawnEvent.SpawnReason arg1) {
+ // this.handle.addFreshEntityWithPassengers(arg0, arg1); + // this.handle.addFreshEntityWithPassengers(arg0, arg1);
@ -159,7 +159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // public void addFreshEntityWithPassengers(Entity entity) { + // public void addFreshEntityWithPassengers(Entity entity) {
+ // this.handle.addFreshEntityWithPassengers(entity); + // this.handle.addFreshEntityWithPassengers(entity);
+ // } + // }
+ // Paper end - don't override these methods + // Paper end - Don't fire sync event during generation; don't override these methods
@Override @Override
public ServerLevel getMinecraftWorld() { public ServerLevel getMinecraftWorld() {
@ -186,7 +186,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- super.addFreshEntityWithPassengers(arg0, arg1); - super.addFreshEntityWithPassengers(arg0, arg1);
- } - }
+ // Paper start - don't override these methods so all entities are run through addFreshEntity + // Paper start - Don't fire sync event during generation; don't override these methods so all entities are run through addFreshEntity
+ // @Override + // @Override
+ // public void addFreshEntityWithPassengers(Entity entity) { + // public void addFreshEntityWithPassengers(Entity entity) {
+ // if (this.structureTransformer != null && !this.structureTransformer.transformEntity(entity)) { + // if (this.structureTransformer != null && !this.structureTransformer.transformEntity(entity)) {
@ -202,7 +202,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // } + // }
+ // super.addFreshEntityWithPassengers(arg0, arg1); + // super.addFreshEntityWithPassengers(arg0, arg1);
+ // } + // }
+ // Paper end - don't override these methods + // Paper end - Don't fire sync event during generation; don't override these methods
public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, int i, int j) { public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, int i, int j) {
if (this.structureTransformer != null) { if (this.structureTransformer != null) {

View file

@ -15,13 +15,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.catalystListener.level = this.level; // CraftBukkit - this.catalystListener.level = this.level; // CraftBukkit
} }
+ // Paper start + // Paper start - Fix NPE in SculkBloomEvent world access
+ @Override + @Override
+ public void setLevel(Level level) { + public void setLevel(Level level) {
+ super.setLevel(level); + super.setLevel(level);
+ this.catalystListener.sculkSpreader.level = level; + this.catalystListener.sculkSpreader.level = level;
+ } + }
+ // Paper end + // Paper end - Fix NPE in SculkBloomEvent world access
+ +
public static void serverTick(Level world, BlockPos pos, BlockState state, SculkCatalystBlockEntity blockEntity) { public static void serverTick(Level world, BlockPos pos, BlockState state, SculkCatalystBlockEntity blockEntity) {
org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = blockEntity.getBlockPos(); // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep. org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = blockEntity.getBlockPos(); // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep.
@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.positionSource = positionSource; this.positionSource = positionSource;
this.sculkSpreader = SculkSpreader.createLevelSpreader(); this.sculkSpreader = SculkSpreader.createLevelSpreader();
- this.sculkSpreader.level = this.level; // CraftBukkit - this.sculkSpreader.level = this.level; // CraftBukkit
+ // this.sculkSpreader.level = this.level; // CraftBukkit // Paper - bad fix + // this.sculkSpreader.level = this.level; // CraftBukkit // Paper - Fix NPE in SculkBloomEvent world access
} }
@Override @Override

View file

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id); - MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id);
- if (worldmap != null) { - if (worldmap != null) {
- worldmap.id = id; - worldmap.id = id;
+ // Paper start - Call missing map initialize event & set id + // Paper start - Call missing map initialize event and set id
+ final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage();
+ +
+ final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id); + final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id);
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- // CraftBukkit end - // CraftBukkit end
+ +
+ return existing instanceof MapItemSavedData data ? data : null; + return existing instanceof MapItemSavedData data ? data : null;
+ // Paper end + // Paper end - Call missing map initialize event and set id
} }
@Override @Override

View file

@ -18,10 +18,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
int i = this.getAge(); int i = this.getAge();
if (!this.level().isClientSide && i == 0 && this.canFallInLove()) { if (!this.level().isClientSide && i == 0 && this.canFallInLove()) {
+ final ItemStack breedCopy = itemstack.copy(); // Paper + final ItemStack breedCopy = itemstack.copy(); // Paper - Fix EntityBreedEvent copying
this.usePlayerItem(player, hand, itemstack); this.usePlayerItem(player, hand, itemstack);
- this.setInLove(player); - this.setInLove(player);
+ this.setInLove(player, breedCopy); // Paper + this.setInLove(player, breedCopy); // Paper - Fix EntityBreedEvent copying
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
@ -29,18 +29,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.inLove <= 0; return this.inLove <= 0;
} }
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper + @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Fix EntityBreedEvent copying
public void setInLove(@Nullable Player player) { public void setInLove(@Nullable Player player) {
+ // Paper start - pass breed stack + // Paper start - Fix EntityBreedEvent copying
+ this.setInLove(player, null); + this.setInLove(player, null);
+ } + }
+ public void setInLove(@Nullable Player player, @Nullable ItemStack breedItemCopy) { + public void setInLove(@Nullable Player player, @Nullable ItemStack breedItemCopy) {
+ if (breedItemCopy != null) this.breedItem = breedItemCopy; + if (breedItemCopy != null) this.breedItem = breedItemCopy;
+ // Paper end + // Paper end - Fix EntityBreedEvent copying
// CraftBukkit start // CraftBukkit start
EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(player, this, 600); EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(player, this, 600);
if (entityEnterLoveModeEvent.isCancelled()) { if (entityEnterLoveModeEvent.isCancelled()) {
+ this.breedItem = null; // Paper - clear if cancelled + this.breedItem = null; // Paper - Fix EntityBreedEvent copying; clear if cancelled
return; return;
} }
this.inLove = entityEnterLoveModeEvent.getTicksInLove(); this.inLove = entityEnterLoveModeEvent.getTicksInLove();
@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.loveCause = player.getUUID(); this.loveCause = player.getUUID();
} }
- this.breedItem = player.getInventory().getSelected(); // CraftBukkit - this.breedItem = player.getInventory().getSelected(); // CraftBukkit
+ // Paper - set breed item in better place + // Paper - Fix EntityBreedEvent copying; set breed item in better place
this.level().broadcastEntityEvent(this, (byte) 18); this.level().broadcastEntityEvent(this, (byte) 18);
} }
@ -61,10 +61,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.usePlayerItem(player, hand, itemstack); this.usePlayerItem(player, hand, itemstack);
this.ageUp((int) ((float) (-this.getAge() / 20) * 0.1F), true); this.ageUp((int) ((float) (-this.getAge() / 20) * 0.1F), true);
} else if (!this.level().isClientSide && this.getAge() == 0 && this.canFallInLove()) { } else if (!this.level().isClientSide && this.getAge() == 0 && this.canFallInLove()) {
+ final ItemStack breedCopy = itemstack.copy(); // Paper + final ItemStack breedCopy = itemstack.copy(); // Paper - Fix EntityBreedEvent copying
this.usePlayerItem(player, hand, itemstack); this.usePlayerItem(player, hand, itemstack);
- this.setInLove(player); - this.setInLove(player);
+ this.setInLove(player, breedCopy); // Paper + this.setInLove(player, breedCopy); // Paper - Fix EntityBreedEvent copying
} else { } else {
if (this.level().isClientSide || this.isSitting() || this.isInWater()) { if (this.level().isClientSide || this.isSitting() || this.isInWater()) {
return InteractionResult.PASS; return InteractionResult.PASS;
@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
boolean bl2 = this.isTamed() && this.getAge() == 0 && this.canFallInLove(); boolean bl2 = this.isTamed() && this.getAge() == 0 && this.canFallInLove();
if (bl2) { if (bl2) {
- this.setInLove(player); - this.setInLove(player);
+ this.setInLove(player, item.copy()); // Paper + this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
} }
boolean bl3 = this.isBaby(); boolean bl3 = this.isBaby();
@ -90,7 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
flag = true; flag = true;
- this.setInLove(player); - this.setInLove(player);
+ this.setInLove(player, item.copy()); // Paper + this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
} }
} else if (item.is(Items.GOLDEN_APPLE) || item.is(Items.ENCHANTED_GOLDEN_APPLE)) { } else if (item.is(Items.GOLDEN_APPLE) || item.is(Items.ENCHANTED_GOLDEN_APPLE)) {
f = 10.0F; f = 10.0F;
@ -99,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
flag = true; flag = true;
- this.setInLove(player); - this.setInLove(player);
+ this.setInLove(player, item.copy()); // Paper + this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
} }
} }
@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) { if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) {
flag = true; flag = true;
- this.setInLove(player); - this.setInLove(player);
+ this.setInLove(player, item.copy()); // Paper + this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
} }
} }

View file

@ -12,22 +12,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void setItemSlot(EquipmentSlot slot, ItemStack stack) { public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
+ // Paper start + // Paper start - Fix silent equipment change
+ setItemSlot(slot, stack, false); + setItemSlot(slot, stack, false);
+ } + }
+ +
+ @Override + @Override
+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { + public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) {
+ // Paper end + // Paper end - Fix silent equipment change
this.verifyEquippedItem(stack); this.verifyEquippedItem(stack);
switch (slot.getType()) { switch (slot.getType()) {
case HAND: case HAND:
- this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack); - this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack);
+ this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack, silent); // Paper + this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change
break; break;
case ARMOR: case ARMOR:
- this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack); - this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack);
+ this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack, silent); // Paper + this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change
} }
} }
@ -41,8 +41,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
- public void setItemSlot(EquipmentSlot slot, ItemStack stack) { - public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
- super.setItemSlot(slot, stack); - super.setItemSlot(slot, stack);
+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { // Paper + public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { // Paper - Fix silent equipment change
+ super.setItemSlot(slot, stack, silent); // Paper + super.setItemSlot(slot, stack, silent); // Paper - Fix silent equipment change
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
this.reassessWeaponGoal(); this.reassessWeaponGoal();
} }
@ -58,7 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) + // notify observers if the block state is the same and the Y level equals the original y level (for mega trees)
+ // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the + // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the
+ // tree grew or not + // tree grew or not
+ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { + if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // Paper - Fix silent equipment change
this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512);
} }
} }

View file

@ -29,13 +29,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
+ // Spigot start // Paper start - moved after stat fetching for player state file. + // Paper start - Moved after stat fetching for player state file
+ // Moves the loading after vanilla loading, so it overrides the values.
+ // Disables saving any forced stats, so it stays at the same value (without enabling disableStatSaving)
+ // Fixes stat initialization to not cause a NullPointerException
+ // Spigot start
+ for ( Map.Entry<ResourceLocation, Integer> entry : org.spigotmc.SpigotConfig.forcedStats.entrySet() ) + for ( Map.Entry<ResourceLocation, Integer> entry : org.spigotmc.SpigotConfig.forcedStats.entrySet() )
+ { + {
+ Stat<ResourceLocation> wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.get(entry.getKey()))); // Paper - ensured by SpigotConfig#stats + Stat<ResourceLocation> wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.get(entry.getKey()))); // Paper - ensured by SpigotConfig#stats
+ this.stats.put( wrapper, entry.getValue().intValue() ); + this.stats.put( wrapper, entry.getValue().intValue() );
+ } + }
+ // Spigot end // Paper end - moved after stat fetching for player state file. + // Spigot end
+ // Paper end - Moved after stat fetching for player state file
} }
public void save() { public void save() {

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private final Set<Entity> hitEntities = Sets.newHashSet(); private final Set<Entity> hitEntities = Sets.newHashSet();
private int blocksSetOnFire; private int blocksSetOnFire;
- public boolean isSilent = false; // Spigot - public boolean isSilent = false; // Spigot
+ public boolean isEffect; // Paper + public boolean isEffect; // Paper - Properly handle lightning effects api
public LightningBolt(EntityType<? extends LightningBolt> type, Level world) { public LightningBolt(EntityType<? extends LightningBolt> type, Level world) {
super(type, world); super(type, world);
@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void tick() { public void tick() {
super.tick(); super.tick();
- if (!this.isSilent && this.life == 2) { // Spigot - if (!this.isSilent && this.life == 2) { // Spigot
+ if (!this.isEffect && this.life == 2) { // Spigot // Paper + if (!this.isEffect && this.life == 2) { // Spigot // Paper - Properly handle lightning effects api
if (this.level().isClientSide()) { if (this.level().isClientSide()) {
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F, false); this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F, false);
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F, false); this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F, false);
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly - if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly
+ if (this.life >= 0 && !this.isEffect) { // CraftBukkit - add !this.visualOnly // Paper - undo + if (this.life >= 0 && !this.isEffect) { // CraftBukkit - add !this.visualOnly // Paper - Properly handle lightning effects api
if (!(this.level() instanceof ServerLevel)) { if (!(this.level() instanceof ServerLevel)) {
this.level().setSkyFlashTime(2); this.level().setSkyFlashTime(2);
} else if (!this.visualOnly) { } else if (!this.visualOnly) {
@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private void spawnFire(int spreadAttempts) { private void spawnFire(int spreadAttempts) {
- if (!this.visualOnly && !this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { - if (!this.visualOnly && !this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
+ if (!this.visualOnly && !this.isEffect && !this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { // Paper + if (!this.visualOnly && !this.isEffect && !this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { // Paper - Properly handle lightning effects api
BlockPos blockposition = this.blockPosition(); BlockPos blockposition = this.blockPosition();
BlockState iblockdata = BaseFireBlock.getState(this.level(), blockposition); BlockState iblockdata = BaseFireBlock.getState(this.level(), blockposition);
@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
LightningBolt lightning = EntityType.LIGHTNING_BOLT.create(this.world); LightningBolt lightning = EntityType.LIGHTNING_BOLT.create(this.world);
lightning.moveTo(loc.getX(), loc.getY(), loc.getZ()); lightning.moveTo(loc.getX(), loc.getY(), loc.getZ());
- lightning.setVisualOnly(isVisual); - lightning.setVisualOnly(isVisual);
+ lightning.isEffect = isVisual; // Paper + lightning.isEffect = isVisual; // Paper - Properly handle lightning effects api
this.world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); this.world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM);
return (LightningStrike) lightning.getBukkitEntity(); return (LightningStrike) lightning.getBukkitEntity();
} }
@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() ); lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() );
- lightning.visualOnly = true; - lightning.visualOnly = true;
- lightning.isSilent = isSilent; - lightning.isSilent = isSilent;
+ lightning.isEffect = true; // Paper + lightning.isEffect = true; // Paper - Properly handle lightning effects api
CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM ); CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM );
return (LightningStrike) lightning.getBukkitEntity(); return (LightningStrike) lightning.getBukkitEntity();
} }
@ -85,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public boolean isEffect() { public boolean isEffect() {
- return this.getHandle().visualOnly; - return this.getHandle().visualOnly;
+ return this.getHandle().isEffect; // Paper + return this.getHandle().isEffect; // Paper - Properly handle lightning effects api
} }
public int getFlashes() { public int getFlashes() {
@ -94,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public boolean isSilent() public boolean isSilent()
{ {
- return CraftLightningStrike.this.getHandle().isSilent; - return CraftLightningStrike.this.getHandle().isSilent;
+ return false; // Paper - the concept of isSilent doesn't exist as sound is controlled by the client + return false; // Paper - Properly handle lightning effects api; the concept of isSilent doesn't exist as sound is controlled by the client
} }
}; };

View file

@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ boolean shouldLagCompensate = this.useItem.getItem().isEdible() && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000)); + boolean shouldLagCompensate = this.useItem.getItem().isEdible() && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000));
+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) { + if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) {
+ this.useItemRemaining = 0; + this.useItemRemaining = 0;
+ // Paper end + // Paper end - lag compensate eating
this.completeUsingItem(); this.completeUsingItem();
} }
@ -101,7 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - lag compensate eating + // Paper start - lag compensate eating
+ this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration(); + this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration();
+ this.eatStartTime = System.nanoTime(); + this.eatStartTime = System.nanoTime();
+ // Paper end + // Paper end - lag compensate eating
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(1, true);
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND); this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
@ -113,7 +113,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - lag compensate eating + // Paper start - lag compensate eating
+ this.useItemRemaining = this.totalEatTimeTicks = 0; + this.useItemRemaining = this.totalEatTimeTicks = 0;
+ this.eatStartTime = -1L; + this.eatStartTime = -1L;
+ // Paper end + // Paper end - lag compensate eating
} }
} }
@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - lag compensate eating + // Paper start - lag compensate eating
+ this.useItemRemaining = this.totalEatTimeTicks = 0; + this.useItemRemaining = this.totalEatTimeTicks = 0;
+ this.eatStartTime = -1L; + this.eatStartTime = -1L;
+ // Paper end + // Paper end - lag compensate eating
} }
public boolean isBlocking() { public boolean isBlocking() {

View file

@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.getHandle().zPower = velocity.getZ(); + this.getHandle().zPower = velocity.getZ();
+ update(); + update();
+ } + }
+ // Paper end + // Paper end - set direction without normalizing
+ +
@Override @Override
public AbstractHurtingProjectile getHandle() { public AbstractHurtingProjectile getHandle() {

View file

@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
players[NearbyMapType.GENERAL_REALLY_SMALL.ordinal()].update(chunk.x, chunk.z, GENERAL_REALLY_SMALL_VIEW_DISTANCE); players[NearbyMapType.GENERAL_REALLY_SMALL.ordinal()].update(chunk.x, chunk.z, GENERAL_REALLY_SMALL_VIEW_DISTANCE);
players[NearbyMapType.TICK_VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, ChunkSystem.getTickViewDistance(player)); players[NearbyMapType.TICK_VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, ChunkSystem.getTickViewDistance(player));
players[NearbyMapType.VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, ChunkSystem.getLoadViewDistance(player)); players[NearbyMapType.VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, ChunkSystem.getLoadViewDistance(player));
+ players[NearbyMapType.SPAWN_RANGE.ordinal()].update(chunk.x, chunk.z, SPAWN_RANGE_VIEW_DISTANCE); + players[NearbyMapType.SPAWN_RANGE.ordinal()].update(chunk.x, chunk.z, SPAWN_RANGE_VIEW_DISTANCE); // Paper - optimise chunk iteration
} }
public TrackedChunk getChunk(final ChunkPos pos) { public TrackedChunk getChunk(final ChunkPos pos) {
@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
public void broadcastChanges(LevelChunk chunk) { public void broadcastChanges(LevelChunk chunk) {
- if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) { - if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) {
+ if (this.needsBroadcastChanges()) { // Paper - moved into above, other logic needs to call + if (this.needsBroadcastChanges()) { // Paper - optimise chunk tick iteration; moved into above, other logic needs to call
Level world = chunk.getLevel(); Level world = chunk.getLevel();
List list; List list;
@ -135,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end // Paper end
- private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { - private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
+ public static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { // Paper - optimise chunk iteration - public + public static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { // Paper - optimise chunk iteration; public
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8); double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 8); double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 8);
double d2 = d0 - entity.getX(); double d2 = d0 - entity.getX();

View file

@ -148,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
T livingEntity = null; T livingEntity = null;
for(T livingEntity2 : entityList) { for(T livingEntity2 : entityList) {
+ // Paper start - move up + // Paper start - optimise nearby player retrieval; move up
+ // don't check entities outside closest range + // don't check entities outside closest range
+ double e = livingEntity2.distanceToSqr(x, y, z); + double e = livingEntity2.distanceToSqr(x, y, z);
+ if (d == -1.0D || e < d) { + if (d == -1.0D || e < d) {
@ -156,7 +156,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (targetPredicate.test(entity, livingEntity2)) { if (targetPredicate.test(entity, livingEntity2)) {
- double e = livingEntity2.distanceToSqr(x, y, z); - double e = livingEntity2.distanceToSqr(x, y, z);
- if (d == -1.0D || e < d) { - if (d == -1.0D || e < d) {
+ // Paper - move up + // Paper - optimise nearby player retrieval; move up
d = e; d = e;
livingEntity = livingEntity2; livingEntity = livingEntity2;
} }

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.status = Behavior.Status.RUNNING; this.status = Behavior.Status.RUNNING;
this.orderPolicy.apply(this.behaviors); this.orderPolicy.apply(this.behaviors);
- this.runningPolicy.apply(this.behaviors.stream(), world, entity, time); - this.runningPolicy.apply(this.behaviors.stream(), world, entity, time);
+ this.runningPolicy.apply(this.behaviors.entries, world, entity, time); + this.runningPolicy.apply(this.behaviors.entries, world, entity, time); // Paper - Remove streams
return true; return true;
} else { } else {
return false; return false;
@ -26,13 +26,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }).forEach((task) -> { - }).forEach((task) -> {
- task.tickOrStop(world, entity, time); - task.tickOrStop(world, entity, time);
- }); - });
+ // Paper start + // Paper start - Remove streams
+ for (BehaviorControl<? super E> task : this.behaviors) { + for (BehaviorControl<? super E> task : this.behaviors) {
+ if (task.getStatus() == Behavior.Status.RUNNING) { + if (task.getStatus() == Behavior.Status.RUNNING) {
+ task.tickOrStop(world, entity, time); + task.tickOrStop(world, entity, time);
+ } + }
+ } + }
+ // Paper end + // Paper end - Remove streams
if (this.behaviors.stream().noneMatch((task) -> { if (this.behaviors.stream().noneMatch((task) -> {
return task.getStatus() == Behavior.Status.RUNNING; return task.getStatus() == Behavior.Status.RUNNING;
})) { })) {
@ -45,13 +45,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }).forEach((task) -> { - }).forEach((task) -> {
- task.doStop(world, entity, time); - task.doStop(world, entity, time);
- }); - });
+ // Paper start + // Paper start - Remove streams
+ for (BehaviorControl<? super E> behavior : this.behaviors) { + for (BehaviorControl<? super E> behavior : this.behaviors) {
+ if (behavior.getStatus() == Behavior.Status.RUNNING) { + if (behavior.getStatus() == Behavior.Status.RUNNING) {
+ behavior.doStop(world, entity, time); + behavior.doStop(world, entity, time);
+ } + }
+ } + }
+ // Paper end + // Paper end - Remove streams
this.exitErasedMemories.forEach(entity.getBrain()::eraseMemory); this.exitErasedMemories.forEach(entity.getBrain()::eraseMemory);
} }
@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }).filter((task) -> { - }).filter((task) -> {
- return task.tryStart(world, entity, time); - return task.tryStart(world, entity, time);
- }).findFirst(); - }).findFirst();
+ // Paper start - remove streams + // Paper start - Remove streams
+ public <E extends LivingEntity> void apply(List<ShufflingList.WeightedEntry<BehaviorControl<? super E>>> tasks, ServerLevel world, E entity, long time) { + public <E extends LivingEntity> void apply(List<ShufflingList.WeightedEntry<BehaviorControl<? super E>>> tasks, ServerLevel world, E entity, long time) {
+ for (ShufflingList.WeightedEntry<BehaviorControl<? super E>> task : tasks) { + for (ShufflingList.WeightedEntry<BehaviorControl<? super E>> task : tasks) {
+ final BehaviorControl<? super E> behavior = task.getData(); + final BehaviorControl<? super E> behavior = task.getData();
@ -73,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ break; + break;
+ } + }
+ } + }
+ // Paper end - remove streams + // Paper end - Remove streams
} }
}, },
TRY_ALL { TRY_ALL {
@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- }).forEach((task) -> { - }).forEach((task) -> {
- task.tryStart(world, entity, time); - task.tryStart(world, entity, time);
- }); - });
+ // Paper start - remove streams + // Paper start - Remove streams
+ public <E extends LivingEntity> void apply(List<ShufflingList.WeightedEntry<BehaviorControl<? super E>>> tasks, ServerLevel world, E entity, long time) { + public <E extends LivingEntity> void apply(List<ShufflingList.WeightedEntry<BehaviorControl<? super E>>> tasks, ServerLevel world, E entity, long time) {
+ for (ShufflingList.WeightedEntry<BehaviorControl<? super E>> task : tasks) { + for (ShufflingList.WeightedEntry<BehaviorControl<? super E>> task : tasks) {
+ final BehaviorControl<? super E> behavior = task.getData(); + final BehaviorControl<? super E> behavior = task.getData();
@ -92,12 +92,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ behavior.tryStart(world, entity, time); + behavior.tryStart(world, entity, time);
+ } + }
+ } + }
+ // Paper end - remove streams + // Paper end - Remove streams
} }
}; };
- public abstract <E extends LivingEntity> void apply(Stream<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time); - public abstract <E extends LivingEntity> void apply(Stream<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time);
+ public abstract <E extends LivingEntity> void apply(List<ShufflingList.WeightedEntry<BehaviorControl<? super E>>> tasks, ServerLevel world, E entity, long time); // Paper - remove streams + public abstract <E extends LivingEntity> void apply(List<ShufflingList.WeightedEntry<BehaviorControl<? super E>>> tasks, ServerLevel world, E entity, long time); // Paper - Remove streams
} }
} }
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
@ -126,7 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}); });
- list.sort(Comparator.comparingDouble(entity::distanceToSqr)); - list.sort(Comparator.comparingDouble(entity::distanceToSqr));
+ list.sort((e1, e2) -> Double.compare(entity.distanceToSqr(e1), entity.distanceToSqr(e2))); // better to take the sort perf hit than using line of sight more than we need to. + list.sort((e1, e2) -> Double.compare(entity.distanceToSqr(e1), entity.distanceToSqr(e2))); // better to take the sort perf hit than using line of sight more than we need to.
+ // Paper start - remove streams + // Paper start - Remove streams
// Paper start - remove streams in favour of lists // Paper start - remove streams in favour of lists
ItemEntity nearest = null; ItemEntity nearest = null;
- for (ItemEntity entityItem : list) { - for (ItemEntity entityItem : list) {
@ -134,7 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) {
+ ItemEntity entityItem = list.get(i); + ItemEntity entityItem = list.get(i);
+ if (entity.hasLineOfSight(entityItem)) { + if (entity.hasLineOfSight(entityItem)) {
+ // Paper end - remove streams + // Paper end - Remove streams
nearest = entityItem; nearest = entityItem;
break; break;
} }

View file

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - update entity data + // Paper start - update entity data
+ this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ATTACHED_TO_TARGET, + this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ATTACHED_TO_TARGET,
+ entity != null ? java.util.OptionalInt.of(entity.getEntityId()) : java.util.OptionalInt.empty()); + entity != null ? java.util.OptionalInt.of(entity.getEntityId()) : java.util.OptionalInt.empty());
+ // Paper end + // Paper end - update entity data
return true; return true;
} }

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
map1.forEach((key, lootTable) -> { map1.forEach((key, lootTable) -> {
- if (object instanceof LootTable table) { - if (object instanceof LootTable table) {
+ if (lootTable instanceof LootTable table) { // Paper - use correct variable + if (lootTable instanceof LootTable table) { // Paper - Use correct variable for initializing CraftLootTable
table.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(key.location()), table); table.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(key.location()), table);
} }
}); });

View file

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return dedicatedserverproperties.enforceSecureProfile + return dedicatedserverproperties.enforceSecureProfile
+ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() + && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
+ && this.services.canValidateProfileKeys(); + && this.services.canValidateProfileKeys();
+ // Paper end + // Paper end - fix secure profile with proxy online mode
} }
@Override @Override