Update to Minecraft 1.20.5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-04-24 01:15:00 +10:00
parent 4deda9501f
commit 65bc2541a3
524 changed files with 7788 additions and 6181 deletions

View File

@@ -173,6 +173,14 @@ public class Commodore {
}
}
if (owner.equals("org/bukkit/attribute/Attribute")) {
switch (name) {
case "HORSE_JUMP_STRENGTH":
super.visitFieldInsn(opcode, owner, "GENERIC_JUMP_STRENGTH", desc);
return;
}
}
if (owner.equals("org/bukkit/loot/LootTables")) {
switch (name) {
case "ZOMBIE_PIGMAN":
@@ -208,6 +216,9 @@ public class Commodore {
case "GRASS":
name = "SHORT_GRASS";
break;
case "SCUTE":
name = "TURTLE_SCUTE";
break;
}
}
@@ -247,6 +258,9 @@ public class Commodore {
if (owner.equals("org/bukkit/Particle")) {
switch (name) {
case "SPELL_MOB_AMBIENT":
super.visitFieldInsn(opcode, owner, "SPELL_MOB", desc);
return;
case "BLOCK_CRACK":
case "BLOCK_DUST":
case "FALLING_DUST":

View File

@@ -18,6 +18,7 @@ import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.chat.IChatMutableComponent;
import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.server.MinecraftServer;
import org.bukkit.ChatColor;
public final class CraftChatMessage {
@@ -160,6 +161,14 @@ public final class CraftChatMessage {
}
}
public static Optional<IChatBaseComponent> fromStringOrOptional(String message) {
return Optional.ofNullable(fromStringOrNull(message));
}
public static Optional<IChatBaseComponent> fromStringOrOptional(String message, boolean keepNewlines) {
return Optional.ofNullable(fromStringOrNull(message, keepNewlines));
}
public static IChatBaseComponent fromStringOrNull(String message) {
return fromStringOrNull(message, false);
}
@@ -181,7 +190,7 @@ public final class CraftChatMessage {
}
public static String toJSON(IChatBaseComponent component) {
return IChatBaseComponent.ChatSerializer.toJson(component);
return IChatBaseComponent.ChatSerializer.toJson(component, MinecraftServer.getDefaultRegistryAccess());
}
public static String toJSONOrNull(IChatBaseComponent component) {
@@ -192,7 +201,7 @@ public final class CraftChatMessage {
public static IChatBaseComponent fromJSON(String jsonMessage) throws JsonParseException {
// Note: This also parses plain Strings to text components.
// Note: An empty message (empty, or only consisting of whitespace) results in null rather than a parse exception.
return IChatBaseComponent.ChatSerializer.fromJson(jsonMessage);
return IChatBaseComponent.ChatSerializer.fromJson(jsonMessage, MinecraftServer.getDefaultRegistryAccess());
}
public static IChatBaseComponent fromJSONOrNull(String jsonMessage) {

View File

@@ -7,6 +7,7 @@ import com.google.common.collect.Multimap;
import com.google.common.io.Files;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.JsonOps;
@@ -17,18 +18,16 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.SharedConstants;
import net.minecraft.SystemUtils;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.commands.CommandDispatcher;
import net.minecraft.commands.arguments.item.ArgumentParserItemStack;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.MojangsonParser;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.server.AdvancementDataWorld;
@@ -36,9 +35,9 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.datafix.DataConverterRegistry;
import net.minecraft.util.datafix.fixes.DataConverterTypes;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.ai.attributes.AttributeBase;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.alchemy.PotionRegistry;
import net.minecraft.world.item.component.ItemAttributeModifiers;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.storage.SavedFile;
@@ -228,7 +227,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string
*/
public String getMappingsVersion() {
return "60a2bb6bf2684dc61c56b90d7c41bddc";
return "ad1a88fd7eaf2277f2507bf34d7b994c";
}
@Override
@@ -241,7 +240,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack);
try {
nmsStack.setTag((NBTTagCompound) MojangsonParser.parseTag(arguments));
nmsStack.applyComponents(new ArgumentParserItemStack(CommandDispatcher.createValidationContext(MinecraftServer.getDefaultRegistryAccess())).parse(new StringReader(arguments)).components());
} catch (CommandSyntaxException ex) {
Logger.getLogger(CraftMagicNumbers.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -261,7 +260,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
MinecraftKey minecraftkey = CraftNamespacedKey.toMinecraft(key);
JsonElement jsonelement = AdvancementDataWorld.GSON.fromJson(advancement, JsonElement.class);
net.minecraft.advancements.Advancement nms = SystemUtils.getOrThrow(net.minecraft.advancements.Advancement.CODEC.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
net.minecraft.advancements.Advancement nms = net.minecraft.advancements.Advancement.CODEC.parse(JsonOps.INSTANCE, jsonelement).getOrThrow(JsonParseException::new);
if (nms != null) {
MinecraftServer.getServer().getAdvancements().advancements.put(minecraftkey, new AdvancementHolder(minecraftkey, nms));
Advancement bukkit = Bukkit.getAdvancement(key);
@@ -337,11 +336,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(Material material, EquipmentSlot slot) {
ImmutableMultimap.Builder<Attribute, AttributeModifier> defaultAttributes = ImmutableMultimap.builder();
Multimap<AttributeBase, net.minecraft.world.entity.ai.attributes.AttributeModifier> nmsDefaultAttributes = getItem(material).getDefaultAttributeModifiers(CraftEquipmentSlot.getNMS(slot));
for (Entry<AttributeBase, net.minecraft.world.entity.ai.attributes.AttributeModifier> mapEntry : nmsDefaultAttributes.entries()) {
Attribute attribute = CraftAttribute.minecraftToBukkit(mapEntry.getKey());
defaultAttributes.put(attribute, CraftAttributeInstance.convert(mapEntry.getValue(), slot));
}
ItemAttributeModifiers nmsDefaultAttributes = getItem(material).getDefaultAttributeModifiers();
nmsDefaultAttributes.forEach(CraftEquipmentSlot.getNMS(slot), (key, value) -> {
Attribute attribute = CraftAttribute.minecraftToBukkit(key.value());
defaultAttributes.put(attribute, CraftAttributeInstance.convert(value, slot));
});
return defaultAttributes.build();
}

View File

@@ -39,9 +39,9 @@ import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.entity.TileEntityTypes;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.level.chunk.IChunkProvider;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.dimension.DimensionManager;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.level.gameevent.GameEvent;
@@ -56,7 +56,6 @@ import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.ticks.LevelTickAccess;
import net.minecraft.world.ticks.NextTickListEntry;
import net.minecraft.world.ticks.TickListPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
@@ -187,16 +186,6 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed {
return handle.nextSubTickCount();
}
@Override
public <T> NextTickListEntry<T> createTick(BlockPosition arg0, T arg1, int arg2) {
return handle.createTick(arg0, arg1, arg2);
}
@Override
public <T> NextTickListEntry<T> createTick(BlockPosition arg0, T arg1, int arg2, TickListPriority arg3) {
return handle.createTick(arg0, arg1, arg2, arg3);
}
@Override
public LevelTickAccess<FluidType> getFluidTicks() {
return handle.getFluidTicks();
@@ -228,22 +217,22 @@ public abstract class DelegatedGeneratorAccess implements GeneratorAccessSeed {
}
@Override
public void gameEvent(GameEvent arg0, Vec3D arg1, GameEvent.a arg2) {
public void gameEvent(Holder<GameEvent> arg0, Vec3D arg1, GameEvent.a arg2) {
handle.gameEvent(arg0, arg1, arg2);
}
@Override
public void gameEvent(GameEvent arg0, BlockPosition arg1, GameEvent.a arg2) {
public void gameEvent(Holder<GameEvent> arg0, BlockPosition arg1, GameEvent.a arg2) {
handle.gameEvent(arg0, arg1, arg2);
}
@Override
public void gameEvent(Entity arg0, GameEvent arg1, BlockPosition arg2) {
public void gameEvent(Entity arg0, Holder<GameEvent> arg1, BlockPosition arg2) {
handle.gameEvent(arg0, arg1, arg2);
}
@Override
public void gameEvent(Entity arg0, GameEvent arg1, Vec3D arg2) {
public void gameEvent(Entity arg0, Holder<GameEvent> arg1, Vec3D arg2) {
handle.gameEvent(arg0, arg1, arg2);
}

View File

@@ -24,9 +24,9 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.level.chunk.IChunkProvider;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.dimension.DimensionManager;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.level.gameevent.GameEvent;
@@ -119,7 +119,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
}
@Override
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
public void gameEvent(Holder<GameEvent> gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
// Used by BlockComposter
}

View File

@@ -72,7 +72,7 @@ public class TransformerGeneratorAccess extends DelegatedGeneratorAccess {
}
TileEntity tileEntity = getBlockEntity(position);
if (tileEntity != null && craftBlockState instanceof CraftBlockEntityState<?> craftEntityState) {
tileEntity.load(craftEntityState.getSnapshotNBT());
tileEntity.loadWithComponents(craftEntityState.getSnapshotNBT(), this.registryAccess());
}
return result;
}
@@ -86,7 +86,7 @@ public class TransformerGeneratorAccess extends DelegatedGeneratorAccess {
if (structureTransformer == null || !structureTransformer.canTransformBlocks()) {
return super.setBlock(position, iblockdata, i, j);
}
return setCraftBlock(position, (CraftBlockState) CraftBlockStates.getBlockState(position, iblockdata, null), i, j);
return setCraftBlock(position, (CraftBlockState) CraftBlockStates.getBlockState(this, position, iblockdata, null), i, j);
}
@Override