mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
Merge remote-tracking branch 'origin/ver/6.6.0' into dev/7.0-2
This commit is contained in:
@@ -9,28 +9,27 @@ object Versions {
|
|||||||
const val strata = "1.3.2"
|
const val strata = "1.3.2"
|
||||||
|
|
||||||
const val cloud = "2.0.0"
|
const val cloud = "2.0.0"
|
||||||
const val cloudPaper = "2.0.0-beta.10"
|
|
||||||
const val cloudFabric = "2.0.0-beta.9"
|
|
||||||
|
|
||||||
const val caffeine = "3.1.8"
|
const val caffeine = "3.1.8"
|
||||||
|
|
||||||
const val slf4j = "2.0.16"
|
const val slf4j = "2.0.16"
|
||||||
|
|
||||||
object Internal {
|
object Internal {
|
||||||
const val shadow = "8.3.1"
|
const val shadow = "8.3.3"
|
||||||
const val apacheText = "1.12.0"
|
const val apacheText = "1.12.0"
|
||||||
const val apacheIO = "2.16.1"
|
const val apacheIO = "2.17.0"
|
||||||
const val guava = "33.3.0-jre"
|
const val guava = "33.3.1-jre"
|
||||||
const val asm = "9.7"
|
const val asm = "9.7.1"
|
||||||
const val snakeYml = "2.3"
|
const val snakeYml = "2.3"
|
||||||
const val jetBrainsAnnotations = "24.1.0"
|
const val jetBrainsAnnotations = "26.0.1"
|
||||||
const val junit = "5.11.0"
|
const val junit = "5.11.3"
|
||||||
const val nbt = "6.1"
|
const val nbt = "6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object Fabric {
|
object Fabric {
|
||||||
const val fabricAPI = "0.104.0+${Mod.minecraft}"
|
const val fabricAPI = "0.106.1+${Mod.minecraft}"
|
||||||
|
const val cloud = "2.0.0-beta.9"
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// object Quilt {
|
// object Quilt {
|
||||||
@@ -41,12 +40,13 @@ object Versions {
|
|||||||
object Mod {
|
object Mod {
|
||||||
const val mixin = "0.15.3+mixin.0.8.7"
|
const val mixin = "0.15.3+mixin.0.8.7"
|
||||||
|
|
||||||
const val minecraft = "1.21.1"
|
const val minecraft = "1.21.3"
|
||||||
const val yarn = "$minecraft+build.3"
|
const val yarn = "$minecraft+build.2"
|
||||||
const val fabricLoader = "0.16.5"
|
const val fabricLoader = "0.16.7"
|
||||||
|
|
||||||
const val architecuryLoom = "1.7.413"
|
const val architecuryLoom = "1.7.413"
|
||||||
const val architecturyPlugin = "3.4.159"
|
const val architecturyPlugin = "3.4.159"
|
||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// object Forge {
|
// object Forge {
|
||||||
@@ -55,14 +55,15 @@ object Versions {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
object Bukkit {
|
object Bukkit {
|
||||||
const val minecraft = "1.21.1"
|
const val minecraft = "1.21.3"
|
||||||
const val paperBuild = "$minecraft-R0.1-20240917.151311-80"
|
const val paperBuild = "$minecraft-R0.1-20241025.163321-1"
|
||||||
const val paper = paperBuild
|
const val paper = paperBuild
|
||||||
const val paperLib = "1.0.8"
|
const val paperLib = "1.0.8"
|
||||||
const val reflectionRemapper = "0.1.1"
|
const val reflectionRemapper = "0.1.1"
|
||||||
const val paperDevBundle = paperBuild
|
const val paperDevBundle = paperBuild
|
||||||
const val runPaper = "2.3.1"
|
const val runPaper = "2.3.1"
|
||||||
const val paperWeight = "1.7.2"
|
const val paperWeight = "1.7.2"
|
||||||
|
const val cloud = "2.0.0-beta.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
+1
-6
@@ -8,7 +8,6 @@
|
|||||||
package com.dfsek.terra.addons.palette;
|
package com.dfsek.terra.addons.palette;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.palette.palette.PaletteImpl;
|
import com.dfsek.terra.addons.palette.palette.PaletteImpl;
|
||||||
import com.dfsek.terra.addons.palette.palette.PaletteLayerHolder;
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.config.ConfigFactory;
|
import com.dfsek.terra.api.config.ConfigFactory;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||||
@@ -17,10 +16,6 @@ import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
|||||||
public class PaletteFactory implements ConfigFactory<PaletteTemplate, Palette> {
|
public class PaletteFactory implements ConfigFactory<PaletteTemplate, Palette> {
|
||||||
@Override
|
@Override
|
||||||
public Palette build(PaletteTemplate config, Platform platform) {
|
public Palette build(PaletteTemplate config, Platform platform) {
|
||||||
PaletteImpl palette = new PaletteImpl(config.getNoise());
|
return new PaletteImpl(config.getPalette(), config.getDefaultSampler());
|
||||||
for(PaletteLayerHolder layer : config.getPalette()) {
|
|
||||||
palette.add(layer.getLayer(), layer.getSize(), layer.getSampler());
|
|
||||||
}
|
|
||||||
return palette;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -23,7 +23,7 @@ import com.dfsek.terra.api.noise.NoiseSampler;
|
|||||||
public class PaletteTemplate implements AbstractableTemplate {
|
public class PaletteTemplate implements AbstractableTemplate {
|
||||||
@Value("sampler")
|
@Value("sampler")
|
||||||
@Default
|
@Default
|
||||||
private @Meta NoiseSampler noise = NoiseSampler.zero();
|
private @Meta NoiseSampler defaultSampler = NoiseSampler.zero();
|
||||||
|
|
||||||
@Value("id")
|
@Value("id")
|
||||||
@Final
|
@Final
|
||||||
@@ -40,7 +40,7 @@ public class PaletteTemplate implements AbstractableTemplate {
|
|||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoiseSampler getNoise() {
|
public NoiseSampler getDefaultSampler() {
|
||||||
return noise;
|
return defaultSampler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-45
@@ -15,73 +15,45 @@ import com.dfsek.terra.api.noise.NoiseSampler;
|
|||||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representation of a "slice" of the world.
|
* A class representation of a "slice" of the world.
|
||||||
* Used to get a section of blocks, based on the depth at which they are found.
|
* Used to get a section of blocks, based on the depth at which they are found.
|
||||||
*/
|
*/
|
||||||
public class PaletteImpl implements Palette {
|
public class PaletteImpl implements Palette {
|
||||||
private final List<PaletteLayer> pallet = new ArrayList<>();
|
private final PaletteLayer[] layers;
|
||||||
private final NoiseSampler sampler;
|
|
||||||
|
|
||||||
public PaletteImpl(NoiseSampler sampler) {
|
public PaletteImpl(List<PaletteLayerHolder> layers, NoiseSampler defaultSampler) {
|
||||||
this.sampler = sampler;
|
List<PaletteLayer> layerArray = new ArrayList<>();
|
||||||
}
|
|
||||||
|
|
||||||
public Palette add(ProbabilityCollection<BlockState> m, int layers, NoiseSampler sampler) {
|
for (PaletteLayerHolder holder : layers) {
|
||||||
for(int i = 0; i < layers; i++) {
|
PaletteLayer layer;
|
||||||
pallet.add(new PaletteLayer(m, sampler));
|
ProbabilityCollection<BlockState> materials = holder.getLayer();
|
||||||
|
NoiseSampler sampler = holder.getSampler() == null ? defaultSampler : holder.getSampler();
|
||||||
|
layer = new PaletteLayer(materials, sampler);
|
||||||
|
for (int i = 0; i < holder.getSize(); i++)
|
||||||
|
layerArray.add(layer);
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
|
this.layers = layerArray.toArray(new PaletteLayer[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState get(int layer, double x, double y, double z, long seed) {
|
public BlockState get(int layer, double x, double y, double z, long seed) {
|
||||||
PaletteLayer paletteLayer;
|
int idx = layer < layers.length ? layer : layers.length - 1;
|
||||||
if(layer > this.getSize()) paletteLayer = this.getLayers().get(this.getLayers().size() - 1);
|
return layers[idx].get(x, y, z, seed);
|
||||||
else {
|
|
||||||
List<PaletteLayer> pl = getLayers();
|
|
||||||
if(layer >= pl.size()) paletteLayer = pl.get(pl.size() - 1);
|
|
||||||
else paletteLayer = pl.get(layer);
|
|
||||||
}
|
|
||||||
NoiseSampler paletteSampler = paletteLayer.getSampler();
|
|
||||||
return paletteLayer.get(paletteSampler == null ? sampler : paletteSampler, x, y, z, seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class PaletteLayer {
|
||||||
public int getSize() {
|
|
||||||
return pallet.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PaletteLayer> getLayers() {
|
|
||||||
return pallet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class representation of a layer of a BlockPalette.
|
|
||||||
*/
|
|
||||||
public static class PaletteLayer {
|
|
||||||
private final NoiseSampler sampler;
|
private final NoiseSampler sampler;
|
||||||
private final ProbabilityCollection<BlockState> collection;
|
private final ProbabilityCollection<BlockState> collection;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a PaletteLayerHolder with a ProbabilityCollection of materials and a number of layers.
|
|
||||||
*
|
|
||||||
* @param type The collection of materials to choose from.
|
|
||||||
* @param sampler Noise sampler to use
|
|
||||||
*/
|
|
||||||
public PaletteLayer(ProbabilityCollection<BlockState> type, NoiseSampler sampler) {
|
public PaletteLayer(ProbabilityCollection<BlockState> type, NoiseSampler sampler) {
|
||||||
this.sampler = sampler;
|
this.sampler = sampler;
|
||||||
this.collection = type;
|
this.collection = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState get(NoiseSampler random, double x, double y, double z, long seed) {
|
public BlockState get(double x, double y, double z, long seed) {
|
||||||
return this.collection.get(random, x, y, z, seed);
|
return this.collection.get(sampler, x, y, z, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoiseSampler getSampler() {
|
|
||||||
return sampler;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-8
@@ -43,23 +43,27 @@ public class ProbabilityCollectionLoader implements TypeLoader<ProbabilityCollec
|
|||||||
AnnotatedType generic = pType.getAnnotatedActualTypeArguments()[0];
|
AnnotatedType generic = pType.getAnnotatedActualTypeArguments()[0];
|
||||||
if(o instanceof Map) {
|
if(o instanceof Map) {
|
||||||
Map<Object, Object> map = (Map<Object, Object>) o;
|
Map<Object, Object> map = (Map<Object, Object>) o;
|
||||||
|
if (map.size() == 1) {
|
||||||
|
Object onlyKey = map.keySet().iterator().next();
|
||||||
|
return new ProbabilityCollection.Singleton<>(configLoader.loadType(generic, onlyKey, depthTracker));
|
||||||
|
}
|
||||||
for(Map.Entry<Object, Object> entry : map.entrySet()) {
|
for(Map.Entry<Object, Object> entry : map.entrySet()) {
|
||||||
collection.add(configLoader.loadType(generic, entry.getKey(), depthTracker.entry((String) entry.getKey())),
|
collection.add(configLoader.loadType(generic, entry.getKey(), depthTracker.entry((String) entry.getKey())),
|
||||||
configLoader.loadType(Integer.class, entry.getValue(), depthTracker.entry((String) entry.getKey())));
|
configLoader.loadType(Integer.class, entry.getValue(), depthTracker.entry((String) entry.getKey())));
|
||||||
}
|
}
|
||||||
} else if(o instanceof List) {
|
} else if(o instanceof List) {
|
||||||
List<Map<Object, Object>> map = (List<Map<Object, Object>>) o;
|
List<Map<Object, Object>> list = (List<Map<Object, Object>>) o;
|
||||||
if(map.size() == 1) {
|
if(list.size() == 1) {
|
||||||
Map<Object, Object> entry = map.get(0);
|
Map<Object, Object> map = list.getFirst();
|
||||||
if(entry.size() == 1) {
|
if(map.size() == 1) {
|
||||||
for(Object value : entry.keySet()) {
|
for(Object value : map.keySet()) {
|
||||||
return new ProbabilityCollection.Singleton<>(configLoader.loadType(generic, value, depthTracker));
|
return new ProbabilityCollection.Singleton<>(configLoader.loadType(generic, value, depthTracker));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < map.size(); i++) {
|
for(int i = 0; i < list.size(); i++) {
|
||||||
Map<Object, Object> l = map.get(i);
|
Map<Object, Object> map = list.get(i);
|
||||||
for(Entry<Object, Object> entry : l.entrySet()) {
|
for(Entry<Object, Object> entry : map.entrySet()) {
|
||||||
if(entry.getValue() == null) throw new LoadException("No probability defined for entry \"" + entry.getKey() + "\"",
|
if(entry.getValue() == null) throw new LoadException("No probability defined for entry \"" + entry.getKey() + "\"",
|
||||||
depthTracker);
|
depthTracker);
|
||||||
Object val = configLoader.loadType(generic, entry.getKey(), depthTracker.index(i).entry((String) entry.getKey()));
|
Object val = configLoader.loadType(generic, entry.getKey(), depthTracker.index(i).entry((String) entry.getKey()));
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
|
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -84,7 +86,8 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|||||||
Vendored
+2
@@ -13,6 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ dependencies {
|
|||||||
|
|
||||||
shadedApi("com.google.guava", "guava", Versions.Libraries.Internal.guava)
|
shadedApi("com.google.guava", "guava", Versions.Libraries.Internal.guava)
|
||||||
|
|
||||||
shadedApi("org.incendo", "cloud-paper", Versions.Libraries.cloudPaper)
|
shadedApi("org.incendo", "cloud-paper", Versions.Bukkit.cloud)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -19,7 +19,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
||||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||||
@@ -43,7 +42,7 @@ public class AwfulBukkitHacks {
|
|||||||
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
||||||
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
|
ResourceLocation vanillaMinecraftKey = ResourceLocation.fromNamespaceAndPath(vanillaBukkitKey.getNamespace(),
|
||||||
vanillaBukkitKey.getKey());
|
vanillaBukkitKey.getKey());
|
||||||
Biome platform = NMSBiomeInjector.createBiome(biome, Objects.requireNonNull(biomeRegistry.get(vanillaMinecraftKey)));
|
Biome platform = NMSBiomeInjector.createBiome(biome, biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value());
|
||||||
|
|
||||||
ResourceKey<Biome> delegateKey = ResourceKey.create(
|
ResourceKey<Biome> delegateKey = ResourceKey.create(
|
||||||
Registries.BIOME,
|
Registries.BIOME,
|
||||||
@@ -70,7 +69,7 @@ public class AwfulBukkitHacks {
|
|||||||
.getTags() // streamKeysAndEntries
|
.getTags() // streamKeysAndEntries
|
||||||
.collect(HashMap::new,
|
.collect(HashMap::new,
|
||||||
(map, pair) ->
|
(map, pair) ->
|
||||||
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
map.put(pair.key(), new ArrayList<>(Reflection.HOLDER_SET.invokeContents(pair).stream().toList())),
|
||||||
HashMap::putAll);
|
HashMap::putAll);
|
||||||
|
|
||||||
terraBiomeMap
|
terraBiomeMap
|
||||||
@@ -91,8 +90,8 @@ public class AwfulBukkitHacks {
|
|||||||
() -> LOGGER.error("No such biome: {}", tb))),
|
() -> LOGGER.error("No such biome: {}", tb))),
|
||||||
() -> LOGGER.error("No vanilla biome: {}", vb)));
|
() -> LOGGER.error("No vanilla biome: {}", vb)));
|
||||||
|
|
||||||
biomeRegistry.resetTags();
|
((MappedRegistry<Biome>) biomeRegistry).bindAllTagsToEmpty();
|
||||||
biomeRegistry.bindTags(ImmutableMap.copyOf(collect));
|
ImmutableMap.copyOf(collect).forEach(biomeRegistry::bindTag);
|
||||||
|
|
||||||
} catch(SecurityException | IllegalArgumentException exception) {
|
} catch(SecurityException | IllegalArgumentException exception) {
|
||||||
throw new RuntimeException(exception);
|
throw new RuntimeException(exception);
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public class NMSBiomeInjector {
|
|||||||
public static <T> Optional<Holder<T>> getEntry(Registry<T> registry, ResourceLocation identifier) {
|
public static <T> Optional<Holder<T>> getEntry(Registry<T> registry, ResourceLocation identifier) {
|
||||||
return registry.getOptional(identifier)
|
return registry.getOptional(identifier)
|
||||||
.flatMap(registry::getResourceKey)
|
.flatMap(registry::getResourceKey)
|
||||||
.flatMap(registry::getHolder);
|
.flatMap(registry::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Biome createBiome(com.dfsek.terra.api.world.biome.Biome biome, Biome vanilla)
|
public static Biome createBiome(com.dfsek.terra.api.world.biome.Biome biome, Biome vanilla)
|
||||||
|
|||||||
+2
-2
@@ -29,7 +29,7 @@ public class NMSBiomeProvider extends BiomeSource {
|
|||||||
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
||||||
return delegate.stream()
|
return delegate.stream()
|
||||||
.map(biome -> RegistryFetcher.biomeRegistry()
|
.map(biome -> RegistryFetcher.biomeRegistry()
|
||||||
.getHolderOrThrow(((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
|
.getOrThrow(((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
|
||||||
.get(NMSBiomeInfo.class)
|
.get(NMSBiomeInfo.class)
|
||||||
.biomeKey()));
|
.biomeKey()));
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public class NMSBiomeProvider extends BiomeSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Holder<Biome> getNoiseBiome(int x, int y, int z, @NotNull Sampler sampler) {
|
public @NotNull Holder<Biome> getNoiseBiome(int x, int y, int z, @NotNull Sampler sampler) {
|
||||||
return biomeRegistry.getHolderOrThrow(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed)
|
return biomeRegistry.getOrThrow(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed)
|
||||||
.getPlatformBiome()).getContext()
|
.getPlatformBiome()).getContext()
|
||||||
.get(NMSBiomeInfo.class)
|
.get(NMSBiomeInfo.class)
|
||||||
.biomeKey());
|
.biomeKey());
|
||||||
|
|||||||
+1
-2
@@ -15,7 +15,6 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
|||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.level.levelgen.Beardifier;
|
import net.minecraft.world.level.levelgen.Beardifier;
|
||||||
import net.minecraft.world.level.levelgen.DensityFunction.SinglePointContext;
|
import net.minecraft.world.level.levelgen.DensityFunction.SinglePointContext;
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep.Carving;
|
|
||||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||||
import net.minecraft.world.level.levelgen.RandomState;
|
import net.minecraft.world.level.levelgen.RandomState;
|
||||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||||
@@ -59,7 +58,7 @@ public class NMSChunkGeneratorDelegate extends ChunkGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyCarvers(@NotNull WorldGenRegion chunkRegion, long seed, @NotNull RandomState noiseConfig, @NotNull BiomeManager world,
|
public void applyCarvers(@NotNull WorldGenRegion chunkRegion, long seed, @NotNull RandomState noiseConfig, @NotNull BiomeManager world,
|
||||||
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk, @NotNull Carving carverStep) {
|
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk) {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-13
@@ -41,19 +41,15 @@ public class NMSInjectListener implements Listener {
|
|||||||
ChunkGenerator vanilla = serverWorld.getChunkSource().getGenerator();
|
ChunkGenerator vanilla = serverWorld.getChunkSource().getGenerator();
|
||||||
NMSBiomeProvider provider = new NMSBiomeProvider(pack.getBiomeProvider(), craftWorld.getSeed());
|
NMSBiomeProvider provider = new NMSBiomeProvider(pack.getBiomeProvider(), craftWorld.getSeed());
|
||||||
ChunkMap chunkMap = serverWorld.getChunkSource().chunkMap;
|
ChunkMap chunkMap = serverWorld.getChunkSource().chunkMap;
|
||||||
WorldGenContext worldGenContext = chunkMap.worldGenContext;
|
WorldGenContext worldGenContext = Reflection.CHUNKMAP.getWorldGenContext(chunkMap);
|
||||||
|
Reflection.CHUNKMAP.setWorldGenContext(chunkMap, new WorldGenContext(
|
||||||
try {
|
worldGenContext.level(),
|
||||||
ReflectionUtil.setFinalField(chunkMap, "worldGenContext", new WorldGenContext(
|
new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed()),
|
||||||
worldGenContext.level(),
|
worldGenContext.structureManager(),
|
||||||
new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed()),
|
worldGenContext.lightEngine(),
|
||||||
worldGenContext.structureManager(),
|
worldGenContext.mainThreadExecutor(),
|
||||||
worldGenContext.lightEngine(),
|
worldGenContext.unsavedListener()
|
||||||
worldGenContext.mainThreadMailBox()
|
));
|
||||||
));
|
|
||||||
} catch(NoSuchFieldException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.info("Successfully injected into world.");
|
LOGGER.info("Successfully injected into world.");
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -26,11 +26,11 @@ public class NMSWorldProperties implements WorldProperties {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return height.getMaxBuildHeight();
|
return height.getMaxY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinHeight() {
|
public int getMinHeight() {
|
||||||
return height.getMinBuildHeight();
|
return height.getMinY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
@@ -2,9 +2,12 @@ package com.dfsek.terra.bukkit.nms.v1_21;
|
|||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Holder.Reference;
|
import net.minecraft.core.Holder.Reference;
|
||||||
|
import net.minecraft.core.HolderSet;
|
||||||
import net.minecraft.core.MappedRegistry;
|
import net.minecraft.core.MappedRegistry;
|
||||||
|
import net.minecraft.server.level.ChunkMap;
|
||||||
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.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;
|
||||||
@@ -12,6 +15,8 @@ import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldSetter;
|
|||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.MethodName;
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.MethodName;
|
||||||
import xyz.jpenilla.reflectionremapper.proxy.annotation.Proxies;
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.Proxies;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class Reflection {
|
public class Reflection {
|
||||||
public static final MappedRegistryProxy MAPPED_REGISTRY;
|
public static final MappedRegistryProxy MAPPED_REGISTRY;
|
||||||
@@ -19,6 +24,9 @@ public class Reflection {
|
|||||||
|
|
||||||
public static final ReferenceProxy REFERENCE;
|
public static final ReferenceProxy REFERENCE;
|
||||||
|
|
||||||
|
public static final ChunkMapProxy CHUNKMAP;
|
||||||
|
public static final HolderSetProxy HOLDER_SET;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
||||||
ReflectionProxyFactory reflectionProxyFactory = ReflectionProxyFactory.create(reflectionRemapper,
|
ReflectionProxyFactory reflectionProxyFactory = ReflectionProxyFactory.create(reflectionRemapper,
|
||||||
@@ -27,6 +35,8 @@ public class Reflection {
|
|||||||
MAPPED_REGISTRY = reflectionProxyFactory.reflectionProxy(MappedRegistryProxy.class);
|
MAPPED_REGISTRY = reflectionProxyFactory.reflectionProxy(MappedRegistryProxy.class);
|
||||||
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
||||||
REFERENCE = reflectionProxyFactory.reflectionProxy(ReferenceProxy.class);
|
REFERENCE = reflectionProxyFactory.reflectionProxy(ReferenceProxy.class);
|
||||||
|
CHUNKMAP = reflectionProxyFactory.reflectionProxy(ChunkMapProxy.class);
|
||||||
|
HOLDER_SET = reflectionProxyFactory.reflectionProxy(HolderSetProxy.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,4 +59,19 @@ public class Reflection {
|
|||||||
@MethodName("bindValue")
|
@MethodName("bindValue")
|
||||||
<T> void invokeBindValue(Reference<T> instance, T value);
|
<T> void invokeBindValue(Reference<T> instance, T value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Proxies(ChunkMap.class)
|
||||||
|
public interface ChunkMapProxy {
|
||||||
|
@FieldGetter("worldGenContext")
|
||||||
|
WorldGenContext getWorldGenContext(ChunkMap instance);
|
||||||
|
|
||||||
|
@FieldSetter("worldGenContext")
|
||||||
|
void setWorldGenContext(ChunkMap instance, WorldGenContext worldGenContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Proxies(HolderSet.class)
|
||||||
|
public interface HolderSetProxy {
|
||||||
|
@MethodName("contents")
|
||||||
|
<T> List<Holder<T>> invokeContents(HolderSet<T> instance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -15,7 +15,9 @@ public class RegistryFetcher {
|
|||||||
DedicatedServer dedicatedserver = craftserver.getServer();
|
DedicatedServer dedicatedserver = craftserver.getServer();
|
||||||
return dedicatedserver
|
return dedicatedserver
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(key);
|
.get(key)
|
||||||
|
.orElseThrow()
|
||||||
|
.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Registry<Biome> biomeRegistry() {
|
public static Registry<Biome> biomeRegistry() {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ dependencies {
|
|||||||
|
|
||||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
||||||
|
|
||||||
modImplementation("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric)
|
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||||
include("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric)
|
include("org.incendo", "cloud-fabric", Versions.Fabric.cloud)
|
||||||
|
|
||||||
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
|
modRuntimeOnly("net.fabricmc.fabric-api", "fabric-api", Versions.Fabric.fabricAPI)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
"terra.common.mixins.json"
|
"terra.common.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.16.5",
|
"fabricloader": ">=0.16.7",
|
||||||
"java": ">=21",
|
"java": ">=21",
|
||||||
"minecraft": ">=1.21.1",
|
"minecraft": ">=1.21.3",
|
||||||
"fabric": "*"
|
"fabric": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -29,7 +29,7 @@ public class BiomeParticleConfigTemplate implements ObjectTemplate<BiomeParticle
|
|||||||
try {
|
try {
|
||||||
return new BiomeParticleConfig(
|
return new BiomeParticleConfig(
|
||||||
ParticleEffectArgumentType.readParameters(new StringReader(particle),
|
ParticleEffectArgumentType.readParameters(new StringReader(particle),
|
||||||
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE.getReadOnlyWrapper()),
|
(RegistryWrapper.WrapperLookup) Registries.PARTICLE_TYPE),
|
||||||
probability);
|
probability);
|
||||||
} catch(CommandSyntaxException e) {
|
} catch(CommandSyntaxException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
+1
-1
@@ -15,6 +15,6 @@ public class EntityTypeTemplate implements ObjectTemplate<EntityType<?>> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityType<?> get() {
|
public EntityType<?> get() {
|
||||||
return Registries.ENTITY_TYPE.get(id);
|
return Registries.ENTITY_TYPE.getEntry(id).orElseThrow().value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,6 +15,6 @@ public class VillagerTypeTemplate implements ObjectTemplate<VillagerType> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VillagerType get() {
|
public VillagerType get() {
|
||||||
return Registries.VILLAGER_TYPE.get(id);
|
return Registries.VILLAGER_TYPE.getEntry(id).orElseThrow().value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -35,7 +35,6 @@ import net.minecraft.world.StructureWorldAccess;
|
|||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.source.BiomeAccess;
|
import net.minecraft.world.biome.source.BiomeAccess;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.gen.GenerationStep.Carver;
|
|
||||||
import net.minecraft.world.gen.StructureAccessor;
|
import net.minecraft.world.gen.StructureAccessor;
|
||||||
import net.minecraft.world.gen.StructureWeightSampler;
|
import net.minecraft.world.gen.StructureWeightSampler;
|
||||||
import net.minecraft.world.gen.chunk.Blender;
|
import net.minecraft.world.gen.chunk.Blender;
|
||||||
@@ -97,7 +96,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
|||||||
public void populateEntities(ChunkRegion region) {
|
public void populateEntities(ChunkRegion region) {
|
||||||
if(this.settings.mobGeneration()) {
|
if(this.settings.mobGeneration()) {
|
||||||
ChunkPos chunkPos = region.getCenterPos();
|
ChunkPos chunkPos = region.getCenterPos();
|
||||||
RegistryEntry<Biome> registryEntry = region.getBiome(chunkPos.getStartPos().withY(region.getTopY() - 1));
|
RegistryEntry<Biome> registryEntry = region.getBiome(chunkPos.getStartPos().withY(region.getTopYInclusive() - 1));
|
||||||
ChunkRandom chunkRandom = new ChunkRandom(new CheckedRandom(RandomSeed.getSeed()));
|
ChunkRandom chunkRandom = new ChunkRandom(new CheckedRandom(RandomSeed.getSeed()));
|
||||||
chunkRandom.setPopulationSeed(region.getSeed(), chunkPos.getStartX(), chunkPos.getStartZ());
|
chunkRandom.setPopulationSeed(region.getSeed(), chunkPos.getStartX(), chunkPos.getStartZ());
|
||||||
SpawnHelper.populateEntities(region, registryEntry, chunkPos, chunkRandom);
|
SpawnHelper.populateEntities(region, registryEntry, chunkPos, chunkRandom);
|
||||||
@@ -183,7 +182,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
|||||||
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
|
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
|
||||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
int min = height.getBottomY();
|
int min = height.getBottomY();
|
||||||
for(int y = height.getTopY() - 1; y >= min; y--) {
|
for(int y = height.getTopYInclusive() - 1; y >= min; y--) {
|
||||||
if(heightmap
|
if(heightmap
|
||||||
.getBlockPredicate()
|
.getBlockPredicate()
|
||||||
.test((BlockState) delegate.getBlock(properties, x, y, z, biomeProvider))) return y + 1;
|
.test((BlockState) delegate.getBlock(properties, x, y, z, biomeProvider))) return y + 1;
|
||||||
@@ -196,14 +195,14 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
|||||||
BlockState[] array = new BlockState[height.getHeight()];
|
BlockState[] array = new BlockState[height.getHeight()];
|
||||||
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
|
WorldProperties properties = MinecraftAdapter.adapt(height, SeedHack.getSeed(noiseConfig.getMultiNoiseSampler()));
|
||||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
for(int y = height.getTopYInclusive() - 1; y >= height.getBottomY(); y--) {
|
||||||
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(properties, x, y, z, biomeProvider);
|
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(properties, x, y, z, biomeProvider);
|
||||||
}
|
}
|
||||||
return new VerticalBlockSample(height.getBottomY(), array);
|
return new VerticalBlockSample(height.getBottomY(), array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
|
public void appendDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
|
||||||
// no op
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,10 +218,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
|||||||
logger.debug("Loading world with config pack {}", pack.getID());
|
logger.debug("Loading world with config pack {}", pack.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor,
|
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess biomeAccess,
|
||||||
Chunk chunk, Carver carverStep) {
|
StructureAccessor structureAccessor, Chunk chunk) {
|
||||||
// no op
|
//no op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+9
-3
@@ -24,6 +24,7 @@ import net.minecraft.command.argument.ItemStackArgumentType;
|
|||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.registry.RegistryWrapper.Impl;
|
import net.minecraft.registry.RegistryWrapper.Impl;
|
||||||
|
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -43,14 +44,19 @@ public class MinecraftItemHandle implements ItemHandle {
|
|||||||
public Item createItem(String data) {
|
public Item createItem(String data) {
|
||||||
try {
|
try {
|
||||||
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
|
return (Item) new ItemStackArgumentType(new CommandRegistryAccess() {
|
||||||
|
@Override
|
||||||
|
public FeatureSet getEnabledFeatures() {
|
||||||
|
return FeatureSet.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
|
public Stream<RegistryKey<? extends Registry<?>>> streamAllRegistryKeys() {
|
||||||
return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys();
|
return CommonPlatform.get().getServer().getRegistryManager().streamAllRegistryKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Optional<Impl<T>> getOptionalWrapper(RegistryKey<? extends Registry<? extends T>> registryRef) {
|
public <T> Optional<Impl<T>> getOptional(RegistryKey<? extends Registry<? extends T>> registryRef) {
|
||||||
return Optional.of(CommonPlatform.get().getServer().getRegistryManager().getWrapperOrThrow(registryRef));
|
return Optional.of(CommonPlatform.get().getServer().getRegistryManager().getOrThrow(registryRef));
|
||||||
}
|
}
|
||||||
}).parse(new StringReader(data)).getItem();
|
}).parse(new StringReader(data)).getItem();
|
||||||
} catch(CommandSyntaxException e) {
|
} catch(CommandSyntaxException e) {
|
||||||
@@ -60,7 +66,7 @@ public class MinecraftItemHandle implements ItemHandle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enchantment getEnchantment(String id) {
|
public Enchantment getEnchantment(String id) {
|
||||||
return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().get(Identifier.tryParse(id)));
|
return (Enchantment) (Object) (CommonPlatform.get().enchantmentRegistry().getEntry(Identifier.tryParse(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-2
@@ -41,7 +41,7 @@ public class MinecraftWorldHandle implements WorldHandle {
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull BlockState createBlockState(@NotNull String data) {
|
public @NotNull BlockState createBlockState(@NotNull String data) {
|
||||||
try {
|
try {
|
||||||
net.minecraft.block.BlockState state = BlockArgumentParser.block(Registries.BLOCK.getReadOnlyWrapper(), data, true)
|
net.minecraft.block.BlockState state = BlockArgumentParser.block(Registries.BLOCK, data, true)
|
||||||
.blockState();
|
.blockState();
|
||||||
if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
|
if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
|
||||||
return (BlockState) state;
|
return (BlockState) state;
|
||||||
@@ -60,6 +60,6 @@ public class MinecraftWorldHandle implements WorldHandle {
|
|||||||
if(!id.contains(":")) throw new IllegalArgumentException("Invalid entity identifier " + id);
|
if(!id.contains(":")) throw new IllegalArgumentException("Invalid entity identifier " + id);
|
||||||
Identifier identifier = Identifier.tryParse(id);
|
Identifier identifier = Identifier.tryParse(id);
|
||||||
if(identifier == null) identifier = Identifier.tryParse(id);
|
if(identifier == null) identifier = Identifier.tryParse(id);
|
||||||
return (EntityType) Registries.ENTITY_TYPE.get(identifier);
|
return (EntityType) Registries.ENTITY_TYPE.getEntry(identifier).orElseThrow().value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -54,8 +54,8 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
|||||||
public abstract void setEntityType(net.minecraft.entity.EntityType<?> entityType, Random random);
|
public abstract void setEntityType(net.minecraft.entity.EntityType<?> entityType, Random random);
|
||||||
|
|
||||||
public EntityType terra$getSpawnedType() {
|
public EntityType terra$getSpawnedType() {
|
||||||
return (EntityType) Registries.ENTITY_TYPE.get(
|
return (EntityType) Registries.ENTITY_TYPE.getEntry(
|
||||||
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id")));
|
Identifier.tryParse(((MobSpawnerLogicAccessor) getLogic()).getSpawnEntry().getNbt().getString("id"))).orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
||||||
|
|||||||
+2
-1
@@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.properties.Property;
|
import com.dfsek.terra.api.block.state.properties.Property;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ public abstract class PropertyMixin<T> {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract Collection<T> getValues();
|
public abstract List<T> getValues();
|
||||||
|
|
||||||
@Intrinsic
|
@Intrinsic
|
||||||
public Collection<T> terra$values() {
|
public Collection<T> terra$values() {
|
||||||
|
|||||||
-3
@@ -49,9 +49,6 @@ public abstract class WorldChunkMixin {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract TickSchedulers getTickSchedulers();
|
|
||||||
|
|
||||||
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||||
BlockPos blockPos = new BlockPos(x, y, z);
|
BlockPos blockPos = new BlockPos(x, y, z);
|
||||||
setBlockState(blockPos, (net.minecraft.block.BlockState) data, false);
|
setBlockState(blockPos, (net.minecraft.block.BlockState) data, false);
|
||||||
|
|||||||
+1
-1
@@ -48,6 +48,6 @@ public abstract class ProtoChunkMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int terra$getMaxHeight() {
|
public int terra$getMaxHeight() {
|
||||||
return getHeightLimitView().getTopY();
|
return getHeightLimitView().getTopYInclusive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@ package com.dfsek.terra.mod.mixin.implementations.terra.inventory.item;
|
|||||||
|
|
||||||
import net.minecraft.component.ComponentChanges;
|
import net.minecraft.component.ComponentChanges;
|
||||||
import net.minecraft.component.ComponentMap;
|
import net.minecraft.component.ComponentMap;
|
||||||
import net.minecraft.component.ComponentMapImpl;
|
import net.minecraft.component.MergedComponentMap;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Implements;
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
@@ -37,7 +37,7 @@ import com.dfsek.terra.api.inventory.item.ItemMeta;
|
|||||||
public abstract class ItemStackMixin {
|
public abstract class ItemStackMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
private ComponentMapImpl components;
|
private MergedComponentMap components;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract int getCount();
|
public abstract int getCount();
|
||||||
|
|||||||
+3
-2
@@ -18,6 +18,7 @@
|
|||||||
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
||||||
|
|
||||||
import net.minecraft.block.FluidBlock;
|
import net.minecraft.block.FluidBlock;
|
||||||
|
import net.minecraft.entity.SpawnReason;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.util.collection.BoundedRegionArray;
|
import net.minecraft.util.collection.BoundedRegionArray;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -99,7 +100,7 @@ public abstract class ChunkRegionMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int terraWorld$getMaxHeight() {
|
public int terraWorld$getMaxHeight() {
|
||||||
return world.getTopY();
|
return world.getTopYInclusive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Intrinsic(displace = true)
|
@Intrinsic(displace = true)
|
||||||
@@ -125,7 +126,7 @@ public abstract class ChunkRegionMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Entity terraWorld$spawnEntity(double x, double y, double z, EntityType entityType) {
|
public Entity terraWorld$spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(world);
|
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(world, SpawnReason.CHUNK_GENERATION);
|
||||||
entity.setPos(x, y, z);
|
entity.setPos(x, y, z);
|
||||||
((ChunkRegion) (Object) this).spawnEntity(entity);
|
((ChunkRegion) (Object) this).spawnEntity(entity);
|
||||||
return (Entity) entity;
|
return (Entity) entity;
|
||||||
|
|||||||
+2
-1
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
package com.dfsek.terra.mod.mixin.implementations.terra.world;
|
||||||
|
|
||||||
|
import net.minecraft.entity.SpawnReason;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
import org.spongepowered.asm.mixin.Implements;
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
@@ -42,7 +43,7 @@ import com.dfsek.terra.mod.util.MinecraftUtil;
|
|||||||
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
|
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
|
||||||
public abstract class ServerWorldMixin {
|
public abstract class ServerWorldMixin {
|
||||||
public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) {
|
public Entity terra$spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(null);
|
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(null, SpawnReason.CHUNK_GENERATION);
|
||||||
entity.setPos(x, y, z);
|
entity.setPos(x, y, z);
|
||||||
((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity);
|
((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity);
|
||||||
return (Entity) entity;
|
return (Entity) entity;
|
||||||
|
|||||||
+22
-5
@@ -1,10 +1,16 @@
|
|||||||
package com.dfsek.terra.mod.mixin.lifecycle;
|
package com.dfsek.terra.mod.mixin.lifecycle;
|
||||||
|
|
||||||
|
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||||
import net.minecraft.registry.DynamicRegistryManager;
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.Registry.PendingTagLoad;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.registry.ReloadableRegistries;
|
import net.minecraft.registry.ReloadableRegistries;
|
||||||
|
import net.minecraft.registry.ServerDynamicRegistryType;
|
||||||
|
import net.minecraft.resource.ResourceManager;
|
||||||
|
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||||
import net.minecraft.server.DataPackContents;
|
import net.minecraft.server.DataPackContents;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -16,6 +22,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||||
import com.dfsek.terra.mod.util.TagUtil;
|
import com.dfsek.terra.mod.util.TagUtil;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
|
||||||
@Mixin(DataPackContents.class)
|
@Mixin(DataPackContents.class)
|
||||||
public class DataPackContentsMixin {
|
public class DataPackContentsMixin {
|
||||||
@@ -26,12 +38,17 @@ public class DataPackContentsMixin {
|
|||||||
/*
|
/*
|
||||||
* #refresh populates all tags in the registries
|
* #refresh populates all tags in the registries
|
||||||
*/
|
*/
|
||||||
@Inject(method = "refresh()V", at = @At("RETURN"))
|
@Inject(method = "reload(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
|
||||||
private void injectReload(CallbackInfo ci) {
|
private static void injectReload(ResourceManager resourceManager,
|
||||||
DynamicRegistryManager.Immutable dynamicRegistryManager = this.reloadableRegistries.getRegistryManager();
|
CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries,
|
||||||
TagUtil.registerWorldPresetTags(dynamicRegistryManager.get(RegistryKeys.WORLD_PRESET));
|
List<PendingTagLoad<?>> pendingTagLoads, FeatureSet enabledFeatures,
|
||||||
|
CommandManager.RegistrationEnvironment environment, int functionPermissionLevel,
|
||||||
|
Executor prepareExecutor,
|
||||||
|
Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<DataPackContents>> cir) {
|
||||||
|
DynamicRegistryManager.Immutable dynamicRegistryManager = dynamicRegistries.getCombinedRegistryManager();
|
||||||
|
TagUtil.registerWorldPresetTags(dynamicRegistryManager.getOrThrow(RegistryKeys.WORLD_PRESET));
|
||||||
|
|
||||||
Registry<Biome> biomeRegistry = dynamicRegistryManager.get(RegistryKeys.BIOME);
|
Registry<Biome> biomeRegistry = dynamicRegistryManager.getOrThrow(RegistryKeys.BIOME);
|
||||||
TagUtil.registerBiomeTags(biomeRegistry);
|
TagUtil.registerBiomeTags(biomeRegistry);
|
||||||
MinecraftUtil.registerFlora(biomeRegistry);
|
MinecraftUtil.registerFlora(biomeRegistry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public final class MinecraftAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return height.getTopY();
|
return height.getTopYInclusive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -54,9 +54,8 @@ public final class MinecraftUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Optional<RegistryEntry<T>> getEntry(Registry<T> registry, Identifier identifier) {
|
public static <T> Optional<RegistryEntry<T>> getEntry(Registry<T> registry, Identifier identifier) {
|
||||||
return registry.getOrEmpty(identifier)
|
return registry.getOptionalValue(identifier)
|
||||||
.flatMap(registry::getKey)
|
.flatMap(id -> Optional.ofNullable(registry.getEntry(id)));
|
||||||
.flatMap(registry::getEntry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockEntity createState(WorldAccess worldAccess, BlockPos pos) {
|
public static BlockEntity createState(WorldAccess worldAccess, BlockPos pos) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.mod.util;
|
package com.dfsek.terra.mod.util;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
import net.minecraft.registry.entry.RegistryEntry;
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
|
import net.minecraft.registry.tag.TagGroupLoader.RegistryTags;
|
||||||
import net.minecraft.registry.tag.TagKey;
|
import net.minecraft.registry.tag.TagKey;
|
||||||
import net.minecraft.registry.tag.WorldPresetTags;
|
import net.minecraft.registry.tag.WorldPresetTags;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public final class TagUtil {
|
public final class TagUtil {
|
||||||
@@ -24,12 +25,9 @@ public final class TagUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T> Map<TagKey<T>, List<RegistryEntry<T>>> tagsToMutableMap(Registry<T> registry) {
|
private static <T> Map<TagKey<T>, List<RegistryEntry<T>>> tagsToMutableMap(Registry<T> registry) {
|
||||||
return registry
|
return registry.streamTags().collect(HashMap::new,
|
||||||
.streamTagsAndEntries()
|
(map, tag) -> map.put(tag.getTag(), tag.stream().collect(Collectors.toList())),
|
||||||
.collect(HashMap::new,
|
HashMap::putAll);
|
||||||
(map, pair) ->
|
|
||||||
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
|
||||||
HashMap::putAll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerWorldPresetTags(Registry<WorldPreset> registry) {
|
public static void registerWorldPresetTags(Registry<WorldPreset> registry) {
|
||||||
@@ -46,8 +44,14 @@ public final class TagUtil {
|
|||||||
.add(preset),
|
.add(preset),
|
||||||
() -> logger.error("Preset {} does not exist!", id)));
|
() -> logger.error("Preset {} does not exist!", id)));
|
||||||
|
|
||||||
registry.clearTags();
|
registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
|
||||||
registry.populateTags(ImmutableMap.copyOf(collect));
|
|
||||||
|
if(logger.isDebugEnabled()) {
|
||||||
|
registry.streamEntries()
|
||||||
|
.map(e -> e.registryKey().getValue() + ": " +
|
||||||
|
e.streamTags().reduce("", (s, t) -> t.id() + ", " + s, String::concat))
|
||||||
|
.forEach(logger::debug);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerBiomeTags(Registry<Biome> registry) {
|
public static void registerBiomeTags(Registry<Biome> registry) {
|
||||||
@@ -90,8 +94,7 @@ public final class TagUtil {
|
|||||||
tb))),
|
tb))),
|
||||||
() -> logger.error("No vanilla biome: {}", vb)));
|
() -> logger.error("No vanilla biome: {}", vb)));
|
||||||
|
|
||||||
registry.clearTags();
|
registry.startTagReload(new RegistryTags<>(registry.getKey(), collect)).apply();
|
||||||
registry.populateTags(ImmutableMap.copyOf(collect));
|
|
||||||
|
|
||||||
if(logger.isDebugEnabled()) {
|
if(logger.isDebugEnabled()) {
|
||||||
registry.streamEntries()
|
registry.streamEntries()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ dependencies {
|
|||||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|
||||||
modImplementation("org.incendo", "cloud-fabric", Versions.Libraries.cloudFabric) {
|
modImplementation("org.incendo", "cloud-fabric", Versions.Fabric.cloud) {
|
||||||
exclude("net.fabricmc")
|
exclude("net.fabricmc")
|
||||||
exclude("net.fabricmc.fabric-api")
|
exclude("net.fabricmc.fabric-api")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
|||||||
boolean succeed = loadConfigPacks();
|
boolean succeed = loadConfigPacks();
|
||||||
|
|
||||||
if(server != null) {
|
if(server != null) {
|
||||||
BiomeUtil.registerBiomes(server.getRegistryManager().get(RegistryKeys.BIOME));
|
BiomeUtil.registerBiomes(server.getRegistryManager().getOrThrow(RegistryKeys.BIOME));
|
||||||
server.reloadResources(server.getDataPackManager().getEnabledIds()).exceptionally(throwable -> {
|
server.reloadResources(server.getDataPackManager().getEnabledIds()).exceptionally(throwable -> {
|
||||||
LOGGER.warn("Failed to execute reload", throwable);
|
LOGGER.warn("Failed to execute reload", throwable);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
|
||||||
|
import com.dfsek.terra.mod.CommonPlatform;
|
||||||
|
|
||||||
|
import com.dfsek.terra.mod.ModPlatform;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static com.dfsek.terra.lifecycle.util.LifecycleUtil.initialized;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(CreateWorldScreen.class)
|
||||||
|
public class CreateWorldScreenMixin {
|
||||||
|
@Inject(method = "onCloseScreen()V", at = @At("HEAD"))
|
||||||
|
public void onClose(CallbackInfo ci) {
|
||||||
|
ModPlatform platform = CommonPlatform.get();
|
||||||
|
platform.getRawConfigRegistry().clear();
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -1,5 +1,8 @@
|
|||||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||||
|
|
||||||
|
import com.dfsek.terra.mod.CommonPlatform;
|
||||||
|
import com.dfsek.terra.mod.ModPlatform;
|
||||||
|
|
||||||
import com.mojang.datafixers.DataFixer;
|
import com.mojang.datafixers.DataFixer;
|
||||||
import net.minecraft.resource.ResourcePackManager;
|
import net.minecraft.resource.ResourcePackManager;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@@ -34,6 +37,8 @@ public class MinecraftServerMixin {
|
|||||||
|
|
||||||
@Inject(method = "shutdown()V", at = @At("RETURN"))
|
@Inject(method = "shutdown()V", at = @At("RETURN"))
|
||||||
private void injectShutdown(CallbackInfo ci) {
|
private void injectShutdown(CallbackInfo ci) {
|
||||||
|
ModPlatform platform = CommonPlatform.get();
|
||||||
|
platform.getRawConfigRegistry().clear();
|
||||||
initialized = false;
|
initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -39,8 +39,7 @@ public class RegistryLoaderMixin {
|
|||||||
private static Logger LOGGER;
|
private static Logger LOGGER;
|
||||||
|
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;" +
|
method = "load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Ljava/util/List;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
||||||
"Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;",
|
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V",
|
||||||
|
|||||||
+6
-7
@@ -1,7 +1,8 @@
|
|||||||
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
package com.dfsek.terra.lifecycle.mixin.lifecycle;
|
||||||
|
|
||||||
import net.minecraft.registry.DynamicRegistryManager;
|
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.registry.ServerDynamicRegistryType;
|
||||||
import net.minecraft.server.SaveLoading;
|
import net.minecraft.server.SaveLoading;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -18,13 +19,11 @@ public class SaveLoadingMixin {
|
|||||||
"Ljava/util/concurrent/CompletableFuture;",
|
"Ljava/util/concurrent/CompletableFuture;",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/registry/RegistryLoader;loadFromResource(Lnet/minecraft/resource/ResourceManager;" +
|
target = "Lnet/minecraft/server/DataPackContents;reload(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/CombinedDynamicRegistries;Ljava/util/List;Lnet/minecraft/resource/featuretoggle/FeatureSet;Lnet/minecraft/server/command/CommandManager$RegistrationEnvironment;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"),
|
||||||
"Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)" +
|
|
||||||
"Lnet/minecraft/registry/DynamicRegistryManager$Immutable;"),
|
|
||||||
index = 1
|
index = 1
|
||||||
)
|
)
|
||||||
private static DynamicRegistryManager grabManager(DynamicRegistryManager registryManager) {
|
private static CombinedDynamicRegistries<ServerDynamicRegistryType> grabManager(CombinedDynamicRegistries<ServerDynamicRegistryType> dynamicRegistries) {
|
||||||
MinecraftUtil.registerFlora(registryManager.get(RegistryKeys.BIOME));
|
MinecraftUtil.registerFlora(dynamicRegistries.getCombinedRegistryManager().getOrThrow(RegistryKeys.BIOME));
|
||||||
return registryManager;
|
return dynamicRegistries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ public final class BiomeUtil {
|
|||||||
|
|
||||||
|
|
||||||
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
|
if(pack.getContext().get(PreLoadCompatibilityOptions.class).useVanillaBiomes()) {
|
||||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(vanilla).orElseThrow());
|
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(registry.getEntry(registry.get(vanilla)));
|
||||||
} else {
|
} else {
|
||||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "com.dfsek.terra.lifecycle.mixin",
|
"package": "com.dfsek.terra.lifecycle.mixin",
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"NoiseConfigMixin",
|
"NoiseConfigMixin",
|
||||||
"RegistryEntryReferenceInvoker",
|
"RegistryEntryReferenceInvoker",
|
||||||
"RegistryMixin",
|
"RegistryMixin",
|
||||||
"SimpleRegistryMixin",
|
"SimpleRegistryMixin",
|
||||||
"lifecycle.MinecraftServerMixin",
|
"lifecycle.MinecraftServerMixin",
|
||||||
"lifecycle.RegistryLoaderMixin",
|
"lifecycle.RegistryLoaderMixin",
|
||||||
"lifecycle.SaveLoadingMixin"
|
"lifecycle.SaveLoadingMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
"lifecycle.CreateWorldScreenMixin"
|
||||||
"server": [
|
],
|
||||||
],
|
"server": [
|
||||||
"injectors": {
|
],
|
||||||
"defaultRequire": 1
|
"injectors": {
|
||||||
},
|
"defaultRequire": 1
|
||||||
"refmap": "terra.lifecycle.refmap.json"
|
},
|
||||||
|
"refmap": "terra.lifecycle.refmap.json"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user