Skip to content

Commit

Permalink
First pass at an update to 1.21.2. (#95)
Browse files Browse the repository at this point in the history
* First pass at an update to 1.21.2.

- Make it build against 1.21.2
- Fix broken things
- Replace basically all of the boat API

* I forgot about PillarLogHelper...

- PillarLogHelper.of methods removed
- PillarLogHelper.settings methods added
  They provide AbstractBlock.Settings instead of PillarLog

- Improvements to the testmod

* Darn it IDEA, why do you keep removing this change from my commits?

* Adjust name of new pillar log helpers.

I was trying to keep them short, but I didn't really like the names either, so I'm fine with this.

Co-authored-by: haykam821 <[email protected]>

* Update ancillary gradle cruft to match version 8.8.

* Update to 1.21.2-rc1.  Fix wood test.

* Fix the raft entity renderers.

* Add DFU support so old boats can become new boats.

This is the nice clean way I wanted to do but can't because somebody decided the DFU should init before mods do...

* Version which enables mods to register boat IDs early.
- Provide a hook for mods to give us their boat IDs (so datafixer retains the boat type instead of using oak)

This is the icky version I hate to have to make, but the DFU initializes way too early to do this in any nice way...

---------

Co-authored-by: haykam821 <[email protected]>
  • Loading branch information
gniftygnome and haykam821 authored Nov 8, 2024
1 parent a7ac9de commit 74c77f1
Show file tree
Hide file tree
Showing 57 changed files with 901 additions and 1,134 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'maven-publish'
id 'idea'
id 'eclipse'
id 'fabric-loom' version '1.6.+'
id 'fabric-loom' version '1.7.+'
}

allprojects {
Expand Down
11 changes: 5 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true

maven_group=com.terraformersmc.terraform-api
version=11.0.0-alpha.1
version=12.0.0-alpha.1

minecraft_version=1.21
yarn_mappings=1.21+build.7
loader_version=0.15.11
fabric_version=0.100.4+1.21
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
loader_version=0.16.7
fabric_version=0.106.1+1.21.2
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 10 additions & 9 deletions gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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 @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,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 +57,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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class TerraformGrassBlock extends GrassBlock {
private final Map<Block, Block> spreadsTo;
private final Supplier<Block> path;
public static final Map<Block, Block> GRASS_SPREADS_TO = new HashMap<>();
private static final int MAX_LIGHT_LEVEL = 15;

public TerraformGrassBlock(Block dirt, Supplier<Block> path, Block.Settings settings) {
this(dirt, path, settings, ImmutableMap.of(Blocks.DIRT, Blocks.GRASS_BLOCK));
Expand Down Expand Up @@ -55,11 +56,13 @@ private static boolean canSurvive(BlockState state, WorldView world, BlockPos po
BlockPos above = pos.up();
BlockState aboveState = world.getBlockState(above);

if (aboveState.getBlock() == Blocks.SNOW && aboveState.get(SnowBlock.LAYERS) == 1) {
if (aboveState.isOf(Blocks.SNOW) && aboveState.get(SnowBlock.LAYERS) == 1) {
return true;
} else if (aboveState.getFluidState().getLevel() == 8) {
return false;
} else {
int lightingAt = ChunkLightProvider.getRealisticOpacity(world, state, pos, aboveState, above, Direction.UP, aboveState.getOpacity(world, above));
return lightingAt < world.getMaxLightLevel();
int lightingAt = ChunkLightProvider.getRealisticOpacity(state, aboveState, Direction.UP, aboveState.getOpacity());
return lightingAt < MAX_LIGHT_LEVEL;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.block.Blocks;
import net.minecraft.entity.ai.goal.EatGrassGoal;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
Expand Down Expand Up @@ -52,7 +53,7 @@ public class MixinEatGrassGoal {
BlockState down = this.world.getBlockState(downPos);

if (down.isIn(TerraformDirtBlockTags.GRASS_BLOCKS)) {
if (this.world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
if (((ServerWorld) this.world).getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
this.world.syncWorldEvent(2001, downPos, Block.getRawIdFromState(Blocks.GRASS_BLOCK.getDefaultState()));

Block replacement = TerraformDirtRegistryImpl.getByGrassBlock(down.getBlock()).map(DirtBlocks::getDirt).orElse(Blocks.DIRT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import java.util.function.Predicate;

public final class TillableBlockRegistryImpl extends HoeItem {
private TillableBlockRegistryImpl(ToolMaterial material, Settings settings) {
super(material, settings);
private TillableBlockRegistryImpl(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
super(material, attackDamage, attackSpeed, settings);
return;
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,83 +1,35 @@
package com.terraformersmc.terraform.boat.api.client;

import com.terraformersmc.terraform.boat.impl.client.TerraformBoatClientHelperImpl;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry.TexturedModelDataProvider;
import net.minecraft.client.render.entity.model.BoatEntityModel;
import net.minecraft.client.render.entity.model.ChestBoatEntityModel;
import net.minecraft.client.render.entity.model.ChestRaftEntityModel;
import net.minecraft.client.render.entity.BoatEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.render.entity.model.RaftEntityModel;
import net.minecraft.util.Identifier;

@Environment(EnvType.CLIENT)
/**
* This class provides useful helpers for registering a {@linkplain com.terraformersmc.terraform.boat.api.TerraformBoatType Terraform boat} on the client.
* This class provides useful helpers for registering a {@linkplain net.minecraft.entity.vehicle.BoatEntity boat} on the client.
*/
@Environment(EnvType.CLIENT)
@SuppressWarnings("unused")
public final class TerraformBoatClientHelper {
private TerraformBoatClientHelper() {
return;
}

/**
* Gets the identifier of a {@linkplain EntityModelLayer model layer} for a boat of a given type.
* @param boatId the {@linkplain net.minecraft.util.Identifier identifier} of the {@linkplain com.terraformersmc.terraform.boat.api.TerraformBoatType boat}
* @param raft whether the boat is a raft
* @param chest whether the boat contains a chest
*/
private static Identifier getLayerId(Identifier boatId, boolean raft, boolean chest) {
String prefix = raft ? (chest ? "chest_raft/" : "raft/") : (chest ? "chest_boat/" : "boat/");
return boatId.withPrefixedPath(prefix);
}

/**
* Creates a {@linkplain EntityModelLayer model layer} for a boat of a given type.
* @param boatId the {@linkplain net.minecraft.util.Identifier identifier} of the {@linkplain com.terraformersmc.terraform.boat.api.TerraformBoatType boat}
* @param raft whether the boat is a raft
* @param chest whether the boat contains a chest
*
* <pre>{@code
* EntityModelLayer layer = TerraformBoatClientHelper.getLayer(Identifier.of("examplemod", "mahogany"), false, false);
* }</pre>
*/
public static EntityModelLayer getLayer(Identifier boatId, boolean raft, boolean chest) {
return new EntityModelLayer(getLayerId(boatId, raft, chest), "main");
}

private static TexturedModelDataProvider getTexturedModelDataProvider(boolean raft, boolean chest) {
if (raft) {
return chest ? ChestRaftEntityModel::getTexturedModelData : RaftEntityModel::getTexturedModelData;
} else {
return chest ? ChestBoatEntityModel::getTexturedModelData : BoatEntityModel::getTexturedModelData;
}
}

/**
* Registers a {@linkplain EntityModelLayer model layer} for a boat of a given type.
* @param boatId the {@linkplain net.minecraft.util.Identifier identifier} of the {@linkplain com.terraformersmc.terraform.boat.api.TerraformBoatType boat}
* @param raft whether the boat is a raft
* @param chest whether the boat contains a chest
*
* <pre>{@code
* TerraformBoatClientHelper.registerModelLayer(Identifier.of("examplemod", "mahogany"), false, false);
* }</pre>
*/
private static void registerModelLayer(Identifier boatId, boolean raft, boolean chest) {
EntityModelLayerRegistry.registerModelLayer(getLayer(boatId, raft, chest), getTexturedModelDataProvider(raft, chest));
}

/**
* Registers {@linkplain EntityModelLayer model layers} for a given boat type.
* @param boatId the {@linkplain net.minecraft.util.Identifier identifier} of the {@linkplain com.terraformersmc.terraform.boat.api.TerraformBoatType boat type}
* @param raft whether the boat is a raft
*
* Registers {@linkplain EntityModelLayer model layers} and
* {@linkplain BoatEntityRenderer entity renderers} for all boats of given boat type.
* The provided identifier must match the identifier used to
* {@linkplain com.terraformersmc.terraform.boat.api.item.TerraformBoatItemHelper#registerBoatItem register the boat type}.
*
* <pre>{@code
* TerraformBoatClientHelper.registerModelLayers(Identifier.of("examplemod", "mahogany"), false);
* TerraformBoatClientHelper.registerModelLayers(Identifier.of("examplemod", "mahogany"));
* }</pre>
*
* @param id the {@linkplain net.minecraft.util.Identifier identifier} of the boat type.
*/
public static void registerModelLayers(Identifier boatId, boolean raft) {
registerModelLayer(boatId, raft, false);
registerModelLayer(boatId, raft, true);
public static void registerModelLayers(Identifier id) {
TerraformBoatClientHelperImpl.registerModelLayers(id);
}
}
Loading

0 comments on commit 74c77f1

Please sign in to comment.