Skip to content

Commit

Permalink
First pass at an update to 1.21.2.
Browse files Browse the repository at this point in the history
- Make it build against 1.21.2
- Fix broken things
- Replace basically all of the boat API
  • Loading branch information
gniftygnome committed Oct 12, 2024
1 parent a7ac9de commit b323b57
Show file tree
Hide file tree
Showing 38 changed files with 449 additions and 1,080 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-pre3
yarn_mappings=1.21.2-pre3+build.3
loader_version=0.16.7
fabric_version=0.105.4+1.21.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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 b323b57

Please sign in to comment.