This commit is contained in:
Jake Potrebic 2024-04-23 19:46:06 -07:00
parent e45f4f85f4
commit 840f63b25a
33 changed files with 61 additions and 63 deletions

View file

@ -46,7 +46,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
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
private CraftEntity bukkitEntity;

View file

@ -45,9 +45,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
this.commandsConfiguration = YamlConfiguration.loadConfiguration(this.getCommandsConfigFile());
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
this.enablePlugins(PluginLoadOrder.STARTUP);
this.enablePlugins(PluginLoadOrder.POSTWORLD);
this.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.RELOAD));
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Disable watchdog early timeout on reload
}

View file

@ -33,17 +33,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
@@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy {
return -0.125F;
return entitysize.scale(1.0F + 0.15F * (float) i);
}
+ // Paper start
+ @Nullable
+ java.util.UUID spawningEntity;
+
+ @Nullable
+ public java.util.UUID getSpawningEntity() {
+ return spawningEntity;
+ return this.spawningEntity;
+ }
+ public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; }
+ // Paper end
+
private static enum AttackPhase {
CIRCLE, SWOOP;
@ -69,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entityphantom != null) {
+ entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper - PhantomPreSpawnEvent
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity, (CompoundTag) null);
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity);
world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/TntBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/TntBlock.java
@@ -0,0 +0,0 @@ public class TntBlock extends Block {
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (!oldState.is(state.getBlock())) {
if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
+ // Paper start - TNTPrimeEvent
@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@@ -0,0 +0,0 @@ public class TntBlock extends Block {
@Override
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, sourcePos)) { // CraftBukkit - TNTPrimeEvent
+ // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
@ -90,7 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
int i = entitytntprimed.getFuse();
@@ -0,0 +0,0 @@ public class TntBlock extends Block {
return InteractionResult.CONSUME;
return ItemInteractionResult.CONSUME;
}
// CraftBukkit end
+ // Paper start - TNTPrimeEvent
@ -101,7 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - TNTPrimeEvent
TntBlock.explode(world, pos, player);
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
Item item = itemstack.getItem();
Item item = stack.getItem();
@@ -0,0 +0,0 @@ public class TntBlock extends Block {
return;
}

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/ja
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -0,0 +0,0 @@ public final class ItemStack {
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
enuminteractionresult = InteractionResult.FAIL; // cancel placement
// PAIL: Remove this when MC-99075 fixed
placeEvent.getPlayer().updateInventory();

View file

@ -51,9 +51,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.canTickSetByAPI = true;
+ }
+ // Paper end - Allow ArmorStands not to tick
CompoundTag nbttagcompound1 = nbt.getCompound("Pose");
CompoundTag nbttagcompound2 = nbt.getCompound("Pose");
this.readPose(nbttagcompound1);
this.readPose(nbttagcompound2);
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
@Override

View file

@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
@@ -0,0 +0,0 @@ public class AnvilMenu extends ItemCombinerMenu {
if (!player.getAbilities().instabuild && iblockdata.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) {
if (!player.hasInfiniteMaterials() && iblockdata.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) {
BlockState iblockdata1 = AnvilBlock.damage(iblockdata);
+ // Paper start - AnvilDamageEvent

View file

@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -0,0 +0,0 @@ public class LiquidBlock extends Block implements BucketPickup {
@Override
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (this.shouldSpreadLiquid(world, pos, state)) {
- world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
+ world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper - Configurable speed for water flowing over lava
@ -39,11 +39,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - Configurable speed for water flowing over lava
+
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) {
@@ -0,0 +0,0 @@ public class LiquidBlock extends Block implements BucketPickup {
@Override
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
if (this.shouldSpreadLiquid(world, pos, state)) {
- world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
+ world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper - Configurable speed for water flowing over lava

View file

@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - cancellable death event
// CraftBukkit start
public String displayName;
public CraftPlayer.TransferCookieConnection transferCookieConnection;
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
@Override
@ -95,10 +95,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.isDeadOrDying()) {
if (!this.checkTotemDeathProtection(source)) {
- SoundEvent soundeffect = this.getDeathSound();
-
- if (flag1 && soundeffect != null) {
- this.playSound(soundeffect, this.getSoundVolume(), this.getVoicePitch());
- if (flag1) {
- this.makeSound(this.getDeathSound());
- }
+ // Paper start - moved into CraftEventFactory event caller for cancellable death event
+ this.silentDeath = !flag1; // mark entity as dying silently
@ -131,8 +129,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (world instanceof ServerLevel) {
ServerLevel worldserver = (ServerLevel) world;
+ // Paper - move below into if for onKill
- if (entity == null || entity.killedEntity(worldserver, this)) {
+
+ // Paper start
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(damageSource);
+ if (deathEvent == null || !deathEvent.isCancelled()) {
@ -155,7 +152,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (!this.level().isClientSide && this.hasCustomName()) {
+ if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot
+ }
+
- if (entity == null || entity.killedEntity(worldserver, this)) {
+ this.getCombatTracker().recheckStatus();
+ if (entity != null) {
+ entity.killedEntity((ServerLevel) this.level(), this);
@ -237,7 +235,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/n
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
}
@ -250,7 +248,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) {
super.dropCustomDeathLoot(source, lootingMultiplier, allowDrops);
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
for (int k = 0; k < j; ++k) {
EquipmentSlot enumitemslot = aenumitemslot[k];
@ -258,7 +256,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ItemStack itemstack = this.getItemBySlot(enumitemslot);
float f = this.getEquipmentDropChance(enumitemslot);
boolean flag1 = f > 1.0F;
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
}
this.spawnAtLocation(itemstack);
@ -317,7 +315,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return deathEvent; // Paper - Cancellable death event
}
@Override
public static boolean isPathClear(Fox fox, LivingEntity chasedEntity) {
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
@ -390,10 +388,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private org.bukkit.event.entity.EntityDeathEvent brokenByPlayer(DamageSource damageSource) { // Paper
ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
if (this.hasCustomName()) {
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
}
itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
- this.brokenByAnything(damageSource);
+ return this.brokenByAnything(damageSource); // Paper

View file

@ -19,12 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- private final Map<ResourceLocation, Holder.Reference<T>> byLocation = new HashMap<>();
- private final Map<ResourceKey<T>, Holder.Reference<T>> byKey = new HashMap<>();
- private final Map<T, Holder.Reference<T>> byValue = new IdentityHashMap<>();
- private final Map<T, Lifecycle> lifecycles = new IdentityHashMap<>();
- private final Map<ResourceKey<T>, RegistrationInfo> registrationInfos = new IdentityHashMap<>();
+ private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(2048), map -> map.defaultReturnValue(-1)); // Paper - Perf: Use bigger expected size to reduce collisions
+ private final Map<ResourceLocation, Holder.Reference<T>> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
+ private final Map<ResourceKey<T>, Holder.Reference<T>> byKey = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
+ private final Map<T, Holder.Reference<T>> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
+ private final Map<T, Lifecycle> lifecycles = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
+ private final Map<ResourceKey<T>, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
private Lifecycle registryLifecycle;
private volatile Map<TagKey<T>, HolderSet.Named<T>> tags = new IdentityHashMap<>();
private boolean frozen;

View file

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 22 Nov 2016 00:40:42 -0500
Subject: [PATCH] Remove unnecessary itemmeta handling
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
// CraftBukkit start
ItemStack itemstack = new ItemStack(holder, i, datacomponentpatch);
- if (!datacomponentpatch.isEmpty()) {
+ if (false && !datacomponentpatch.isEmpty()) { // Paper - This is no longer needed with raw NBT being handled in metadata
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
}
return itemstack;
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
registryfriendlybytebuf.writeVarInt(itemstack.getCount());
// Spigot start - filter
itemstack = itemstack.copy();
- CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+ // CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Paper - This is no longer with raw NBT being handled in metadata
// Spigot end
ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error
DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch());

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapG
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
@@ -0,0 +0,0 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
@@ -0,0 +0,0 @@ import net.minecraft.world.item.enchantment.ItemEnchantments;
public class SkeletonTrapGoal extends Goal {
private final SkeletonHorse horse;

View file

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 22 Nov 2016 00:40:42 -0500
Subject: [PATCH] Remove unnecessary itemmeta handling
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf {
if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) {
// Spigot start - filter
stack = stack.copy();
- CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack));
+ // CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); // Paper - This is no longer with raw NBT being handled in metadata
// Spigot end
nbttagcompound = stack.getTag();
}
@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf {
itemstack.setTag(this.readNbt());
// CraftBukkit start
- if (itemstack.getTag() != null) {
+ if (false && itemstack.getTag() != null) { // Paper - This is no longer needed with raw NBT being handled in metadata
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
}
// CraftBukkit end