I’m using mixin to improve Sponge mod but unfortunately its not properly applied as nothing is printed but the regular message. ids.length != 2 is given.
how can I improve this? I want to replace a Sponge method.
package cabbage
import net.minecraft.world.World;
import org.apache.logging.log4j.Level;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.util.PrettyPrinter;
import org.spongepowered.common.SpongeImpl;
import org.spongepowered.common.config.SpongeConfig;
import org.spongepowered.common.config.category.BlockCapturingCategory;
import org.spongepowered.common.config.category.BlockCapturingModCategory;
import org.spongepowered.common.interfaces.world.IMixinWorldServer;
import org.spongepowered.common.mixin.blockcapturing.MixinBlock_BlockCapturing;
import org.spongepowered.common.config.type.GeneralConfigBase;
@Mixin(value = MixinBlock_BlockCapturing.class, priority = 9999)
public abstract class MixinBlockCapturing implements BlockType {
@Shadow
private boolean processTickChangesImmediately;
public void initializeBlockCapturingState(World worldIn) {
SpongeConfig<? extends GeneralConfigBase> activeConfig = ((IMixinWorldServer) worldIn).getActiveConfig();
BlockCapturingCategory blockCapturing = activeConfig.getConfig().getBlockCapturing();
String[] ids = this.getId().split(":");
if (ids.length != 2) {
System.out.println("Try get bong");
if (true) {
} else {
final PrettyPrinter printer = new PrettyPrinter(60).add("Malformatted Block ID discovered!").centre().hr()
.addWrapped(60, "Sponge has found a malformatted block id when trying to"
+ " load configurations for the block id. The printed out block id"
+ "is not originally from sponge, and should be brought up with the"
+ "mod developer as the registration for this block is not likely"
+ "to work with other systems and assumptions of having a properly"
+ "formatted block id.")
.add("%s : %s", "Malformed ID", this.getId())
.add("%s : %s", "Discovered id array", ids)
.add();
final String id = ids[0];
ids = new String[]{"unknown", id};
printer
.add("Sponge will attempt to work around this by using the provided generated id:")
.add("%s : %s", "Generated ID", ids)
.log(SpongeImpl.getLogger(), Level.WARN);
}
}
String modId = ids[0];
String name = ids[1];
BlockCapturingModCategory modCapturing = blockCapturing.getModMappings().get(modId);
if (modCapturing == null && blockCapturing.autoPopulateData()) {
modCapturing = new BlockCapturingModCategory();
blockCapturing.getModMappings().put(modId.toLowerCase(), modCapturing);
modCapturing.getBlockMap().put(name.toLowerCase(), false);
if (blockCapturing.autoPopulateData()) {
activeConfig.save();
}
return;
} else if (modCapturing != null) {
if (!modCapturing.isEnabled()) {
this.processTickChangesImmediately = false;
return;
}
Boolean processImmediately = modCapturing.getBlockMap().get(name.toLowerCase());
if (processImmediately != null) {
this.processTickChangesImmediately = processImmediately;
}
}
if (blockCapturing.autoPopulateData()) {
activeConfig.save();
}
}
}
this is my build.gradle
buildscript {
repositories {
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
flatDir {
dirs "lib"
}
maven {
name = 'sponge'
url = 'https://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.5-SNAPSHOT'
}
}
plugins {
id 'java'
id 'org.spongepowered.plugin' version '0.8.1'
id 'net.minecrell.vanillagradle.server' version '2.2-6'
}
apply plugin: 'org.spongepowered.mixin'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
version = '0.3'
repositories {
flatDir {
dirs "lib"
}
}
dependencies {
compile 'org.spongepowered:spongeapi:7.0.0'
compile 'org.spongepowered:spongecommon:7.1.0-SNAPSHOT:dev'
compile 'org.spongepowered:mixin:0.7.5-SNAPSHOT'
compileOnly name: "mod-decor"
}
minecraft {
version = '1.12.2'
mappings = "snapshot_20180104"
makeObfSourceJar = false
}
mixin {
add sourceSets.main, "mixins.refmap.json"
}
jar {
manifest.attributes(
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
'MixinConfigs': 'mixins.gss.json',
'FMLCorePluginContainsFMLMod': 'true',
)
}
and this my mixinconfig in resources folder
{
"required": true,
"minVersion": "0.5.7",
"package": "cabbage",
"refmap": "mixins.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"server": [
"MixinMinecraftServer"
],
"injectors": {
"defaultRequire": 1
}
}