Skip to content

Commit

Permalink
Update to 1.18.2
Browse files Browse the repository at this point in the history
- Update biome code
- Update resource redirect code
- Switch to slf4j logging
- Update build dependencies
  • Loading branch information
PepperCode1 committed Mar 5, 2022
1 parent 8dacb5d commit 7cdd123
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 44 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ dependencies {
// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation('com.terraformersmc:modmenu:3.0.1') {
modImplementation('com.terraformersmc:modmenu:3.1.0') {
exclude group: 'net.fabricmc.fabric-api'
}

modCompileOnly 'maven.modrinth:sodium:mc1.18.1-0.4.0-alpha6'
modCompileOnly 'io.vram:canvas-fabric-mc118:1.0.2291'
modCompileOnly 'maven.modrinth:sodium:mc1.18.2-0.4.1'
modCompileOnly 'io.vram:canvas-fabric-mc118:1.0.2308'
}

String getExtraBuildMetadata() {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs = -Xmx1G

# Fabric Properties
loom_version = 0.11-SNAPSHOT
minecraft_version = 1.18.1
yarn_mappings = 1.18.1+build.22
loader_version = 0.13.2
minecraft_version = 1.18.2
yarn_mappings = 1.18.2+build.2
loader_version = 0.13.3

# Mod Properties
mod_version = 1.1.0
mod_minecraft_version = 1.18
mod_minecraft_version = 1.18.2
maven_group = me.pepperbell
archives_base_name = continuity

# Dependencies
fabric_version = 0.46.4+1.18
fabric_version = 0.47.10+1.18.2
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.pepperbell.continuity.api.client.CTMLoader;
Expand Down Expand Up @@ -58,7 +58,7 @@
public class ContinuityClient implements ClientModInitializer {
public static final String ID = "continuity";
public static final String NAME = "Continuity";
public static final Logger LOGGER = LogManager.getLogger(NAME);
public static final Logger LOGGER = LoggerFactory.getLogger(NAME);

@Override
public void onInitializeClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import java.util.Collections;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand All @@ -24,8 +24,7 @@
import net.minecraft.client.MinecraftClient;

public class ContinuityConfig {
protected static final Logger LOGGER = LogManager.getLogger("Continuity Config");
protected static final JsonParser PARSER = new JsonParser();
protected static final Logger LOGGER = LoggerFactory.getLogger("Continuity Config");
protected static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();

public static final ContinuityConfig INSTANCE = new ContinuityConfig(FabricLoader.getInstance().getConfigDir().resolve("continuity.json").toFile());
Expand All @@ -47,7 +46,7 @@ public ContinuityConfig(File file) {
public void load() {
if (file.exists()) {
try (FileReader reader = new FileReader(file)) {
fromJson(PARSER.parse(reader));
fromJson(JsonParser.parseReader(reader));
} catch (Exception e) {
LOGGER.error("Could not load config from file '" + file.getAbsolutePath() + "'", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void init() {
addDrawableChild(createBooleanOptionButton(width / 2 - 75 - 90, height / 2 - 10, 150, 20, config.disableCTM));
addDrawableChild(createBooleanOptionButton(width / 2 - 75 + 90, height / 2 - 10, 150, 20, config.useManualCulling));

addDrawableChild(new ButtonWidget(width / 2 - 100, height - 40, 200, 20, ScreenTexts.DONE, button -> onClose()));
addDrawableChild(new ButtonWidget(width / 2 - 100, height - 40, 200, 20, ScreenTexts.DONE, button -> close()));
}

@Override
Expand All @@ -34,7 +34,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
}

@Override
public void onClose() {
public void close() {
client.setScreen(parent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import me.pepperbell.continuity.client.util.biome.BiomeView;
import net.minecraft.client.render.chunk.ChunkRendererRegion;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;

Expand All @@ -17,7 +18,7 @@ public class ChunkRendererRegionMixin implements BiomeView {
protected World world;

@Override
public Biome getBiome(BlockPos pos) {
public RegistryEntry<Biome> getBiome(BlockPos pos) {
return world.getBiome(pos);
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
package me.pepperbell.continuity.client.mixin;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.pepperbell.continuity.client.mixinterface.ReloadableResourceManagerImplExtension;
import net.minecraft.resource.ReloadableResourceManagerImpl;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceReload;
import me.pepperbell.continuity.client.mixinterface.LifecycledResourceManagerImplExtension;
import net.minecraft.resource.LifecycledResourceManagerImpl;
import net.minecraft.util.Identifier;
import net.minecraft.util.Unit;

@Mixin(ReloadableResourceManagerImpl.class)
public class ReloadableResourceManagerImplMixin implements ReloadableResourceManagerImplExtension {
@Mixin(LifecycledResourceManagerImpl.class)
public class LifecycledResourceManagerImplMixin implements LifecycledResourceManagerImplExtension {
@Unique
private final Map<Identifier, Identifier> redirects = new Object2ObjectOpenHashMap<>();

Expand Down Expand Up @@ -64,9 +56,4 @@ private Identifier redirectGetAllResourcesId(Identifier id) {
// }
// }
// }

@Inject(method = "reload(Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;Ljava/util/List;)Lnet/minecraft/resource/ResourceReload;", at = @At("HEAD"))
private void onHeadReload(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<ResourcePack> packs, CallbackInfoReturnable<ResourceReload> cir) {
redirects.clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package me.pepperbell.continuity.client.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import net.minecraft.resource.LifecycledResourceManager;
import net.minecraft.resource.ReloadableResourceManagerImpl;

@Mixin(ReloadableResourceManagerImpl.class)
public interface ReloadableResourceManagerImplAccessor {
@Accessor("activeManager")
LifecycledResourceManager getActiveManager();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import net.minecraft.util.Identifier;

public interface ReloadableResourceManagerImplExtension {
public interface LifecycledResourceManagerImplExtension {
void addRedirect(Identifier from, Identifier to);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package me.pepperbell.continuity.client.util;

import me.pepperbell.continuity.client.mixinterface.ReloadableResourceManagerImplExtension;
import me.pepperbell.continuity.client.mixin.ReloadableResourceManagerImplAccessor;
import me.pepperbell.continuity.client.mixinterface.LifecycledResourceManagerImplExtension;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;

public final class ResourceRedirectHelper {
public static void addRedirect(ResourceManager resourceManager, Identifier from, Identifier to) {
if (resourceManager instanceof ReloadableResourceManagerImplExtension extension) {
if (resourceManager instanceof ReloadableResourceManagerImplAccessor accessor) {
resourceManager = accessor.getActiveManager();
}
if (resourceManager instanceof LifecycledResourceManagerImplExtension extension) {
extension.addRedirect(from, to);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ public static void init() {

private static Biome getBiomeByWorldView(BlockRenderView blockView, BlockPos pos) {
if (blockView instanceof WorldView worldView) {
return worldView.getBiome(pos);
return worldView.getBiome(pos).value();
}
return null;
}

private static Biome getBiomeByExtension(BlockRenderView blockView, BlockPos pos) {
if (blockView instanceof BiomeView biomeView) {
return biomeView.getBiome(pos);
return biomeView.getBiome(pos).value();
}
return getBiomeByWorldView(blockView, pos);
}

// Sodium
private static Biome getBiomeByWorldSlice(BlockRenderView blockView, BlockPos pos) {
if (blockView instanceof WorldSlice worldSlice) {
return worldSlice.getBiomeAccess().getBiome(pos);
return worldSlice.getBiomeAccess().getBiome(pos).value();
}
return getBiomeByWorldView(blockView, pos);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package me.pepperbell.continuity.client.util.biome;

import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.biome.Biome;

public interface BiomeView {
Biome getBiome(BlockPos pos);
RegistryEntry<Biome> getBiome(BlockPos pos);
}
3 changes: 2 additions & 1 deletion src/main/resources/continuity.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"ChunkRendererRegionMixin",
"FallingBlockEntityRendererMixin",
"IdentifierMixin",
"LifecycledResourceManagerImplMixin",
"ModelLoaderMixin",
"NamespaceResourceManagerMixin",
"ReloadableResourceManagerImplMixin",
"ReloadableResourceManagerImplAccessor",
"RenderLayersMixin"
],
"injectors": {
Expand Down

0 comments on commit 7cdd123

Please sign in to comment.