Skip to content

Commit

Permalink
Reduce compatibility issues with MixinBlockDustParticle.
Browse files Browse the repository at this point in the history
  • Loading branch information
gniftygnome committed Aug 17, 2023
1 parent 4d030cd commit 3a998c2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Environment(EnvType.CLIENT)
public class MixinBlockDustParticle {
@Redirect(method = "<init>(Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isOf(Lnet/minecraft/block/Block;)Z"))
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isOf(Lnet/minecraft/block/Block;)Z"), require = 0)
private boolean terrestria$fixParticleColors(BlockState blockState, Block requiredBlock) {
Block block = blockState.getBlock();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.terraformersmc.terrestria.mixin;

import com.google.common.collect.ImmutableMap;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

public class TerrestriaClientMixinPlugin implements IMixinConfigPlugin {
private static final Supplier<Boolean> TRUE = () -> true;

private static final Map<String, Supplier<Boolean>> CONDITIONS = ImmutableMap.of(
"com.terraformersmc.terrestria.mixin.MixinBlockDustParticle", () -> !FabricLoader.getInstance().isModLoaded("immersive_weathering")
);

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return CONDITIONS.getOrDefault(mixinClassName, TRUE).get();
}

// Boilerplate

@Override
public void onLoad(String mixinPackage) {

}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}
}
1 change: 1 addition & 0 deletions client/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "LGPL-3.0-only",
"icon": "assets/terrestria/icon.png",
"environment": "client",
"plugin": "com.terraformersmc.terrestria.mixin.TerrestriaClientMixinPlugin",
"mixins": [
"mixins.terrestria-client.json"
],
Expand Down

0 comments on commit 3a998c2

Please sign in to comment.