mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Compiler issue v5
This commit is contained in:
parent
f3f59e196d
commit
d333b32d4f
9 changed files with 34 additions and 24 deletions
|
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
@Override
|
||||
- public void giveExp(int exp) {
|
||||
+ // Paper start
|
||||
+ // Paper start - ability to apply mending
|
||||
+ public int applyMending(int amount) {
|
||||
+ ServerPlayer handle = this.getHandle();
|
||||
+ // Logic copied from EntityExperienceOrb and remapped to unobfuscated methods/properties
|
||||
|
@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ .getRandomItemWith(net.minecraft.world.item.enchantment.EnchantmentEffectComponents.REPAIR_WITH_XP, handle, net.minecraft.world.item.ItemStack::isDamaged);
|
||||
+ final net.minecraft.world.item.ItemStack itemstack = stackEntry.map(net.minecraft.world.item.enchantment.EnchantedItemInUse::itemStack).orElse(net.minecraft.world.item.ItemStack.EMPTY);
|
||||
+ if (!itemstack.isEmpty() && itemstack.getItem().components().has(net.minecraft.core.component.DataComponents.MAX_DAMAGE)) {
|
||||
+ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level());
|
||||
+ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level(), net.minecraft.world.entity.EntitySpawnReason.COMMAND);
|
||||
+ orb.value = amount;
|
||||
+ orb.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM;
|
||||
+ orb.setPosRaw(handle.getX(), handle.getY(), handle.getZ());
|
||||
|
@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ if (applyMending) {
|
||||
+ exp = this.applyMending(exp);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - ability to apply mending
|
||||
this.getHandle().giveExperiencePoints(exp);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ public static final BiMap<FeatureFlag, net.minecraft.world.flag.FeatureFlag> FLAGS = ImmutableBiMap.of(
|
||||
+ FeatureFlag.VANILLA, FeatureFlags.VANILLA,
|
||||
+ FeatureFlag.BUNDLE, FeatureFlags.BUNDLE,
|
||||
+ FeatureFlag.TRADE_REBALANCE, FeatureFlags.TRADE_REBALANCE
|
||||
+ FeatureFlag.TRADE_REBALANCE, FeatureFlags.TRADE_REBALANCE,
|
||||
+ FeatureFlag.MINECART_IMPROVEMENTS, FeatureFlags.MINECART_IMPROVEMENTS,
|
||||
+ FeatureFlag.REDSTONE_EXPERIMENTS, FeatureFlags.REDSTONE_EXPERIMENTS,
|
||||
+ FeatureFlag.WINTER_DROP, FeatureFlags.WINTER_DROP
|
||||
+ );
|
||||
+
|
||||
+ @Override
|
||||
|
|
|
@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ private static final Map<GameEvent, ResourceKey<net.minecraft.world.level.gameevent.GameEvent>> KEY_CACHE = Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
+ @Override
|
||||
+ public boolean isTagged(@NotNull GameEvent gameEvent) {
|
||||
+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registries.GAME_EVENT, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag);
|
||||
+ return registry.getOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registries.GAME_EVENT, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
|
|
@ -61,6 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import net.kyori.adventure.text.format.TextDecoration;
|
||||
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
+import net.minecraft.commands.arguments.selector.SelectorPattern;
|
||||
+import net.minecraft.core.UUIDUtil;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -146,7 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ @Subst("key") final String typeKey = isi.item.unwrapKey().orElseThrow().location().toString();
|
||||
+ return HoverEvent.ShowItem.showItem(Key.key(typeKey), isi.count, PaperAdventure.asAdventure(isi.getItemStack().getComponentsPatch()));
|
||||
+ }, si -> {
|
||||
+ final Item itemType = BuiltInRegistries.ITEM.get(PaperAdventure.asVanilla(si.item()));
|
||||
+ final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(si.item()));
|
||||
+ final Map<Key, DataComponentValue> dataComponentsMap = si.dataComponents();
|
||||
+ final ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(itemType), si.count(), PaperAdventure.asVanilla(dataComponentsMap));
|
||||
+ return new net.minecraft.network.chat.HoverEvent.ItemStackInfo(stack);
|
||||
|
@ -315,7 +316,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ });
|
||||
+
|
||||
+ static final MapCodec<KeybindComponent> KEYBIND_COMPONENT_MAP_CODEC = KeybindContents.CODEC.xmap(k -> Component.keybind(k.getName()), k -> new KeybindContents(k.keybind()));
|
||||
+ static final MapCodec<ScoreComponent> SCORE_COMPONENT_INNER_MAP_CODEC = ScoreContents.INNER_CODEC.xmap(s -> Component.score(s.getName(), s.getObjective()), s -> new ScoreContents(s.name(), s.objective()));
|
||||
+ static final MapCodec<ScoreComponent> SCORE_COMPONENT_INNER_MAP_CODEC = ScoreContents.INNER_CODEC.xmap(
|
||||
+ s -> Component.score(s.name().map(SelectorPattern::pattern, Function.identity()), s.objective()),
|
||||
+ s -> new ScoreContents(SelectorPattern.parse(s.name()).<Either<SelectorPattern, String>>map(Either::left).result().orElse(Either.right(s.name())), s.objective())
|
||||
+ ); // TODO we might want to ask adventure for a nice way we can avoid parsing and flattening the SelectorPattern on every conversion.
|
||||
+ static final MapCodec<ScoreComponent> SCORE_COMPONENT_MAP_CODEC = SCORE_COMPONENT_INNER_MAP_CODEC.fieldOf("score");
|
||||
+ static final MapCodec<SelectorComponent> SELECTOR_COMPONENT_MAP_CODEC = mapCodec((instance) -> {
|
||||
+ return instance.group(
|
||||
|
@ -1580,7 +1584,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ final DataComponentPatch.Builder builder = DataComponentPatch.builder();
|
||||
+ map.forEach((key, dataComponentValue) -> {
|
||||
+ final DataComponentType<?> type = requireNonNull(BuiltInRegistries.DATA_COMPONENT_TYPE.get(asVanilla(key)));
|
||||
+ final DataComponentType<?> type = requireNonNull(BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(asVanilla(key)));
|
||||
+ if (dataComponentValue instanceof DataComponentValue.Removed) {
|
||||
+ builder.remove(type);
|
||||
+ return;
|
||||
|
@ -1895,7 +1899,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ GsonDataComponentValue.class,
|
||||
+ PaperAdventure.DataComponentValueImpl.class,
|
||||
+ (key, dataComponentValue) -> {
|
||||
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(PaperAdventure.asVanilla(key));
|
||||
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(PaperAdventure.asVanilla(key));
|
||||
+ if (type == null) {
|
||||
+ throw new IllegalArgumentException("Unknown data component type: " + key);
|
||||
+ }
|
||||
|
@ -1911,7 +1915,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ DataComponentValue.TagSerializable.class,
|
||||
+ PaperAdventure.DataComponentValueImpl.class,
|
||||
+ (key, tagSerializable) -> {
|
||||
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(PaperAdventure.asVanilla(key));
|
||||
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(PaperAdventure.asVanilla(key));
|
||||
+ if (type == null) {
|
||||
+ throw new IllegalArgumentException("Unknown data component type: " + key);
|
||||
+ }
|
||||
|
|
|
@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ for (org.bukkit.inventory.EquipmentSlot slot : slots) {
|
||||
+ if (slot == org.bukkit.inventory.EquipmentSlot.OFF_HAND) continue;
|
||||
+ net.minecraft.world.entity.EquipmentSlot nmsSlot = org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot);
|
||||
+ disabled += (1 << nmsSlot.getFilterFlag()) + (1 << (nmsSlot.getFilterFlag() + 8)) + (1 << (nmsSlot.getFilterFlag() + 16));
|
||||
+ disabled += (1 << nmsSlot.getFilterBit(0)) + (1 << nmsSlot.getFilterBit(8)) + (1 << nmsSlot.getFilterBit(16));
|
||||
+ }
|
||||
+ getHandle().disabledSlots = disabled;
|
||||
+ }
|
||||
|
|
|
@ -16,22 +16,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ // Paper start
|
||||
+ @Override
|
||||
+ public double getPushX() {
|
||||
+ return getHandle().xPush;
|
||||
+ return getHandle().push.x;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public double getPushZ() {
|
||||
+ return getHandle().zPush;
|
||||
+ return getHandle().push.z;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setPushX(double xPush) {
|
||||
+ getHandle().xPush = xPush;
|
||||
+ final net.minecraft.world.phys.Vec3 push = getHandle().push;
|
||||
+ getHandle().push = new net.minecraft.world.phys.Vec3(xPush, push.y, push.z);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setPushZ(double zPush) {
|
||||
+ getHandle().zPush = zPush;
|
||||
+ final net.minecraft.world.phys.Vec3 push = getHandle().push;
|
||||
+ getHandle().push = new net.minecraft.world.phys.Vec3(push.x, push.y, zPush);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
|
|
|
@ -263,7 +263,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ for (final io.papermc.paper.entity.TeleportFlag.Relative bukkit : relativeArguments) {
|
||||
+ nms.add(toNmsRelativeFlag(bukkit));
|
||||
+ }
|
||||
+ entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), nms);
|
||||
+ entity.connection.internalTeleport(new net.minecraft.world.entity.PositionMoveRotation(
|
||||
+ io.papermc.paper.util.MCUtil.toVec3(to), net.minecraft.world.phys.Vec3.ZERO, to.getYaw(), to.getPitch()
|
||||
+ ), nms);
|
||||
+ // Paper end - Teleport API
|
||||
} else {
|
||||
entity.portalProcess = null; // SPIGOT-7785: there is no need to carry this over as it contains the old world/location and we might run into trouble if there is a portal in the same spot in both worlds
|
||||
|
|
|
@ -3178,7 +3178,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ protected final Registry<R> registry() {
|
||||
+ return this.registryAccess.registryOrThrow(this.registryKey);
|
||||
+ return this.registryAccess.lookupOrThrow(this.registryKey);
|
||||
+ }
|
||||
+
|
||||
+ protected abstract T convertFromResourceKey(ResourceKey<R> key) throws SerializationException;
|
||||
|
@ -3240,7 +3240,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ @Override
|
||||
+ protected Holder<T> convertFromResourceKey(ResourceKey<T> key) throws SerializationException {
|
||||
+ return this.registry().getHolder(key).orElseThrow(() -> new SerializationException("Missing holder in " + this.registry().key() + " with key " + key));
|
||||
+ return this.registry().get(key).orElseThrow(() -> new SerializationException("Missing holder in " + this.registry().key() + " with key " + key));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
@ -3277,7 +3277,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ @Override
|
||||
+ protected T convertFromResourceKey(ResourceKey<T> key) throws SerializationException {
|
||||
+ final T value = this.registry().get(key);
|
||||
+ final T value = this.registry().getValue(key);
|
||||
+ if (value == null) {
|
||||
+ throw new SerializationException("Missing value in " + this.registry() + " with key " + key.location());
|
||||
+ }
|
||||
|
@ -3668,7 +3668,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ final Reference2LongMap<Holder<ConfiguredFeature<?, ?>>> features = Objects.requireNonNullElseGet(featureNode.get(new TypeToken<Reference2LongMap<Holder<ConfiguredFeature<?, ?>>>>() {}), Reference2LongOpenHashMap::new);
|
||||
+ final Random random = new SecureRandom();
|
||||
+ AtomicInteger counter = new AtomicInteger(0);
|
||||
+ MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).holders().forEach(holder -> {
|
||||
+ MinecraftServer.getServer().registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).listElements().forEach(holder -> {
|
||||
+ if (features.containsKey(holder)) {
|
||||
+ return;
|
||||
+ }
|
||||
|
@ -3805,7 +3805,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ )
|
||||
+ .addVersion(26, ConfigurationTransformation.builder().addAction(path("alt-item-despawn-rate", "items", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> {
|
||||
+ String itemName = path.get(path.size() - 1).toString();
|
||||
+ final Optional<Holder.Reference<Item>> item = BuiltInRegistries.ITEM.getHolder(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT))));
|
||||
+ final Optional<Holder.Reference<Item>> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT))));
|
||||
+ if (item.isEmpty()) {
|
||||
+ itemName = Material.valueOf(itemName).getKey().getKey();
|
||||
+ }
|
||||
|
@ -3837,7 +3837,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ Map<String, Integer> rebuild = new HashMap<>();
|
||||
+ value.childrenMap().forEach((key, node) -> {
|
||||
+ String itemName = key.toString();
|
||||
+ final Optional<Holder.Reference<Item>> itemHolder = BuiltInRegistries.ITEM.getHolder(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT))));
|
||||
+ final Optional<Holder.Reference<Item>> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT))));
|
||||
+ final @Nullable String item;
|
||||
+ if (itemHolder.isEmpty()) {
|
||||
+ final @Nullable Material bukkitMat = Material.matchMaterial(itemName);
|
||||
|
|
|
@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ final RegistryAccess.Frozen access = ((CraftServer) sender.getServer()).getServer().registryAccess();
|
||||
+ final RegistryOps<Tag> ops = access.createSerializationContext(NbtOps.INSTANCE);
|
||||
+ final Registry<DataComponentType<?>> registry = access.registryOrThrow(Registries.DATA_COMPONENT_TYPE);
|
||||
+ final Registry<DataComponentType<?>> registry = access.lookupOrThrow(Registries.DATA_COMPONENT_TYPE);
|
||||
+ final List<ComponentLike> componentComponents = new ArrayList<>();
|
||||
+ final List<String> commandComponents = new ArrayList<>();
|
||||
+ for (final DataComponentType<?> type : referencedComponentTypes) {
|
||||
|
|
Loading…
Reference in a new issue