Skip to content

Commit

Permalink
Update mod to Minecraft 1.21 pre-release 1
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed May 30, 2024
1 parent 039770f commit 29f9b33
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 45 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fabric.loom.multiProjectOptimisation=true
maven_group=com.terraformersmc.terraform-api
version=10.0.0

minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
minecraft_version=1.21-pre1
yarn_mappings=1.21-pre1+build.3
loader_version=0.15.11
fabric_version=0.99.0+1.20.6
fabric_version=0.99.2+1.21
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;

import java.util.Map;
Expand All @@ -11,7 +12,7 @@ public class BiomeIdFixData {

public static void applyFabricDynamicRegistryMap(Map<Identifier, Object2IntMap<Identifier>> registryMap) {
ACTIVE_BIOME_RAW_ID_MAP = new Int2ObjectArrayMap<>();
for (Object2IntMap.Entry<Identifier> entry : registryMap.get(new Identifier("minecraft", "worldgen/biome")).object2IntEntrySet()) {
for (Object2IntMap.Entry<Identifier> entry : registryMap.get(RegistryKeys.BIOME.getValue()).object2IntEntrySet()) {
ACTIVE_BIOME_RAW_ID_MAP.put(entry.getIntValue(), entry.getKey());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ private TerraformDirtBlockTags() {
}

private static TagKey<Block> register(String id) {
return TagKey.of(RegistryKeys.BLOCK, new Identifier("terraform", id));
return TagKey.of(RegistryKeys.BLOCK, Identifier.of("terraform", id));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @see TerraformBoatTypeRegistry#INSTANCE
*/
public class TerraformBoatTypeRegistry {
private static final Identifier REGISTRY_ID = new Identifier("terraform", "boat");
private static final Identifier REGISTRY_ID = Identifier.of("terraform", "boat");
private static final RegistryKey<Registry<TerraformBoatType>> REGISTRY_KEY = RegistryKey.ofRegistry(REGISTRY_ID);

/**
* The registry for {@linkplain TerraformBoatType Terraform boats}.
Expand All @@ -18,15 +19,15 @@ public class TerraformBoatTypeRegistry {
* <p>To register a boat type:
*
* <pre>{@code
* Registry.register(TerraformBoatType.REGISTRY, new Identifier("examplemod", "mahogany"), boat);
* Registry.register(TerraformBoatType.REGISTRY, Identifier.of("examplemod", "mahogany"), boat);
* }</pre>
*
* @see com.terraformersmc.terraform.boat.api.TerraformBoatType.Builder The builder for boat types
* @see com.terraformersmc.terraform.boat.api.client.TerraformBoatClientHelper Helpers for registering the boat on the client
*/
public static final Registry<TerraformBoatType> INSTANCE = FabricRegistryBuilder.createSimple(TerraformBoatType.class, REGISTRY_ID).buildAndRegister();
public static final Registry<TerraformBoatType> INSTANCE = FabricRegistryBuilder.createSimple(REGISTRY_KEY).buildAndRegister();

public static RegistryKey<TerraformBoatType> createKey(Identifier id) {
return RegistryKey.of(INSTANCE.getKey(), id);
return RegistryKey.of(REGISTRY_KEY, id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private TerraformBoatClientHelper() {
*/
private static Identifier getLayerId(Identifier boatId, boolean raft, boolean chest) {
String prefix = raft ? (chest ? "chest_raft/" : "raft/") : (chest ? "chest_boat/" : "boat/");
return new Identifier(boatId.getNamespace(), prefix + boatId.getPath());
return boatId.withPrefixedPath(prefix);
}

/**
Expand All @@ -38,7 +38,7 @@ private static Identifier getLayerId(Identifier boatId, boolean raft, boolean ch
* @param chest whether the boat contains a chest
*
* <pre>{@code
* EntityModelLayer layer = TerraformBoatClientHelper.getLayer(new Identifier("examplemod", "mahogany"), false, false);
* EntityModelLayer layer = TerraformBoatClientHelper.getLayer(Identifier.of("examplemod", "mahogany"), false, false);
* }</pre>
*/
public static EntityModelLayer getLayer(Identifier boatId, boolean raft, boolean chest) {
Expand All @@ -60,7 +60,7 @@ private static TexturedModelDataProvider getTexturedModelDataProvider(boolean ra
* @param chest whether the boat contains a chest
*
* <pre>{@code
* TerraformBoatClientHelper.registerModelLayer(new Identifier("examplemod", "mahogany"), false, false);
* TerraformBoatClientHelper.registerModelLayer(Identifier.of("examplemod", "mahogany"), false, false);
* }</pre>
*/
private static void registerModelLayer(Identifier boatId, boolean raft, boolean chest) {
Expand All @@ -73,7 +73,7 @@ private static void registerModelLayer(Identifier boatId, boolean raft, boolean
* @param raft whether the boat is a raft
*
* <pre>{@code
* TerraformBoatClientHelper.registerModelLayers(new Identifier("examplemod", "mahogany"), false);
* TerraformBoatClientHelper.registerModelLayers(Identifier.of("examplemod", "mahogany"), false);
* }</pre>
*/
public static void registerModelLayers(Identifier boatId, boolean raft) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private TerraformBoatItemHelper() {
* <p>To register a boat item and its dispenser behavior:
*
* <pre>{@code
* TerraformBoatItemHelper.registerBoatItem(new Identifier("examplemod", "mahogany_boat"), MAHOGANY_BOAT_KEY, false);
* TerraformBoatItemHelper.registerBoatItem(Identifier.of("examplemod", "mahogany_boat"), MAHOGANY_BOAT_KEY, false);
* }</pre>
*
* <p>This method should be called twice for a given boat type for both boats and chest boats.
Expand All @@ -51,7 +51,7 @@ public static Item registerBoatItem(Identifier id, RegistryKey<TerraformBoatType
* <p>To register a boat item and its dispenser behavior:
*
* <pre>{@code
* TerraformBoatItemHelper.registerBoatItem(new Identifier("examplemod", "mahogany_boat"), MAHOGANY_BOAT_KEY, false, new Item.Settings().maxCount(1));
* TerraformBoatItemHelper.registerBoatItem(Identifier.of("examplemod", "mahogany_boat"), MAHOGANY_BOAT_KEY, false, new Item.Settings().maxCount(1));
* }</pre>
*
* <p>This method should be called twice for a given boat type for both boats and chest boats.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@
import com.terraformersmc.terraform.boat.impl.entity.TerraformChestBoatEntity;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public final class TerraformBoatInitializer implements ModInitializer {
private static final EntityDimensions DIMENSIONS = EntityDimensions.fixed(1.375f, 0.5625f);
private static final float DIMENSIONS_WIDTH = 1.375f;
private static final float DIMENSIONS_HEIGHT = 0.5625f;

// Hack that prevents the following crash during client startup:
// Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.terraformersmc.terraform.boat.api.TerraformBoatTypeRegistry
private static final Registry<TerraformBoatType> registryInstance = TerraformBoatTypeRegistry.INSTANCE;

private static final Identifier BOAT_ID = new Identifier("terraform", "boat");
public static final EntityType<TerraformBoatEntity> BOAT = FabricEntityTypeBuilder.<TerraformBoatEntity>create(SpawnGroup.MISC, TerraformBoatEntity::new)
.dimensions(DIMENSIONS)
private static final Identifier BOAT_ID = Identifier.of("terraform", "boat");
public static final EntityType<TerraformBoatEntity> BOAT = EntityType.Builder.<TerraformBoatEntity>create(TerraformBoatEntity::new, SpawnGroup.MISC)
.dimensions(DIMENSIONS_WIDTH, DIMENSIONS_HEIGHT)
.build();

private static final Identifier CHEST_BOAT_ID = new Identifier("terraform", "chest_boat");
public static final EntityType<TerraformChestBoatEntity> CHEST_BOAT = FabricEntityTypeBuilder.<TerraformChestBoatEntity>create(SpawnGroup.MISC, TerraformChestBoatEntity::new)
.dimensions(DIMENSIONS)
private static final Identifier CHEST_BOAT_ID = Identifier.of("terraform", "chest_boat");
public static final EntityType<TerraformChestBoatEntity> CHEST_BOAT = EntityType.Builder.<TerraformChestBoatEntity>create(TerraformChestBoatEntity::new, SpawnGroup.MISC)
.dimensions(DIMENSIONS_WIDTH, DIMENSIONS_HEIGHT)
.build();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public TerraformBoatEntityRenderer(EntityRendererFactory.Context context, boolea
String prefix = raft ? (chest ? "chest_raft/" : "raft/") : (chest ? "chest_boat/" : "boat/");

Identifier id = entry.getKey().getValue();
Identifier textureId = new Identifier(id.getNamespace(), "textures/entity/" + prefix + id.getPath() + ".png");
Identifier textureId = id.withPath(path -> "textures/entity/" + prefix + path + ".png");

EntityModelLayer layer = TerraformBoatClientHelper.getLayer(id, raft, chest);
CompositeEntityModel<BoatEntity> model = createModel(context.getPart(layer), raft, chest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MixinHangingSignEditScreen {
private void terraformWood$initSignTextureId(SignBlockEntity signBlockEntity, boolean front, boolean filtered, CallbackInfo ci) {
if (signBlockEntity.getCachedState().getBlock() instanceof TerraformHangingSign signBlock) {
Identifier guiTexture = signBlock.getGuiTexture();
this.texture = new Identifier(guiTexture.getNamespace(), guiTexture.getPath() + ".png");
this.texture = guiTexture.withSuffixedPath(".png");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.terraformersmc.terraform.wood.block;

import net.minecraft.block.*;
import net.minecraft.block.enums.Instrument;
import net.minecraft.block.enums.NoteBlockInstrument;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.Direction;

Expand All @@ -17,7 +17,7 @@ public class PillarLogHelper {
public static PillarBlock of(MapColor color) {
return new PillarBlock(AbstractBlock.Settings.create()
.mapColor(color)
.instrument(Instrument.BASS)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
Expand All @@ -35,7 +35,7 @@ public static PillarBlock of(MapColor color) {
public static PillarBlock of(MapColor wood, MapColor bark) {
return new PillarBlock(AbstractBlock.Settings.create()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.instrument(Instrument.BASS)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
Expand All @@ -52,7 +52,7 @@ public static PillarBlock of(MapColor wood, MapColor bark) {
public static PillarBlock ofNether(MapColor color) {
return new PillarBlock(AbstractBlock.Settings.create()
.mapColor(color)
.instrument(Instrument.BASS)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM)
);
Expand All @@ -69,7 +69,7 @@ public static PillarBlock ofNether(MapColor color) {
public static PillarBlock ofNether(MapColor wood, MapColor bark) {
return new PillarBlock(AbstractBlock.Settings.create()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.instrument(Instrument.BASS)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.client.util.ParticleUtil;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.particle.ParticleUtil;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@
public class TerraformWoodTest implements ModInitializer {
private static final String MOD_ID = "terraform";

private static final Identifier CUSTOM_PLANKS_ID = new Identifier(MOD_ID, "custom_planks");
private static final Identifier CUSTOM_PLANKS_ID = Identifier.of(MOD_ID, "custom_planks");

protected static final Identifier CUSTOM_BOAT_ID = new Identifier(MOD_ID, "custom_boat");
private static final Identifier CUSTOM_CHEST_BOAT_ID = new Identifier(MOD_ID, "custom_chest_boat");
protected static final Identifier CUSTOM_RAFT_ID = new Identifier(MOD_ID, "custom_raft");
private static final Identifier CUSTOM_CHEST_RAFT_ID = new Identifier(MOD_ID, "custom_chest_raft");
protected static final Identifier CUSTOM_BOAT_ID = Identifier.of(MOD_ID, "custom_boat");
private static final Identifier CUSTOM_CHEST_BOAT_ID = Identifier.of(MOD_ID, "custom_chest_boat");
protected static final Identifier CUSTOM_RAFT_ID = Identifier.of(MOD_ID, "custom_raft");
private static final Identifier CUSTOM_CHEST_RAFT_ID = Identifier.of(MOD_ID, "custom_chest_raft");

public static final RegistryKey<TerraformBoatType> CUSTOM_BOAT_KEY = TerraformBoatTypeRegistry.createKey(CUSTOM_BOAT_ID);
public static final RegistryKey<TerraformBoatType> CUSTOM_RAFT_KEY = TerraformBoatTypeRegistry.createKey(CUSTOM_RAFT_ID);

protected static final Identifier SIGN_TEXTURE_ID = new Identifier(MOD_ID, "entity/signs/custom");
protected static final Identifier HANGING_SIGN_TEXTURE_ID = new Identifier(MOD_ID, "entity/signs/hanging/custom");
protected static final Identifier HANGING_SIGN_GUI_TEXTURE_ID = new Identifier(MOD_ID, "textures/gui/hanging_signs/custom");
private static final Identifier CUSTOM_SIGN_ID = new Identifier(MOD_ID, "custom_sign");
private static final Identifier CUSTOM_WALL_SIGN_ID = new Identifier(MOD_ID, "custom_wall_sign");
private static final Identifier CUSTOM_HANGING_SIGN_ID = new Identifier(MOD_ID, "custom_hanging_sign");
private static final Identifier CUSTOM_WALL_HANGING_SIGN_ID = new Identifier(MOD_ID, "custom_wall_hanging_sign");
protected static final Identifier SIGN_TEXTURE_ID = Identifier.of(MOD_ID, "entity/signs/custom");
protected static final Identifier HANGING_SIGN_TEXTURE_ID = Identifier.of(MOD_ID, "entity/signs/hanging/custom");
protected static final Identifier HANGING_SIGN_GUI_TEXTURE_ID = Identifier.of(MOD_ID, "textures/gui/hanging_signs/custom");
private static final Identifier CUSTOM_SIGN_ID = Identifier.of(MOD_ID, "custom_sign");
private static final Identifier CUSTOM_WALL_SIGN_ID = Identifier.of(MOD_ID, "custom_wall_sign");
private static final Identifier CUSTOM_HANGING_SIGN_ID = Identifier.of(MOD_ID, "custom_hanging_sign");
private static final Identifier CUSTOM_WALL_HANGING_SIGN_ID = Identifier.of(MOD_ID, "custom_wall_hanging_sign");

@Override
public void onInitialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.minecraft.util.math.Vec3d;

public final class SpawnBoatsCommand {
private static final Identifier ADVANCEMENT_ID = new Identifier("husbandry/ride_a_boat_with_a_goat");
private static final Identifier ADVANCEMENT_ID = Identifier.ofVanilla("husbandry/ride_a_boat_with_a_goat");

private SpawnBoatsCommand() {
return;
Expand Down

0 comments on commit 29f9b33

Please sign in to comment.