diff --git a/patches/api/Spawn-Reason-API.patch b/patches/api/Spawn-Reason-API.patch index e3f7ebf273..7e9d84d3a0 100644 --- a/patches/api/Spawn-Reason-API.patch +++ b/patches/api/Spawn-Reason-API.patch @@ -13,9 +13,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.CreatureSpawnEvent; - import org.bukkit.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + @@ -0,0 +0,0 @@ public interface RegionAccessor { * {@link Entity} requested cannot be spawned */ diff --git a/patches/server/Add-villager-reputation-API.patch b/patches/server/Add-villager-reputation-API.patch index d8fdecaedf..554d3c9167 100644 --- a/patches/server/Add-villager-reputation-API.patch +++ b/patches/server/Add-villager-reputation-API.patch @@ -75,8 +75,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.Villager entity) { @@ -0,0 +0,0 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { - public static VillagerProfession bukkitToNmsProfession(Profession bukkit) { - return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey())); + .getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow(); + } } + + // Paper start - Add villager reputation API diff --git a/patches/server/Attributes-API-for-item-defaults.patch b/patches/server/Attributes-API-for-item-defaults.patch index 25e87f3814..1111aa83bd 100644 --- a/patches/server/Attributes-API-for-item-defaults.patch +++ b/patches/server/Attributes-API-for-item-defaults.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + ImmutableMultimap.Builder attributeMapBuilder = ImmutableMultimap.builder(); + item.getDefaultAttributeModifiers(CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> { -+ attributeMapBuilder.put(CraftAttributeMap.fromMinecraft(net.minecraft.core.registries.BuiltInRegistries.ATTRIBUTE.getKey(attributeBase).toString()), CraftAttributeInstance.convert(attributeModifier, equipmentSlot)); ++ attributeMapBuilder.put(CraftAttribute.stringToBukkit(net.minecraft.core.registries.BuiltInRegistries.ATTRIBUTE.getKey(attributeBase).toString()), CraftAttributeInstance.convert(attributeModifier, equipmentSlot)); + }); + return attributeMapBuilder.build(); + } diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch index cbae66a61c..11d82504ba 100644 --- a/patches/server/Basic-PlayerProfile-API.patch +++ b/patches/server/Basic-PlayerProfile-API.patch @@ -705,8 +705,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Map serialize() { + // Paper - diff on change Map map = new LinkedHashMap<>(); - if (this.uniqueId != null) { - map.put("uniqueId", this.uniqueId.toString()); + if (this.getUniqueId() != null) { + map.put("uniqueId", this.getUniqueId().toString()); @@ -0,0 +0,0 @@ public final class CraftPlayerProfile implements PlayerProfile { }); map.put("properties", propertiesData); diff --git a/patches/server/Bucketable-API.patch b/patches/server/Bucketable-API.patch index 307d447144..fcd95369db 100644 --- a/patches/server/Bucketable-API.patch +++ b/patches/server/Bucketable-API.patch @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + default Sound getPickupSound() { -+ return CraftSound.getBukkit(this.getHandle().getPickupSound()); ++ return CraftSound.minecraftToBukkit(this.getHandle().getPickupSound()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java diff --git a/patches/server/Convert-legacy-attributes-in-Item-Meta.patch b/patches/server/Convert-legacy-attributes-in-Item-Meta.patch index cfd5f83c56..05d5c5daeb 100644 --- a/patches/server/Convert-legacy-attributes-in-Item-Meta.patch +++ b/patches/server/Convert-legacy-attributes-in-Item-Meta.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; +@@ -0,0 +0,0 @@ import org.bukkit.attribute.AttributeInstance; public class CraftAttributeMap implements Attributable { private final AttributeMap handle; diff --git a/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch b/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch index 4d7002936e..07a405eaa7 100644 --- a/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch +++ b/patches/server/Expose-vanilla-BiomeProvider-from-WorldInfo.patch @@ -45,15 +45,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + final net.minecraft.world.level.biome.BiomeSource biomeSource = serverCache.getGenerator().getBiomeSource(); + final net.minecraft.world.level.biome.Climate.Sampler sampler = serverCache.randomState().sampler(); -+ final net.minecraft.core.Registry biomeRegistry = this.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME); + + final List possibleBiomes = biomeSource.possibleBiomes().stream() -+ .map(biome -> CraftBlock.biomeBaseToBiome(biomeRegistry, biome)) ++ .map(biome -> org.bukkit.craftbukkit.block.CraftBiome.minecraftHolderToBukkit(biome)) + .toList(); + return new BiomeProvider() { + @Override + public Biome getBiome(final org.bukkit.generator.WorldInfo worldInfo, final int x, final int y, final int z) { -+ return CraftBlock.biomeBaseToBiome(biomeRegistry, biomeSource.getNoiseBiome(x >> 2, y >> 2, z >> 2, sampler)); ++ return org.bukkit.craftbukkit.block.CraftBiome.minecraftHolderToBukkit(biomeSource.getNoiseBiome(x >> 2, y >> 2, z >> 2, sampler)); + } + + @Override @@ -118,14 +117,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + registryAccess.lookupOrThrow(net.minecraft.core.registries.Registries.NOISE), getSeed()); + } + -+ final net.minecraft.core.Registry biomeRegistry = CraftWorldInfo.this.registryAccess.registryOrThrow(net.minecraft.core.registries.Registries.BIOME); + final java.util.List possibleBiomes = CraftWorldInfo.this.vanillaChunkGenerator.getBiomeSource().possibleBiomes().stream() -+ .map(biome -> org.bukkit.craftbukkit.block.CraftBlock.biomeBaseToBiome(biomeRegistry, biome)) ++ .map(biome -> org.bukkit.craftbukkit.block.CraftBiome.minecraftHolderToBukkit(biome)) + .toList(); + return new org.bukkit.generator.BiomeProvider() { + @Override + public org.bukkit.block.Biome getBiome(final WorldInfo worldInfo, final int x, final int y, final int z) { -+ return org.bukkit.craftbukkit.block.CraftBlock.biomeBaseToBiome(biomeRegistry, ++ return org.bukkit.craftbukkit.block.CraftBiome.minecraftHolderToBukkit( + CraftWorldInfo.this.vanillaChunkGenerator.getBiomeSource().getNoiseBiome(x >> 2, y >> 2, z >> 2, randomState.sampler())); + } + diff --git a/patches/server/Fix-CraftSound-backwards-compatibility.patch b/patches/server/Fix-CraftSound-backwards-compatibility.patch index 6cd7635a20..cf1c5bc59f 100644 --- a/patches/server/Fix-CraftSound-backwards-compatibility.patch +++ b/patches/server/Fix-CraftSound-backwards-compatibility.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -0,0 +0,0 @@ public class CraftSound { - public static Sound getBukkit(SoundEvent soundEffect) { - return Registry.SOUNDS.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.SOUND_EVENT.getKey(soundEffect))); + throw new IllegalArgumentException("No Reference holder found for " + bukkit + + ", this can happen if a plugin creates its own sound effect with out properly registering it."); } + + // Paper start diff --git a/patches/server/Get-entity-default-attributes.patch b/patches/server/Get-entity-default-attributes.patch index 1b958da6d0..6f36411d9d 100644 --- a/patches/server/Get-entity-default-attributes.patch +++ b/patches/server/Get-entity-default-attributes.patch @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.attribute.Attributable; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; -+import org.bukkit.craftbukkit.attribute.CraftAttributeMap; ++import org.bukkit.craftbukkit.attribute.CraftAttribute; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public @Nullable AttributeInstance getAttribute(@NotNull Attribute attribute) { -+ net.minecraft.world.entity.ai.attributes.Attribute nmsAttribute = CraftAttributeMap.toMinecraft(attribute); ++ net.minecraft.world.entity.ai.attributes.Attribute nmsAttribute = CraftAttribute.bukkitToMinecraft(attribute); + if (!this.handle.hasAttribute(nmsAttribute)) { + return null; + } diff --git a/patches/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch index 4bd81f6383..a44c585347 100644 --- a/patches/server/Hook-into-CB-plugin-rewrites.patch +++ b/patches/server/Hook-into-CB-plugin-rewrites.patch @@ -11,12 +11,13 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -@@ -0,0 +0,0 @@ import java.io.FileOutputStream; - import java.io.InputStream; +@@ -0,0 +0,0 @@ import java.io.InputStream; + import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; + import java.util.List; +import java.util.Map; import java.util.Set; import java.util.jar.JarEntry; @@ -26,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; -+import org.objectweb.asm.Handle; + import org.objectweb.asm.Handle; +import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -103,20 +104,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 { + // Paper start - Plugin rewrites + @Override -+ public void visitInvokeDynamicInsn(String name, String desc, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) -+ { -+ // Paper start - Rewrite plugins -+ name = getOriginalOrRewrite( name ); -+ if ( desc != null ) -+ { -+ desc = getOriginalOrRewrite( desc ); -+ } -+ // Paper end -+ -+ super.visitInvokeDynamicInsn( name, desc, bootstrapMethodHandle, bootstrapMethodArguments ); -+ } -+ -+ @Override + public void visitTypeInsn(int opcode, String type) + { + type = getOriginalOrRewrite( type ); @@ -192,3 +179,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if ( value instanceof String && ( (String) value ).equals( "com.mysql.jdbc.Driver" ) ) { super.visitLdcInsn( "com.mysql.cj.jdbc.Driver" ); +@@ -0,0 +0,0 @@ public class Commodore + @Override + public void visitInvokeDynamicInsn( String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments ) + { ++ // Paper start - Rewrite plugins ++ name = getOriginalOrRewrite( name ); ++ if ( descriptor != null ) ++ { ++ descriptor = getOriginalOrRewrite( descriptor ); ++ } ++ // Paper end - Rewrite plugins + if ( bootstrapMethodHandle.getOwner().equals( "java/lang/invoke/LambdaMetafactory" ) + && bootstrapMethodHandle.getName().equals( "metafactory" ) && bootstrapMethodArguments.length == 3 ) + { diff --git a/patches/server/Implement-CraftBlockSoundGroup.patch b/patches/server/Implement-CraftBlockSoundGroup.patch index 4a48e1c37a..fe74a36265 100644 --- a/patches/server/Implement-CraftBlockSoundGroup.patch +++ b/patches/server/Implement-CraftBlockSoundGroup.patch @@ -26,27 +26,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public Sound getBreakSound() { -+ return CraftSound.getBukkit(soundEffectType.getBreakSound()); ++ return CraftSound.minecraftToBukkit(soundEffectType.getBreakSound()); + } + + @Override + public Sound getStepSound() { -+ return CraftSound.getBukkit(soundEffectType.getStepSound()); ++ return CraftSound.minecraftToBukkit(soundEffectType.getStepSound()); + } + + @Override + public Sound getPlaceSound() { -+ return CraftSound.getBukkit(soundEffectType.getPlaceSound()); ++ return CraftSound.minecraftToBukkit(soundEffectType.getPlaceSound()); + } + + @Override + public Sound getHitSound() { -+ return CraftSound.getBukkit(soundEffectType.getHitSound()); ++ return CraftSound.minecraftToBukkit(soundEffectType.getHitSound()); + } + + @Override + public Sound getFallSound() { -+ return CraftSound.getBukkit(soundEffectType.getFallSound()); ++ return CraftSound.minecraftToBukkit(soundEffectType.getFallSound()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java diff --git a/patches/server/Implement-alternative-item-despawn-rate.patch b/patches/server/Implement-alternative-item-despawn-rate.patch index 5eef75f5dd..3af4eeac5b 100644 --- a/patches/server/Implement-alternative-item-despawn-rate.patch +++ b/patches/server/Implement-alternative-item-despawn-rate.patch @@ -45,8 +45,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private void tryToMerge(ItemEntity other) { @@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity { + public void setItem(ItemStack stack) { - com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit this.getEntityData().set(ItemEntity.DATA_ITEM, stack); + this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper } diff --git a/patches/server/Implement-getComputedBiome-API.patch b/patches/server/Implement-getComputedBiome-API.patch index fdb048c999..3714c613ce 100644 --- a/patches/server/Implement-getComputedBiome-API.patch +++ b/patches/server/Implement-getComputedBiome-API.patch @@ -9,13 +9,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -0,0 +0,0 @@ public abstract class CraftRegionAccessor implements RegionAccessor { - return CraftBlock.biomeBaseToBiome(this.getHandle().registryAccess().registryOrThrow(Registries.BIOME), this.getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2)); + return CraftBiome.minecraftHolderToBukkit(this.getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2)); } + // Paper start + @Override + public Biome getComputedBiome(int x, int y, int z) { -+ return CraftBlock.biomeBaseToBiome(this.getHandle().registryAccess().registryOrThrow(Registries.BIOME), this.getHandle().getBiome(new BlockPos(x, y, z))); ++ return CraftBiome.minecraftHolderToBukkit(this.getHandle().getBiome(new BlockPos(x, y, z))); + } + // Paper end + diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index 28c7b4153b..80c1bce753 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -458,7 +458,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue()); + event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent()); + net.minecraft.sounds.SoundEvent soundEffect = victim.getDeathSound(); -+ event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.getBukkit(soundEffect) : null); ++ event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(soundEffect) : null); + event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundSource().name())); + event.setDeathSoundVolume(victim.getSoundVolume()); + event.setDeathSoundPitch(victim.getVoicePitch()); @@ -471,7 +471,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + double x = event.getEntity().getLocation().getX(); + double y = event.getEntity().getLocation().getY(); + double z = event.getEntity().getLocation().getZ(); -+ net.minecraft.sounds.SoundEvent soundEffect = org.bukkit.craftbukkit.CraftSound.getSoundEffect(event.getDeathSound()); ++ net.minecraft.sounds.SoundEvent soundEffect = org.bukkit.craftbukkit.CraftSound.bukkitToMinecraft(event.getDeathSound()); + net.minecraft.sounds.SoundSource soundCategory = net.minecraft.sounds.SoundSource.valueOf(event.getDeathSoundCategory().name()); + victim.level().playSound(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch()); + } diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 10a962b087..e72edc62c6 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -7741,7 +7741,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - private static final BiMap FLUIDTYPE_FLUID = HashBiMap.create(); + private static final Map ITEM_MATERIAL = new HashMap<>(); private static final Map MATERIAL_ITEM = new HashMap<>(); private static final Map MATERIAL_BLOCK = new HashMap<>(); + // Paper start diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index cda9a0e385..54ebc1f43b 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -534,9 +534,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -0,0 +0,0 @@ public class CraftCat extends CraftTameableAnimal implements Cat { - public void setCollarColor(DyeColor color) { - this.getHandle().setCollarColor(net.minecraft.world.item.DyeColor.byId(color.getWoolData())); + .byId(bukkit.ordinal()); + } } ++ + // Paper Start - More cat api + @Override + public void setLyingDown(boolean lyingDown) { diff --git a/patches/server/More-PotionEffectType-API.patch b/patches/server/More-PotionEffectType-API.patch index 19b26a6a37..882de5e807 100644 --- a/patches/server/More-PotionEffectType-API.patch +++ b/patches/server/More-PotionEffectType-API.patch @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final java.util.Map attributeMap = new java.util.HashMap<>(); + this.handle.getAttributeModifiers().forEach((attribute, attributeModifier) -> { + attributeMap.put( -+ org.bukkit.craftbukkit.attribute.CraftAttributeMap.fromMinecraft(attribute.toString()), ++ org.bukkit.craftbukkit.attribute.CraftAttribute.stringToBukkit(attribute.toString()), + // use zero as amplifier to get the base amount, as it is amount = base * (amplifier + 1) + org.bukkit.craftbukkit.attribute.CraftAttributeInstance.convert(attributeModifier.create(0)) + ); @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public double getAttributeModifierAmount(org.bukkit.attribute.Attribute attribute, int effectAmplifier) { + com.google.common.base.Preconditions.checkArgument(effectAmplifier >= 0, "effectAmplifier must be greater than or equal to 0"); -+ net.minecraft.world.entity.ai.attributes.Attribute nmsAttribute = org.bukkit.craftbukkit.attribute.CraftAttributeMap.toMinecraft(attribute); ++ net.minecraft.world.entity.ai.attributes.Attribute nmsAttribute = org.bukkit.craftbukkit.attribute.CraftAttribute.bukkitToMinecraft(attribute); + com.google.common.base.Preconditions.checkArgument(this.handle.getAttributeModifiers().containsKey(nmsAttribute), attribute + " is not present on " + this.getKey()); + return this.handle.getAttributeModifiers().get(nmsAttribute).create(effectAmplifier).getAmount(); + } diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index 557db4a3b1..ec49e6df19 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -158,12 +158,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @org.jetbrains.annotations.NotNull + @Override + public org.bukkit.Sound getHitSound() { -+ return org.bukkit.craftbukkit.CraftSound.getBukkit(this.getHandle().soundEvent); ++ return org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(this.getHandle().soundEvent); + } + + @Override + public void setHitSound(@org.jetbrains.annotations.NotNull org.bukkit.Sound sound) { -+ this.getHandle().setSoundEvent(org.bukkit.craftbukkit.CraftSound.getSoundEffect(sound)); ++ this.getHandle().setSoundEvent(org.bukkit.craftbukkit.CraftSound.bukkitToMinecraft(sound)); + } + @Override diff --git a/patches/server/Prevent-empty-items-from-being-added-to-world.patch b/patches/server/Prevent-empty-items-from-being-added-to-world.patch index 3d02bf1370..be91ac371e 100644 --- a/patches/server/Prevent-empty-items-from-being-added-to-world.patch +++ b/patches/server/Prevent-empty-items-from-being-added-to-world.patch @@ -18,16 +18,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - capture all item additions to the world if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) { captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity); -diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity { - } - - public void setItem(ItemStack stack) { -- com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit -+ // com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit // Paper - Remove check - this.getEntityData().set(ItemEntity.DATA_ITEM, stack); - this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - } diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index 30305a6303..867bc37ba7 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -579,7 +579,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - net.md-5 - specialsource-maven-plugin -- 1.2.4 +- 2.0.0 - - - package @@ -588,6 +588,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - remap-members - +- false - ${project.build.directory}/server.txt - org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot-members - true @@ -737,6 +738,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - remap-obf - +- false - org.spigotmc:minecraft-server:${project.version}:csrg:maps-spigot - true - true @@ -750,6 +752,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - remap-mojang - +- false - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:${project.version}:txt:maps-mojang - true diff --git a/patches/server/Suppress-Item-Meta-Validation-Checks.patch b/patches/server/Suppress-Item-Meta-Validation-Checks.patch index 38eed3aec0..708e1948ad 100644 --- a/patches/server/Suppress-Item-Meta-Validation-Checks.patch +++ b/patches/server/Suppress-Item-Meta-Validation-Checks.patch @@ -54,11 +54,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 continue; } -- Attribute attribute = CraftAttributeMap.fromMinecraft(attributeName); +- Attribute attribute = CraftAttribute.stringToBukkit(attributeName); + // Paper start + Attribute attribute; + try { -+ attribute = CraftAttributeMap.fromMinecraft(attributeName); ++ attribute = CraftAttribute.stringToBukkit(attributeName); + } catch (IllegalArgumentException e) { + attribute = null; + } @@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT))); } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { - this.setProfile(new CraftGameProfile(null, tag.getString(SKULL_OWNER.NBT))); + this.setProfile(new GameProfile(Util.NIL_UUID, tag.getString(SKULL_OWNER.NBT))); } + } catch (Exception ignored) {} // Paper diff --git a/patches/server/Use-UserCache-for-player-heads.patch b/patches/server/Use-UserCache-for-player-heads.patch index d5f4dbf641..783d63b915 100644 --- a/patches/server/Use-UserCache-for-player-heads.patch +++ b/patches/server/Use-UserCache-for-player-heads.patch @@ -12,12 +12,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (name == null) { this.setProfile(null); } else { -- this.setProfile(new CraftGameProfile(null, name)); +- this.setProfile(new GameProfile(Util.NIL_UUID, name)); + // Paper start - Use Online Players Skull + GameProfile newProfile = null; + net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name); + if (player != null) newProfile = player.getGameProfile(); -+ if (newProfile == null) newProfile = new CraftGameProfile(null, name); ++ if (newProfile == null) newProfile = new GameProfile(Util.NIL_UUID, name); + this.setProfile(newProfile); + // Paper end } diff --git a/patches/server/cache-resource-keys.patch b/patches/server/cache-resource-keys.patch index fa1667d845..7eed2e1c61 100644 --- a/patches/server/cache-resource-keys.patch +++ b/patches/server/cache-resource-keys.patch @@ -4,38 +4,48 @@ Date: Sun, 20 Mar 2022 22:06:47 -0700 Subject: [PATCH] cache resource keys -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -@@ -0,0 +0,0 @@ public class CraftBlock implements Block { - return (biome == null) ? Biome.CUSTOM : biome; +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBiome.java +@@ -0,0 +0,0 @@ package org.bukkit.craftbukkit.block; + import com.google.common.base.Preconditions; + import net.minecraft.core.Holder; + import net.minecraft.core.registries.Registries; ++import net.minecraft.resources.ResourceKey; + import org.bukkit.Registry; + import org.bukkit.block.Biome; + import org.bukkit.craftbukkit.CraftRegistry; +@@ -0,0 +0,0 @@ public class CraftBiome { + return CraftBiome.minecraftToBukkit(minecraft.value()); } -+ private static final java.util.Map> BIOME_KEY_CACHE = Collections.synchronizedMap(new java.util.EnumMap<>(Biome.class)); // Paper - public static Holder biomeToBiomeBase(net.minecraft.core.Registry registry, Biome bio) { - if (bio == null || bio == Biome.CUSTOM) { ++ private static final java.util.Map> BIOME_KEY_CACHE = java.util.Collections.synchronizedMap(new java.util.EnumMap<>(Biome.class)); // Paper + public static net.minecraft.world.level.biome.Biome bukkitToMinecraft(Biome bukkit) { + if (bukkit == null || bukkit == Biome.CUSTOM) { return null; } -- return registry.getHolderOrThrow(ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(bio.getKey()))); -+ return registry.getHolderOrThrow(BIOME_KEY_CACHE.computeIfAbsent(bio, b -> ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(b.getKey())))); // Paper - cache key + return CraftRegistry.getMinecraftRegistry(Registries.BIOME) +- .getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow(); ++ .getOptional(BIOME_KEY_CACHE.computeIfAbsent(bukkit, b -> ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(b.getKey())))).orElseThrow(); } - @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java + public static Holder bukkitToMinecraftHolder(Biome bukkit) { +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityType.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java -+++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftEntityTag.java -@@ -0,0 +0,0 @@ public class CraftEntityTag extends CraftTag>> KEY_CACHE = java.util.Collections.synchronizedMap(new java.util.EnumMap<>(EntityType.class)); // Paper - @Override - public boolean isTagged(EntityType entity) { -- return registry.getHolderOrThrow(ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag); -+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(entity, type -> ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(type.getKey())))).is(tag); // Paper - cache key ++ private static final java.util.Map>> KEY_CACHE = java.util.Collections.synchronizedMap(new java.util.EnumMap<>(EntityType.class)); // Paper + public static net.minecraft.world.entity.EntityType bukkitToMinecraft(EntityType bukkit) { + Preconditions.checkArgument(bukkit != null); +- + return CraftRegistry.getMinecraftRegistry(Registries.ENTITY_TYPE) +- .getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow(); ++ .getOptional(KEY_CACHE.computeIfAbsent(bukkit, type -> net.minecraft.resources.ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(type.getKey())))).orElseThrow(); } - - @Override + } diff --git a/patches/server/fix-Instruments.patch b/patches/server/fix-Instruments.patch index 30ef4d10ba..1c77af9662 100644 --- a/patches/server/fix-Instruments.patch +++ b/patches/server/fix-Instruments.patch @@ -13,39 +13,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.getHandle().connection == null) return; -- String instrumentName = switch (instrument.ordinal()) { -- case 0 -> "harp"; -- case 1 -> "basedrum"; -- case 2 -> "snare"; -- case 3 -> "hat"; -- case 4 -> "bass"; -- case 5 -> "flute"; -- case 6 -> "bell"; -- case 7 -> "guitar"; -- case 8 -> "chime"; -- case 9 -> "xylophone"; -- case 10 -> "iron_xylophone"; -- case 11 -> "cow_bell"; -- case 12 -> "didgeridoo"; -- case 13 -> "bit"; -- case 14 -> "banjo"; -- case 15 -> "pling"; -- case 16 -> "xylophone"; +- Sound instrumentSound = switch (instrument.ordinal()) { +- case 0 -> Sound.BLOCK_NOTE_BLOCK_HARP; +- case 1 -> Sound.BLOCK_NOTE_BLOCK_BASEDRUM; +- case 2 -> Sound.BLOCK_NOTE_BLOCK_SNARE; +- case 3 -> Sound.BLOCK_NOTE_BLOCK_HAT; +- case 4 -> Sound.BLOCK_NOTE_BLOCK_BASS; +- case 5 -> Sound.BLOCK_NOTE_BLOCK_FLUTE; +- case 6 -> Sound.BLOCK_NOTE_BLOCK_BELL; +- case 7 -> Sound.BLOCK_NOTE_BLOCK_GUITAR; +- case 8 -> Sound.BLOCK_NOTE_BLOCK_CHIME; +- case 9 -> Sound.BLOCK_NOTE_BLOCK_XYLOPHONE; +- case 10 -> Sound.BLOCK_NOTE_BLOCK_IRON_XYLOPHONE; +- case 11 -> Sound.BLOCK_NOTE_BLOCK_COW_BELL; +- case 12 -> Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO; +- case 13 -> Sound.BLOCK_NOTE_BLOCK_BIT; +- case 14 -> Sound.BLOCK_NOTE_BLOCK_BANJO; +- case 15 -> Sound.BLOCK_NOTE_BLOCK_PLING; +- case 16 -> Sound.BLOCK_NOTE_BLOCK_XYLOPHONE; - default -> null; - }; - - float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); -- this.getHandle().connection.send(new ClientboundSoundPacket(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect("block.note_block." + instrumentName)), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, this.getHandle().getRandom().nextLong())); +- this.getHandle().connection.send(new ClientboundSoundPacket(CraftSound.bukkitToMinecraftHolder(instrumentSound), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, this.getHandle().getRandom().nextLong())); + // Paper start - fix all this (modeled off of NoteBlock) -+ net.minecraft.world.level.block.state.properties.NoteBlockInstrument nms = CraftBlockData.toNMS(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class); -+ float f; -+ if (nms.isTunable()) { -+ f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); ++ net.minecraft.world.level.block.state.properties.NoteBlockInstrument noteBlockInstrument = CraftBlockData.toNMS(instrument, net.minecraft.world.level.block.state.properties.NoteBlockInstrument.class); ++ float pitch; ++ if (noteBlockInstrument.isTunable()) { ++ pitch = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); + } else { -+ f = 1.0f; ++ pitch = 1.0f; + } -+ if (!nms.hasCustomSound()) { -+ this.getHandle().connection.send(new ClientboundSoundPacket(nms.getSoundEvent(), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, this.getHandle().getRandom().nextLong())); ++ if (!noteBlockInstrument.hasCustomSound()) { ++ this.getHandle().connection.send(new ClientboundSoundPacket(noteBlockInstrument.getSoundEvent(), net.minecraft.sounds.SoundSource.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, pitch, this.getHandle().getRandom().nextLong())); + } + // Paper end } diff --git a/patches/server/living-entity-allow-attribute-registration.patch b/patches/server/living-entity-allow-attribute-registration.patch index c2c28e7360..8b28c178da 100644 --- a/patches/server/living-entity-allow-attribute-registration.patch +++ b/patches/server/living-entity-allow-attribute-registration.patch @@ -26,20 +26,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java @@ -0,0 +0,0 @@ public class CraftAttributeMap implements Attributable { + return (nms == null) ? null : new CraftAttributeInstance(nms, attribute); } - + // Paper start + @Override + public void registerAttribute(Attribute attribute) { + Preconditions.checkArgument(attribute != null, "attribute"); -+ handle.registerAttribute(CraftAttributeMap.toMinecraft(attribute)); ++ handle.registerAttribute(CraftAttribute.bukkitToMinecraft(attribute)); + } + // Paper end -+ - public static net.minecraft.world.entity.ai.attributes.Attribute toMinecraft(Attribute attribute) { - return BuiltInRegistries.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey())); - } + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/work/Bukkit b/work/Bukkit index d7a7a6c677..dfe1fb4853 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit d7a7a6c677a84a646a24069572b2ba8b189b4693 +Subproject commit dfe1fb4853158bd17f6955527ad3bf85f4d5150d diff --git a/work/CraftBukkit b/work/CraftBukkit index 28c1023286..f71a799f03 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 28c10232864804265dd3fa4e2008a55e1718b128 +Subproject commit f71a799f03aae4277a48b4a1082b478833975682