Skip to content

Commit

Permalink
Port to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperCode1 committed Nov 22, 2024
1 parent 31f39fd commit 1b31e2b
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 85 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Fabric Properties
loom_version = 1.6.11
minecraft_version = 1.21
yarn_mappings = 1.21+build.1
loader_version = 0.15.11
loom_version = 1.8.12
minecraft_version = 1.21.3
yarn_mappings = 1.21.3+build.2
loader_version = 0.16.9

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

# Dependencies
fabric_version = 0.100.1+1.21
modmenu_version = 11.0.0-beta.1
fabric_version = 0.107.3+1.21.3
modmenu_version = 12.0.0-beta.1
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
2 changes: 2 additions & 0 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

import com.llamalad7.mixinextras.injector.ModifyReturnValue;

import it.unimi.dsi.fastutil.objects.Object2IntMap;
import me.pepperbell.continuity.client.resource.BakedModelManagerReloadExtension;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.ModelBaker;
import net.minecraft.client.render.model.SpriteAtlasManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceReloader;
Expand All @@ -29,8 +31,8 @@ abstract class BakedModelManagerMixin {
@Nullable
private volatile BakedModelManagerReloadExtension continuity$reloadExtension;

@Inject(method = "reload(Lnet/minecraft/resource/ResourceReloader$Synchronizer;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;Lnet/minecraft/util/profiler/Profiler;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("HEAD"))
private void continuity$onHeadReload(ResourceReloader.Synchronizer synchronizer, ResourceManager resourceManager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
@Inject(method = "reload(Lnet/minecraft/resource/ResourceReloader$Synchronizer;Lnet/minecraft/resource/ResourceManager;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("HEAD"))
private void continuity$onHeadReload(ResourceReloader.Synchronizer synchronizer, ResourceManager resourceManager, Executor prepareExecutor, Executor applyExecutor, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
continuity$reloadExtension = new BakedModelManagerReloadExtension(resourceManager, prepareExecutor);

BakedModelManagerReloadExtension reloadExtension = continuity$reloadExtension;
Expand All @@ -39,24 +41,24 @@ abstract class BakedModelManagerMixin {
}
}

@Inject(method = "reload(Lnet/minecraft/resource/ResourceReloader$Synchronizer;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;Lnet/minecraft/util/profiler/Profiler;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
@Inject(method = "reload(Lnet/minecraft/resource/ResourceReloader$Synchronizer;Lnet/minecraft/resource/ResourceManager;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
private void continuity$onReturnReload(CallbackInfoReturnable<CompletableFuture<Void>> cir) {
BakedModelManagerReloadExtension reloadExtension = continuity$reloadExtension;
if (reloadExtension != null) {
reloadExtension.clearContext();
}
}

@ModifyReturnValue(method = "reload(Lnet/minecraft/resource/ResourceReloader$Synchronizer;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;Lnet/minecraft/util/profiler/Profiler;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
@ModifyReturnValue(method = "reload(Lnet/minecraft/resource/ResourceReloader$Synchronizer;Lnet/minecraft/resource/ResourceManager;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
private CompletableFuture<Void> continuity$modifyReturnReload(CompletableFuture<Void> original) {
return original.thenRun(() -> continuity$reloadExtension = null);
}

@Inject(method = "bake(Lnet/minecraft/util/profiler/Profiler;Ljava/util/Map;Lnet/minecraft/client/render/model/ModelLoader;)Lnet/minecraft/client/render/model/BakedModelManager$BakingResult;", at = @At("HEAD"))
private void continuity$onHeadBake(Profiler profiler, Map<Identifier, SpriteAtlasManager.AtlasPreparation> preparations, ModelLoader modelLoader, CallbackInfoReturnable<?> cir) {
@Inject(method = "bake(Lnet/minecraft/util/profiler/Profiler;Ljava/util/Map;Lnet/minecraft/client/render/model/ModelBaker;Lit/unimi/dsi/fastutil/objects/Object2IntMap;)Lnet/minecraft/client/render/model/BakedModelManager$BakingResult;", at = @At("HEAD"))
private void continuity$onHeadBake(Profiler profiler, Map<Identifier, SpriteAtlasManager.AtlasPreparation> preparations, ModelBaker bakery, Object2IntMap<BlockState> modelGroups, CallbackInfoReturnable<?> cir) {
BakedModelManagerReloadExtension reloadExtension = continuity$reloadExtension;
if (reloadExtension != null) {
reloadExtension.beforeBaking(preparations, modelLoader);
reloadExtension.beforeBaking(preparations);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

@Mixin(FallingBlockEntityRenderer.class)
abstract class FallingBlockEntityRendererMixin {
@Inject(method = "render(Lnet/minecraft/entity/FallingBlockEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModelRenderer;render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V"))
@Inject(method = "render(Lnet/minecraft/client/render/entity/state/FallingBlockEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModelRenderer;render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V"))
private void continuity$beforeRenderModel(CallbackInfo ci) {
ContinuityFeatureStates states = ContinuityFeatureStates.get();
states.getConnectedTexturesState().disable();
states.getEmissiveTexturesState().disable();
}

@Inject(method = "render(Lnet/minecraft/entity/FallingBlockEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModelRenderer;render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V", shift = At.Shift.AFTER))
@Inject(method = "render(Lnet/minecraft/client/render/entity/state/FallingBlockEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/BlockModelRenderer;render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V", shift = At.Shift.AFTER))
private void continuity$afterRenderModel(CallbackInfo ci) {
ContinuityFeatureStates states = ContinuityFeatureStates.get();
states.getConnectedTexturesState().enable();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected boolean appliesOverlayCorner(Direction dir0, Direction dir1, BlockPos.
BlockState otherAppearanceState = otherState.getAppearance(blockView, mutablePos, lightFace, state, pos);
if (appliesOverlay(otherAppearanceState, otherState, mutablePos, blockView, appearanceState, state, pos, lightFace, quadSprite)) {
mutablePos.move(lightFace);
return !blockView.getBlockState(mutablePos).isOpaqueFullCube(blockView, mutablePos);
return !blockView.getBlockState(mutablePos).isOpaqueFullCube();
}
return false;
}
Expand Down Expand Up @@ -219,7 +219,7 @@ protected OverlayEmitter getEmitter(BlockRenderView blockView, BlockState appear

mutablePos.set(pos, directions[0]).move(lightFace);
BlockState appearanceState0;
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube(blockView, mutablePos)) {
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube()) {
mutablePos.set(pos, directions[0]);
BlockState state0 = blockView.getBlockState(mutablePos);
appearanceState0 = state0.getAppearance(blockView, mutablePos, lightFace, state, pos);
Expand All @@ -232,7 +232,7 @@ protected OverlayEmitter getEmitter(BlockRenderView blockView, BlockState appear

mutablePos.set(pos, directions[1]).move(lightFace);
BlockState appearanceState1;
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube(blockView, mutablePos)) {
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube()) {
mutablePos.set(pos, directions[1]);
BlockState state1 = blockView.getBlockState(mutablePos);
appearanceState1 = state1.getAppearance(blockView, mutablePos, lightFace, state, pos);
Expand All @@ -245,7 +245,7 @@ protected OverlayEmitter getEmitter(BlockRenderView blockView, BlockState appear

mutablePos.set(pos, directions[2]).move(lightFace);
BlockState appearanceState2;
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube(blockView, mutablePos)) {
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube()) {
mutablePos.set(pos, directions[2]);
BlockState state2 = blockView.getBlockState(mutablePos);
appearanceState2 = state2.getAppearance(blockView, mutablePos, lightFace, state, pos);
Expand All @@ -258,7 +258,7 @@ protected OverlayEmitter getEmitter(BlockRenderView blockView, BlockState appear

mutablePos.set(pos, directions[3]).move(lightFace);
BlockState appearanceState3;
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube(blockView, mutablePos)) {
if (!blockView.getBlockState(mutablePos).isOpaqueFullCube()) {
mutablePos.set(pos, directions[3]);
BlockState state3 = blockView.getBlockState(mutablePos);
appearanceState3 = state3.getAppearance(blockView, mutablePos, lightFace, state, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import org.jetbrains.annotations.Nullable;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.pepperbell.continuity.client.mixinterface.ModelLoaderExtension;
import me.pepperbell.continuity.client.model.QuadProcessors;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.SpriteAtlasManager;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
Expand All @@ -29,6 +27,7 @@ public BakedModelManagerReloadExtension(ResourceManager resourceManager, Executo
ctmLoadingResultFuture = CompletableFuture.supplyAsync(() -> CtmPropertiesLoader.loadAllWithState(resourceManager), prepareExecutor);
spriteLoaderLoadContext = new SpriteLoaderLoadContextImpl(ctmLoadingResultFuture.thenApply(CtmPropertiesLoader.LoadingResult::getTextureDependencies), wrapEmissiveModels);
EmissiveSuffixLoader.load(resourceManager);
ModelWrappingHandler.resetInstance();
}

public void setContext() {
Expand All @@ -39,7 +38,7 @@ public void clearContext() {
SpriteLoaderLoadContext.THREAD_LOCAL.set(null);
}

public void beforeBaking(Map<Identifier, SpriteAtlasManager.AtlasPreparation> preparations, ModelLoader modelLoader) {
public void beforeBaking(Map<Identifier, SpriteAtlasManager.AtlasPreparation> preparations) {
CtmPropertiesLoader.LoadingResult result = ctmLoadingResultFuture.join();

List<QuadProcessors.ProcessorHolder> processorHolders = result.createProcessorHolders(spriteId -> {
Expand All @@ -53,8 +52,7 @@ public void beforeBaking(Map<Identifier, SpriteAtlasManager.AtlasPreparation> pr

this.processorHolders = processorHolders;

ModelWrappingHandler wrappingHandler = ModelWrappingHandler.create(!processorHolders.isEmpty(), wrapEmissiveModels.get());
((ModelLoaderExtension) modelLoader).continuity$setModelWrappingHandler(wrappingHandler);
ModelWrappingHandler.setInstance(!processorHolders.isEmpty(), wrapEmissiveModels.get());
}

public void apply() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EmptyBlockView;

public final class CustomBlockLayers {
public static final Identifier LOCATION = Identifier.ofVanilla("optifine/block.properties");
Expand All @@ -42,7 +40,7 @@ public static boolean isEmpty() {
@Nullable
public static RenderLayer getLayer(BlockState state) {
if (!disableSolidCheck) {
if (state.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN)) {
if (state.isOpaqueFullCube()) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.google.common.collect.ImmutableMap;

import me.pepperbell.continuity.client.mixinterface.ModelLoaderExtension;
import me.pepperbell.continuity.client.model.CtmBakedModel;
import me.pepperbell.continuity.client.model.EmissiveBakedModel;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
Expand All @@ -15,12 +14,15 @@
import net.minecraft.block.BlockState;
import net.minecraft.client.render.block.BlockModels;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.MissingModel;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;

public class ModelWrappingHandler {
@Nullable
private static volatile ModelWrappingHandler instance;

private final boolean wrapCtm;
private final boolean wrapEmissive;
private final ImmutableMap<ModelIdentifier, BlockState> blockStateModelIds;
Expand All @@ -32,11 +34,19 @@ private ModelWrappingHandler(boolean wrapCtm, boolean wrapEmissive) {
}

@Nullable
public static ModelWrappingHandler create(boolean wrapCtm, boolean wrapEmissive) {
public static ModelWrappingHandler getInstance() {
return instance;
}

public static void setInstance(boolean wrapCtm, boolean wrapEmissive) {
if (!wrapCtm && !wrapEmissive) {
return null;
return;
}
return new ModelWrappingHandler(wrapCtm, wrapEmissive);
instance = new ModelWrappingHandler(wrapCtm, wrapEmissive);
}

public static void resetInstance() {
instance = null;
}

private static ImmutableMap<ModelIdentifier, BlockState> createBlockStateModelIdMap() {
Expand All @@ -53,7 +63,7 @@ private static ImmutableMap<ModelIdentifier, BlockState> createBlockStateModelId
}

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 (model != null && !model.isBuiltin() && (resourceId == null || !resourceId.equals(MissingModel.ID))) {
if (wrapCtm) {
if (topLevelId != null) {
BlockState state = blockStateModelIds.get(topLevelId);
Expand All @@ -73,8 +83,7 @@ public BakedModel wrap(@Nullable BakedModel model, @UnknownNullability Identifie
public static void init() {
ModelLoadingPlugin.register(pluginCtx -> {
pluginCtx.modifyModelAfterBake().register(ModelModifier.WRAP_LAST_PHASE, (model, ctx) -> {
ModelLoader modelLoader = ctx.loader();
ModelWrappingHandler wrappingHandler = ((ModelLoaderExtension) modelLoader).continuity$getModelWrappingHandler();
ModelWrappingHandler wrappingHandler = getInstance();
if (wrappingHandler != null) {
return wrappingHandler.wrap(model, ctx.resourceId(), ctx.topLevelId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void refreshHolders() {
}

Map<Identifier, Identifier> compactIdMap = new Object2ObjectOpenHashMap<>();
Registry<Biome> biomeRegistry = registryManager.get(RegistryKeys.BIOME);
Registry<Biome> biomeRegistry = registryManager.getOrThrow(RegistryKeys.BIOME);
for (Identifier id : biomeRegistry.getIds()) {
String path = id.getPath();
String compactPath = path.replace("_", "");
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/continuity.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"FallingBlockEntityRendererMixin",
"IdentifierMixin",
"LifecycledResourceManagerImplMixin",
"ModelLoaderMixin",
"NamespaceResourceManagerMixin",
"PistonBlockEntityRendererMixin",
"ReloadableResourceManagerImplAccessor",
Expand Down
Loading

0 comments on commit 1b31e2b

Please sign in to comment.