mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-12-03 11:52:14 +00:00
Removed already migrated code
This commit is contained in:
1 parent
6b38537d63
commit
bef99469a0
4 files changed
-184
No files matched your search
@@ -1,10 +0,0 @@
|
|||||||
package com.dfsek.terra.bukkit.nms;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.properties.Properties;
|
|
||||||
|
|
||||||
|
|
||||||
public record NMSBiomeInfo(ResourceKey<Biome> biomeKey) implements Properties {
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.dfsek.terra.bukkit.nms;
|
|
||||||
|
|
||||||
import com.mojang.serialization.MapCodec;
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
|
||||||
import net.minecraft.world.level.biome.Climate.Sampler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
|
||||||
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
|
||||||
|
|
||||||
|
|
||||||
public class NMSBiomeProvider extends BiomeSource {
|
|
||||||
private final BiomeProvider delegate;
|
|
||||||
private final long seed;
|
|
||||||
private final Registry<Biome> biomeRegistry = RegistryFetcher.biomeRegistry();
|
|
||||||
|
|
||||||
public NMSBiomeProvider(BiomeProvider delegate, long seed) {
|
|
||||||
super();
|
|
||||||
this.delegate = delegate;
|
|
||||||
this.seed = seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
|
||||||
return delegate.stream()
|
|
||||||
.map(biome -> RegistryFetcher.biomeRegistry()
|
|
||||||
.getOrThrow(((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
|
|
||||||
.get(NMSBiomeInfo.class)
|
|
||||||
.biomeKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected @NotNull MapCodec<? extends BiomeSource> codec() {
|
|
||||||
return MapCodec.assumeMapUnsafe(BiomeSource.CODEC);
|
|
||||||
// return MapCodec.unit(null);
|
|
||||||
// BuiltInRegistries.BIOME_SOURCE.byNameCodec().dispatchMap(this::codec, Function.identity());
|
|
||||||
// BuiltInRegistries.BIOME_SOURCE.byNameCodec().dispatchStable(BiomeSource::codec, Function.identity());
|
|
||||||
// return BiomeSource.CODEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Holder<Biome> getNoiseBiome(int x, int y, int z, @NotNull Sampler sampler) {
|
|
||||||
return biomeRegistry.getOrThrow(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed)
|
|
||||||
.getPlatformBiome()).getContext()
|
|
||||||
.get(NMSBiomeInfo.class)
|
|
||||||
.biomeKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +1,28 @@
|
|||||||
package com.dfsek.terra.bukkit.nms;
|
package com.dfsek.terra.bukkit.nms;
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.Holder.Reference;
|
|
||||||
import net.minecraft.core.HolderSet;
|
|
||||||
import net.minecraft.core.MappedRegistry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.entity.npc.villager.VillagerType;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.StructureManager;
|
import net.minecraft.world.level.StructureManager;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
import net.minecraft.world.level.chunk.status.WorldGenContext;
|
import net.minecraft.world.level.chunk.status.WorldGenContext;
|
||||||
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.ReflectionProxyFactory;
|
import xyz.jpenilla.reflectionremapper.proxy.ReflectionProxyFactory;
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldGetter;
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldGetter;
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldSetter;
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldSetter;
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.MethodName;
|
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.Proxies;
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.Proxies;
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.Static;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
public class Reflection {
|
public class Reflection {
|
||||||
public static final MappedRegistryProxy MAPPED_REGISTRY;
|
|
||||||
public static final MappedRegistryTagSetProxy MAPPED_REGISTRY_TAG_SET;
|
|
||||||
public static final StructureManagerProxy STRUCTURE_MANAGER;
|
public static final StructureManagerProxy STRUCTURE_MANAGER;
|
||||||
|
|
||||||
public static final ReferenceProxy REFERENCE;
|
|
||||||
|
|
||||||
|
|
||||||
public static final ChunkMapProxy CHUNKMAP;
|
public static final ChunkMapProxy CHUNKMAP;
|
||||||
public static final HolderReferenceProxy HOLDER_REFERENCE;
|
|
||||||
public static final HolderSetNamedProxy HOLDER_SET;
|
|
||||||
public static final BiomeProxy BIOME;
|
|
||||||
public static final VillagerTypeProxy VILLAGER_TYPE;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
||||||
ReflectionProxyFactory reflectionProxyFactory = ReflectionProxyFactory.create(reflectionRemapper,
|
ReflectionProxyFactory reflectionProxyFactory = ReflectionProxyFactory.create(reflectionRemapper,
|
||||||
Reflection.class.getClassLoader());
|
Reflection.class.getClassLoader());
|
||||||
|
|
||||||
MAPPED_REGISTRY = reflectionProxyFactory.reflectionProxy(MappedRegistryProxy.class);
|
|
||||||
MAPPED_REGISTRY_TAG_SET = reflectionProxyFactory.reflectionProxy(MappedRegistryTagSetProxy.class);
|
|
||||||
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
||||||
REFERENCE = reflectionProxyFactory.reflectionProxy(ReferenceProxy.class);
|
|
||||||
CHUNKMAP = reflectionProxyFactory.reflectionProxy(ChunkMapProxy.class);
|
CHUNKMAP = reflectionProxyFactory.reflectionProxy(ChunkMapProxy.class);
|
||||||
HOLDER_REFERENCE = reflectionProxyFactory.reflectionProxy(HolderReferenceProxy.class);
|
|
||||||
HOLDER_SET = reflectionProxyFactory.reflectionProxy(HolderSetNamedProxy.class);
|
|
||||||
BIOME = reflectionProxyFactory.reflectionProxy(BiomeProxy.class);
|
|
||||||
VILLAGER_TYPE = reflectionProxyFactory.reflectionProxy(VillagerTypeProxy.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Proxies(MappedRegistry.class)
|
|
||||||
public interface MappedRegistryProxy {
|
|
||||||
@FieldGetter("byKey")
|
|
||||||
<T> Map<ResourceKey<T>, Reference<T>> getByKey(MappedRegistry<T> instance);
|
|
||||||
|
|
||||||
@FieldSetter("allTags")
|
|
||||||
<T> void setAllTags(MappedRegistry<T> instance, Object obj);
|
|
||||||
|
|
||||||
@FieldSetter("frozen")
|
|
||||||
void setFrozen(MappedRegistry<?> instance, boolean frozen);
|
|
||||||
|
|
||||||
@MethodName("createTag")
|
|
||||||
<T> HolderSet.Named<T> invokeCreateTag(MappedRegistry<T> instance, TagKey<T> tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Proxies(className = "net.minecraft.core.MappedRegistry$TagSet")
|
|
||||||
public interface MappedRegistryTagSetProxy {
|
|
||||||
@MethodName("fromMap")
|
|
||||||
@Static
|
|
||||||
<T> Object invokeFromMap(Map<TagKey<T>, HolderSet.Named<T>> map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,16 +33,6 @@ public class Reflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Proxies(Holder.Reference.class)
|
|
||||||
public interface ReferenceProxy {
|
|
||||||
@MethodName("bindValue")
|
|
||||||
<T> void invokeBindValue(Reference<T> instance, T value);
|
|
||||||
|
|
||||||
@MethodName("bindTags")
|
|
||||||
<T> void invokeBindTags(Reference<T> instance, Collection<TagKey<T>> tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Proxies(ChunkMap.class)
|
@Proxies(ChunkMap.class)
|
||||||
public interface ChunkMapProxy {
|
public interface ChunkMapProxy {
|
||||||
@FieldGetter("worldGenContext")
|
@FieldGetter("worldGenContext")
|
||||||
@@ -105,36 +41,4 @@ public class Reflection {
|
|||||||
@FieldSetter("worldGenContext")
|
@FieldSetter("worldGenContext")
|
||||||
void setWorldGenContext(ChunkMap instance, WorldGenContext worldGenContext);
|
void setWorldGenContext(ChunkMap instance, WorldGenContext worldGenContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Proxies(Holder.Reference.class)
|
|
||||||
public interface HolderReferenceProxy {
|
|
||||||
@MethodName("bindTags")
|
|
||||||
<T> void invokeBindTags(Holder.Reference<T> instance, Collection<TagKey<T>> tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Proxies(HolderSet.Named.class)
|
|
||||||
public interface HolderSetNamedProxy {
|
|
||||||
@MethodName("bind")
|
|
||||||
<T> void invokeBind(HolderSet.Named<T> instance, List<Holder<T>> entries);
|
|
||||||
|
|
||||||
@MethodName("contents")
|
|
||||||
<T> List<Holder<T>> invokeContents(HolderSet.Named<T> instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Proxies(Biome.class)
|
|
||||||
public interface BiomeProxy {
|
|
||||||
@MethodName("getGrassColorFromTexture")
|
|
||||||
int invokeGrassColorFromTexture(Biome instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Proxies(VillagerType.class)
|
|
||||||
public interface VillagerTypeProxy {
|
|
||||||
@Static
|
|
||||||
@FieldGetter("BY_BIOME")
|
|
||||||
Map<ResourceKey<Biome>, ResourceKey<VillagerType>> getByBiome();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.dfsek.terra.bukkit.nms;
|
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
|
|
||||||
|
|
||||||
public class RegistryFetcher {
|
|
||||||
private static <T> Registry<T> getRegistry(ResourceKey<Registry<T>> key) {
|
|
||||||
return MinecraftServer.getServer()
|
|
||||||
.registryAccess()
|
|
||||||
.lookupOrThrow(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Registry<Biome> biomeRegistry() {
|
|
||||||
return getRegistry(Registries.BIOME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Registry<SoundEvent> soundEventRegistry() {
|
|
||||||
return getRegistry(Registries.SOUND_EVENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user