Skip to content

Commit

Permalink
WIP - Port to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperCode1 committed Jun 13, 2024
1 parent 4199527 commit 88b5978
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 106 deletions.
6 changes: 0 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ repositories {
name 'Modrinth'
url 'https://api.modrinth.com/maven'
}
maven {
name 'VRAM'
url 'https://maven.vram.io'
}
maven {
name 'Shedaniel'
url 'https://maven.shedaniel.me'
Expand All @@ -49,8 +45,6 @@ dependencies {
modImplementation("com.terraformersmc:modmenu:${modmenu_version}") {
exclude group: 'net.fabricmc.fabric-api'
}

modCompileOnly "io.vram:canvas-fabric:${canvas_version}"
}

processResources {
Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ org.gradle.parallel = true

# Fabric Properties
loom_version = 1.6.11
minecraft_version = 1.20.5
yarn_mappings = 1.20.5+build.1
loader_version = 0.15.10
minecraft_version = 1.21
yarn_mappings = 1.21+build.1
loader_version = 0.15.11

# Mod Properties
mod_version = 3.0.0-beta.5
mod_minecraft_version = 1.20.5
mod_minecraft_version = 1.21
maven_group = me.pepperbell
archives_base_name = continuity

# Dependencies
fabric_version = 0.97.6+1.20.5
modmenu_version = 10.0.0-beta.1
canvas_version = 20.2.2627
fabric_version = 0.100.1+1.21
modmenu_version = 11.0.0-beta.1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import me.pepperbell.continuity.client.resource.ModelWrappingHandler;
import me.pepperbell.continuity.client.util.RenderUtil;
import me.pepperbell.continuity.client.util.biome.BiomeHolderManager;
import me.pepperbell.continuity.client.util.biome.BiomeRetriever;
import me.pepperbell.continuity.impl.client.ProcessingDataKeyRegistryImpl;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
Expand All @@ -58,7 +57,6 @@ public class ContinuityClient implements ClientModInitializer {
public void onInitializeClient() {
ProcessingDataKeyRegistryImpl.INSTANCE.init();
BiomeHolderManager.init();
BiomeRetriever.init();
ProcessingDataKeys.init();
ModelWrappingHandler.init();
RenderUtil.ReloadListener.init();
Expand Down Expand Up @@ -270,6 +268,6 @@ private static <T extends CtmProperties> CtmProperties.Factory<T> wrapWithOptifi
}

public static Identifier asId(String path) {
return new Identifier(ID, path);
return Identifier.of(ID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ abstract class AtlasLoaderMixin {
Map<Identifier, Identifier> emissiveIdMap = new Object2ObjectOpenHashMap<>();
suppliers.forEach((id, supplier) -> {
if (!id.getPath().endsWith(emissiveSuffix)) {
Identifier emissiveId = new Identifier(id.getNamespace(), id.getPath() + emissiveSuffix);
Identifier emissiveId = id.withPath(id.getPath() + emissiveSuffix);
if (!suppliers.containsKey(emissiveId)) {
Identifier emissiveLocation = emissiveId.withPath("textures/" + emissiveId.getPath() + ".png");
Optional<Resource> optionalResource = resourceManager.getResource(emissiveLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import me.pepperbell.continuity.api.client.ProcessingDataProvider;
import me.pepperbell.continuity.client.properties.BaseCtmProperties;
import me.pepperbell.continuity.client.util.biome.BiomeRetriever;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadView;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
Expand Down Expand Up @@ -78,13 +77,14 @@ public static BaseProcessingPredicate fromProperties(BaseCtmProperties propertie
}

public static class BiomeCache {
@Nullable
protected Biome biome;
protected boolean invalid = true;

@Nullable
public Biome get(BlockRenderView blockView, BlockPos pos) {
if (invalid) {
biome = BiomeRetriever.getBiome(blockView, pos);
biome = blockView.hasBiomes() ? blockView.getBiomeFabric(pos).value() : null;
invalid = false;
}
return biome;
Expand All @@ -96,6 +96,7 @@ public void reset() {
}

public static class BlockEntityNameCache {
@Nullable
protected String blockEntityName;
protected boolean invalid = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected void detectMatches() {
if (matchBlocksPredicate == null) {
if (baseName.startsWith("block_")) {
try {
Identifier id = new Identifier(baseName.substring(6));
Identifier id = Identifier.of(baseName.substring(6));
if (Registries.BLOCK.containsId(id)) {
Block block = Registries.BLOCK.get(id);
matchBlocksPredicate = state -> state.getBlock() == block;
Expand Down Expand Up @@ -208,7 +208,7 @@ protected void parseTiles() {
if (min <= max) {
try {
for (int tile = min; tile <= max; tile++) {
listBuilder.add(new Identifier(resourceId.getNamespace(), basePath + tile + ".png"));
listBuilder.add(resourceId.withPath(basePath + tile + ".png"));
}
} catch (InvalidIdentifierException e) {
ContinuityClient.LOGGER.warn("Invalid 'tiles' element '" + tileStr + "' at index " + i + " in file '" + resourceId + "' in pack '" + packName + "'", e);
Expand Down Expand Up @@ -269,7 +269,7 @@ protected void parseTiles() {
}

try {
listBuilder.add(new Identifier(namespace, path));
listBuilder.add(Identifier.of(namespace, path));
} catch (InvalidIdentifierException e) {
ContinuityClient.LOGGER.warn("Invalid 'tiles' element '" + tileStr + "' at index " + i + " in file '" + resourceId + "' in pack '" + packName + "'", e);
}
Expand Down Expand Up @@ -353,7 +353,7 @@ protected void parseBiomes() {
}

try {
Identifier biomeId = new Identifier(biomeStr.toLowerCase(Locale.ROOT));
Identifier biomeId = Identifier.of(biomeStr.toLowerCase(Locale.ROOT));
biomeHolderSet.add(BiomeHolderManager.getOrCreateHolder(biomeId));
} catch (InvalidIdentifierException e) {
ContinuityClient.LOGGER.warn("Invalid 'biomes' element '" + biomeStr + "' at index " + i + " in file '" + resourceId + "' in pack '" + packName + "'", e);
Expand Down Expand Up @@ -584,7 +584,7 @@ protected void parseResourceCondition() {
String resourceStr = parts[0];
Identifier resourceId;
try {
resourceId = new Identifier(resourceStr);
resourceId = Identifier.of(resourceStr);
} catch (InvalidIdentifierException e) {
ContinuityClient.LOGGER.warn("Invalid resource '" + resourceStr + "' in 'resourceCondition' element '" + conditionStr + "' at index " + i + " in file '" + this.resourceId + "' in pack '" + packName + "'", e);
continue;
Expand Down Expand Up @@ -643,12 +643,12 @@ protected void resolveTiles() {
path = path.substring(0, path.length() - 4);
}

spriteId = TextureUtil.toSpriteId(new Identifier(namespace, path));
spriteId = TextureUtil.toSpriteId(Identifier.of(namespace, path));
textureDependencies.add(spriteId);
} else if (redirectHandler != null) {
path = redirectHandler.getSourceSpritePath(path);

spriteId = TextureUtil.toSpriteId(new Identifier(namespace, path));
spriteId = TextureUtil.toSpriteId(Identifier.of(namespace, path));
textureDependencies.add(spriteId);
} else {
spriteId = TextureUtil.MISSING_SPRITE_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static Set<Identifier> parseMatchTiles(Properties properties, String prop
}

try {
set.add(new Identifier(namespace, path));
set.add(Identifier.of(namespace, path));
} catch (InvalidIdentifierException e) {
ContinuityClient.LOGGER.warn("Invalid '" + propertyKey + "' element '" + matchTileStr + "' at index " + i + " in file '" + fileLocation + "' in pack '" + packName + "'", e);
}
Expand Down Expand Up @@ -137,10 +137,10 @@ public static Predicate<BlockState> parseBlockStates(Properties properties, Stri
int startIndex;
try {
if (parts.length == 1 || parts[1].contains("=")) {
blockId = new Identifier(parts[0]);
blockId = Identifier.ofVanilla(parts[0]);
startIndex = 1;
} else {
blockId = new Identifier(parts[0], parts[1]);
blockId = Identifier.of(parts[0], parts[1]);
startIndex = 2;
}
} catch (InvalidIdentifierException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ protected void parseTintBlock() {
Identifier blockId;
try {
if (parts.length == 1 || parts[1].contains("=")) {
blockId = new Identifier(parts[0]);
blockId = Identifier.ofVanilla(parts[0]);
} else {
blockId = new Identifier(parts[0], parts[1]);
blockId = Identifier.of(parts[0], parts[1]);
}
} catch (InvalidIdentifierException e) {
ContinuityClient.LOGGER.warn("Invalid 'tintBlock' value '" + tintBlockStr + "' in file '" + id + "' in pack '" + packName + "'", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.minecraft.world.EmptyBlockView;

public final class CustomBlockLayers {
public static final Identifier LOCATION = new Identifier("optifine/block.properties");
public static final Identifier LOCATION = Identifier.ofVanilla("optifine/block.properties");

@SuppressWarnings("unchecked")
private static final Predicate<BlockState>[] EMPTY_LAYER_PREDICATES = new Predicate[BlockLayer.VALUES.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import net.minecraft.util.Identifier;

public final class EmissiveSuffixLoader {
public static final Identifier LOCATION = new Identifier("optifine/emissive.properties");
public static final Identifier LOCATION = Identifier.ofVanilla("optifine/emissive.properties");

private static String emissiveSuffix;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;

import com.google.common.collect.ImmutableMap;

Expand Down Expand Up @@ -51,11 +52,11 @@ private static ImmutableMap<ModelIdentifier, BlockState> createBlockStateModelId
return builder.build();
}

public BakedModel wrap(@Nullable BakedModel model, Identifier modelId) {
if (model != null && !model.isBuiltin() && !modelId.equals(ModelLoader.MISSING_ID)) {
public BakedModel wrap(@Nullable BakedModel model, @UnknownNullability Identifier resourceId, @UnknownNullability ModelIdentifier topLevelId) {
if (model != null && !model.isBuiltin() && (resourceId == null || !resourceId.equals(ModelLoader.MISSING_ID))) {
if (wrapCtm) {
if (modelId instanceof ModelIdentifier) {
BlockState state = blockStateModelIds.get(modelId);
if (topLevelId != null) {
BlockState state = blockStateModelIds.get(topLevelId);
if (state != null) {
model = new CtmBakedModel(model, state);
}
Expand All @@ -75,7 +76,7 @@ public static void init() {
ModelLoader modelLoader = ctx.loader();
ModelWrappingHandler wrappingHandler = ((ModelLoaderExtension) modelLoader).continuity$getModelWrappingHandler();
if (wrappingHandler != null) {
return wrappingHandler.wrap(model, ctx.id());
return wrappingHandler.wrap(model, ctx.resourceId(), ctx.topLevelId());
}
return model;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Identifier redirect(Identifier id) {

BooleanState invalidIdentifierState = InvalidIdentifierStateHolder.get();
invalidIdentifierState.enable();
Identifier newId = new Identifier(id.getNamespace(), newPath);
Identifier newId = id.withPath(newPath);
invalidIdentifierState.disable();

return newId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void refreshHolders() {
String path = id.getPath();
String compactPath = path.replace("_", "");
if (!path.equals(compactPath)) {
Identifier compactId = new Identifier(id.getNamespace(), compactPath);
Identifier compactId = id.withPath(compactPath);
if (!biomeRegistry.containsId(compactId)) {
compactIdMap.put(compactId, id);
}
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
],

"depends": {
"minecraft": ">=1.20.5",
"minecraft": ">=1.21",
"fabricloader": ">=0.15.0",
"fabric-api": ">=0.97.6"
"fabric-api": ">=0.100.1"
},

"custom": {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/resourcepacks/default/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pack": {
"pack_format": 32,
"supported_formats": [32, 999],
"pack_format": 34,
"supported_formats": [34, 999],
"description": {
"translate": "resourcePack.continuity.default.description"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pack": {
"pack_format": 32,
"supported_formats": [32, 999],
"pack_format": 34,
"supported_formats": [34, 999],
"description": {
"translate": "resourcePack.continuity.glass_pane_culling_fix.description"
}
Expand Down

0 comments on commit 88b5978

Please sign in to comment.