Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -3,10 +3,10 @@ package org.bukkit.craftbukkit.packs;
import java.io.IOException;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.server.packs.IResourcePack;
import net.minecraft.server.packs.metadata.pack.ResourcePackInfo;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraft.server.packs.repository.ResourcePackLoader;
import net.minecraft.util.InclusiveRange;
import org.bukkit.Bukkit;
import org.bukkit.FeatureFlag;
@@ -18,24 +18,24 @@ import org.bukkit.packs.DataPack;
public class CraftDataPack implements DataPack {
private final ResourcePackLoader handle;
private final ResourcePackInfo resourcePackInfo;
private final Pack handle;
private final PackMetadataSection resourcePackInfo;
public CraftDataPack(ResourcePackLoader handler) {
public CraftDataPack(Pack handler) {
this.handle = handler;
try (IResourcePack iresourcepack = this.handle.resources.openPrimary(this.handle.location())) {
this.resourcePackInfo = iresourcepack.getMetadataSection(ResourcePackInfo.TYPE);
try (PackResources iresourcepack = this.handle.resources.openPrimary(this.handle.location())) {
this.resourcePackInfo = iresourcepack.getMetadataSection(PackMetadataSection.TYPE);
} catch (IOException e) { // This is already called in NMS then if in NMS not happen is secure this not throw here
throw new RuntimeException(e);
}
}
public ResourcePackLoader getHandle() {
public Pack getHandle() {
return this.handle;
}
public String getRawId() {
return getHandle().getId();
return this.getHandle().getId();
}
@Override
@@ -65,7 +65,7 @@ public class CraftDataPack implements DataPack {
@Override
public boolean isRequired() {
return getHandle().isRequired();
return this.getHandle().isRequired();
}
@Override
@@ -79,7 +79,7 @@ public class CraftDataPack implements DataPack {
@Override
public boolean isEnabled() {
return ((CraftServer) Bukkit.getServer()).getServer().getPackRepository().getSelectedIds().contains(getRawId());
return ((CraftServer) Bukkit.getServer()).getServer().getPackRepository().getSelectedIds().contains(this.getRawId());
}
@Override
@@ -103,12 +103,12 @@ public class CraftDataPack implements DataPack {
@Override
public NamespacedKey getKey() {
return NamespacedKey.fromString(getRawId());
return NamespacedKey.fromString(this.getRawId());
}
@Override
public String toString() {
String requestedFeatures = getRequestedFeatures().stream().map(featureFlag -> featureFlag.getKey().toString()).collect(Collectors.joining(","));
String requestedFeatures = this.getRequestedFeatures().stream().map(featureFlag -> featureFlag.getKey().toString()).collect(Collectors.joining(","));
return "CraftDataPack{rawId=" + this.getRawId() + ",id=" + this.getKey() + ",title=" + this.getTitle() + ",description=" + this.getDescription() + ",packformat=" + this.getPackFormat() + ",minSupportedPackFormat=" + this.getMinSupportedPackFormat() + ",maxSupportedPackFormat=" + this.getMaxSupportedPackFormat() + ",compatibility=" + this.getCompatibility() + ",source=" + this.getSource() + ",enabled=" + this.isEnabled() + ",requestedFeatures=[" + requestedFeatures + "]}";
}
}

View File

@@ -4,9 +4,8 @@ import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;
import net.minecraft.server.packs.repository.ResourcePackLoader;
import net.minecraft.server.packs.repository.ResourcePackRepository;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
@@ -22,13 +21,13 @@ import org.bukkit.packs.DataPackManager;
public class CraftDataPackManager implements DataPackManager {
private final ResourcePackRepository handle;
private final PackRepository handle;
public CraftDataPackManager(ResourcePackRepository resourcePackRepository) {
public CraftDataPackManager(PackRepository resourcePackRepository) {
this.handle = resourcePackRepository;
}
public ResourcePackRepository getHandle() {
public PackRepository getHandle() {
return this.handle;
}
@@ -37,7 +36,7 @@ public class CraftDataPackManager implements DataPackManager {
// Based in the command for datapacks need reload for get the updated list of datapacks
this.getHandle().reload();
Collection<ResourcePackLoader> availablePacks = this.getHandle().getAvailablePacks();
Collection<Pack> availablePacks = this.getHandle().getAvailablePacks();
return availablePacks.stream().map(CraftDataPack::new).collect(Collectors.toUnmodifiableList());
}
@@ -54,7 +53,7 @@ public class CraftDataPackManager implements DataPackManager {
CraftWorld craftWorld = ((CraftWorld) world);
return craftWorld.getHandle().serverLevelData.getDataConfiguration().dataPacks().getEnabled().stream().map(packName -> {
ResourcePackLoader resourcePackLoader = this.getHandle().getPack(packName);
Pack resourcePackLoader = this.getHandle().getPack(packName);
if (resourcePackLoader != null) {
return new CraftDataPack(resourcePackLoader);
}
@@ -68,7 +67,7 @@ public class CraftDataPackManager implements DataPackManager {
CraftWorld craftWorld = ((CraftWorld) world);
return craftWorld.getHandle().serverLevelData.getDataConfiguration().dataPacks().getDisabled().stream().map(packName -> {
ResourcePackLoader resourcePackLoader = this.getHandle().getPack(packName);
Pack resourcePackLoader = this.getHandle().getPack(packName);
if (resourcePackLoader != null) {
return new CraftDataPack(resourcePackLoader);
}
@@ -116,7 +115,7 @@ public class CraftDataPackManager implements DataPackManager {
Preconditions.checkArgument(entityType != EntityType.UNKNOWN, "EntityType.UNKNOWN its not allowed here");
CraftWorld craftWorld = ((CraftWorld) world);
EntityTypes<?> nmsEntity = CraftEntityType.bukkitToMinecraft(entityType);
net.minecraft.world.entity.EntityType<?> nmsEntity = CraftEntityType.bukkitToMinecraft(entityType);
return nmsEntity.isEnabled(craftWorld.getHandle().enabledFeatures());
}
}