Skip to content

Commit

Permalink
Update mod to Minecraft 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored and Gegy committed Oct 22, 2024
1 parent 8aeaa5f commit 15a1749
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6.+'
id 'fabric-loom' version '1.8.+'
id 'maven-publish'
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties

minecraft_version=1.21
yarn_mappings=1.21+build.1
loader_version=0.15.11
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
loader_version=0.16.7

# Mod Properties
mod_version=0.6.4
maven_group=xyz.nucleoid
archives_base_name=fantasy

# Dependencies
fabric_version=0.100.1+1.21
fabric_version=0.106.1+1.21.2
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/xyz/nucleoid/fantasy/Fantasy.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.TeleportTarget;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.level.storage.LevelStorage;
Expand Down Expand Up @@ -217,8 +219,12 @@ private void kickPlayers(ServerWorld world) {
float spawnAngle = overworld.getSpawnAngle();

List<ServerPlayerEntity> players = new ArrayList<>(world.getPlayers());

Vec3d pos = new Vec3d(spawnPos.getX() + 0.5, spawnPos.getY(), spawnPos.getZ() + 0.5);
TeleportTarget target = new TeleportTarget(overworld, pos, Vec3d.ZERO, spawnAngle, 0.0F, TeleportTarget.NO_OP);

for (ServerPlayerEntity player : players) {
player.teleport(overworld, spawnPos.getX() + 0.5, spawnPos.getY(), spawnPos.getZ() + 0.5, spawnAngle, 0.0F);
player.teleportTo(target);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void save(@Nullable ProgressListener progressListener, boolean flush, boo
@Override
protected void tickTime() {
if (this.shouldTickTime) {
if (this.properties.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
if (this.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
this.setTimeOfDay(this.properties.getTimeOfDay() + 1L);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public DimensionOptions createDimensionOptions(MinecraftServer server) {
private RegistryEntry<DimensionType> resolveDimensionType(MinecraftServer server) {
var dimensionType = this.dimensionType;
if (dimensionType == null) {
dimensionType = server.getRegistryManager().get(RegistryKeys.DIMENSION_TYPE).getEntry(this.dimensionTypeKey).orElse(null);
dimensionType = server.getRegistryManager().getOrThrow(RegistryKeys.DIMENSION_TYPE).getOptional(this.dimensionTypeKey).orElse(null);
Preconditions.checkNotNull(dimensionType, "invalid dimension type " + this.dimensionTypeKey);
}
return dimensionType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ public void setDone() {}

private static SimpleRegistry<DimensionOptions> getDimensionsRegistry(MinecraftServer server) {
DynamicRegistryManager registryManager = server.getCombinedDynamicRegistries().getCombinedRegistryManager();
return (SimpleRegistry<DimensionOptions>) registryManager.get(RegistryKeys.DIMENSION);
return (SimpleRegistry<DimensionOptions>) registryManager.getOrThrow(RegistryKeys.DIMENSION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public RuntimeWorldProperties(SaveProperties saveProperties, RuntimeWorldConfig
super(saveProperties, saveProperties.getMainWorldProperties());
this.config = config;

this.rules = new GameRules();
this.rules = new GameRules(saveProperties.getEnabledFeatures());
config.getGameRules().applyTo(this.rules, null);
}

Expand Down
11 changes: 5 additions & 6 deletions src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import net.minecraft.world.biome.source.FixedBiomeSource;
import net.minecraft.world.biome.source.util.MultiNoiseUtil;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.Blender;
import net.minecraft.world.gen.chunk.ChunkGenerator;
Expand Down Expand Up @@ -103,12 +102,12 @@ public VoidChunkGenerator(Registry<Biome> biomeRegistry) {
}

public VoidChunkGenerator(Registry<Biome> biomeRegistry, RegistryKey<Biome> biome) {
this(biomeRegistry.getEntry(biome).orElseThrow());
this(biomeRegistry.getOptional(biome).orElseThrow());
}

// Create an empty (void) world!
public VoidChunkGenerator(MinecraftServer server) {
this(server.getRegistryManager().get(RegistryKeys.BIOME), BiomeKeys.THE_VOID);
this(server.getRegistryManager().getOrThrow(RegistryKeys.BIOME), BiomeKeys.THE_VOID);
}

// Create a world with a given Biome (as an ID)
Expand All @@ -118,7 +117,7 @@ public VoidChunkGenerator(MinecraftServer server, Identifier biome) {

// Create a world with a given Biome (as a RegistryKey)
public VoidChunkGenerator(MinecraftServer server, RegistryKey<Biome> biome) {
this(server.getRegistryManager().get(RegistryKeys.BIOME), biome);
this(server.getRegistryManager().getOrThrow(RegistryKeys.BIOME), biome);
}

@Override
Expand All @@ -131,7 +130,7 @@ protected RegistryEntry<Biome> getBiome() {
}

@Override
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor, Chunk chunk, GenerationStep.Carver carverStep) {
public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor, Chunk chunk) {

}

Expand Down Expand Up @@ -165,7 +164,7 @@ public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView world,
}

@Override
public void getDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
public void appendDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"depends": {
"fabricloader": ">=0.15.10",
"minecraft": ">=1.21-",
"minecraft": ">=1.21.2-",
"fabric-api": "*",
"java": ">=21"
}
Expand Down
8 changes: 4 additions & 4 deletions src/testmod/java/xyz/nucleoid/fantasy/test/CustomWorld.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package xyz.nucleoid.fantasy.test;

import net.minecraft.recipe.RecipeManager;
import net.minecraft.recipe.ServerRecipeManager;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
Expand All @@ -11,11 +11,11 @@

public class CustomWorld extends RuntimeWorld {
private long dynSeed;
private final RecipeManager recipeManager;
private final ServerRecipeManager recipeManager;

protected CustomWorld(MinecraftServer server, RegistryKey<World> registryKey, RuntimeWorldConfig config, Style style) {
super(server, registryKey, config, style);
this.recipeManager = new RecipeManager(server.getRegistryManager());
this.recipeManager = new ServerRecipeManager(server.getRegistryManager());
}


Expand All @@ -26,7 +26,7 @@ public void tick(BooleanSupplier shouldKeepTicking) {
}

@Override
public RecipeManager getRecipeManager() {
public ServerRecipeManager getRecipeManager() {
return this.recipeManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public final class FantasyInitializer implements ModInitializer {
public void onInitialize() {
ServerLifecycleEvents.SERVER_STARTED.register((s) -> {
Fantasy.get(s).openTemporaryWorld(
new RuntimeWorldConfig().setGenerator(new VoidChunkGenerator(s.getRegistryManager().get(RegistryKeys.BIOME).getEntry(0).get())).setWorldConstructor(CustomWorld::new)
new RuntimeWorldConfig().setGenerator(new VoidChunkGenerator(s.getRegistryManager().getOrThrow(RegistryKeys.BIOME).getEntry(0).get())).setWorldConstructor(CustomWorld::new)
);

Fantasy.get(s).openTemporaryWorld(
new RuntimeWorldConfig().setGenerator(s.getOverworld().getChunkManager().getChunkGenerator()).setWorldConstructor(CustomWorld::new)
);

var biome = s.getRegistryManager().get(RegistryKeys.BIOME).getEntry(s.getRegistryManager().get(RegistryKeys.BIOME).getOrThrow(BiomeKeys.PLAINS));
var biome = s.getRegistryManager().getOrThrow(RegistryKeys.BIOME).getOrThrow(BiomeKeys.PLAINS);
FlatChunkGeneratorConfig flat = new FlatChunkGeneratorConfig(Optional.empty(), biome, List.of());
FlatChunkGenerator generator = new FlatChunkGenerator(flat);

Expand Down

0 comments on commit 15a1749

Please sign in to comment.