Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.movement.NoSlow;
import meteordevelopment.meteorclient.systems.modules.movement.Slippy;
import meteordevelopment.meteorclient.systems.modules.render.Xray;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemConvertible;
import net.minecraft.util.math.Direction;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Block.class)
public abstract class BlockMixin extends AbstractBlock implements ItemConvertible {
Expand All @@ -37,4 +42,16 @@ public float getSlipperiness(float original) {
if (block == Blocks.SLIME_BLOCK && Modules.get().get(NoSlow.class).slimeBlock()) return 0.6F;
else return original;
}

// For More Culling compatibility - runs before More Culling's inject to force-render whitelisted Xray blocks
@Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true)
private static void meteor$forceXrayFace(BlockState state, BlockState sideState, Direction side, CallbackInfoReturnable<Boolean> cir) {
Modules modules = Modules.get();
if (modules == null) return;

Xray xray = modules.get(Xray.class);
if (xray.isActive() && !xray.isBlocked(state.getBlock(), null)) {
cir.setReturnValue(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = BlockOcclusionCache.class, remap = false)
public abstract class SodiumBlockOcclusionCacheMixin {
Expand All @@ -29,6 +30,15 @@ private void onInit(CallbackInfo info) {
xray = Modules.get().get(Xray.class);
}

// For More Culling compatibility - runs before More Culling's inject to force-render whitelisted Xray blocks
@Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true)
private void meteor$forceXrayFace(BlockState state, BlockView view, BlockPos pos, Direction facing,
CallbackInfoReturnable<Boolean> cir) {
if (xray != null && xray.isActive() && !xray.isBlocked(state.getBlock(), null)) {
cir.setReturnValue(true);
}
}

@ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN"))
private boolean shouldDrawSide(boolean original, BlockState state, BlockView view, BlockPos pos, Direction facing) {
if (xray.isActive()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.modintegration;

import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.Fullbright;
import meteordevelopment.meteorclient.systems.modules.render.Xray;

import java.util.function.BooleanSupplier;

/*
* Hook for BadOptimizations mod compatibility.
* Signals when the lightmap needs to be updated due to Fullbright or Xray state changes.
*/
public class BadOptimizationsHook implements BooleanSupplier {
private int lastState;

@Override
public boolean getAsBoolean() {
Modules m = Modules.get();
if (m == null) return false;

int state = (m.get(Fullbright.class).getGamma() ? 1 : 0) | (m.isActive(Xray.class) ? 2 : 0);
boolean changed = state != lastState;
lastState = state;
return changed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient;
package meteordevelopment.meteorclient.modintegration;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"meteordevelopment.meteorclient.MeteorClient"
],
"modmenu": [
"meteordevelopment.meteorclient.ModMenuIntegration"
"meteordevelopment.meteorclient.modintegration.ModMenuIntegration"
]
},
"mixins": [
Expand All @@ -43,6 +43,9 @@
"links": {
"modmenu.discord": "https://meteorclient.com/discord"
}
},
"badoptimizations:cache_hooks": {
"lightmap": "meteordevelopment.meteorclient.modintegration.BadOptimizationsHook"
}
},
"depends": {
Expand Down