Skip to content

Commit

Permalink
Redirect Inventory debug messages
Browse files Browse the repository at this point in the history
Remove MixinForgeHooks_Harvest as it's fixed upstream
  • Loading branch information
LXGaming committed Sep 25, 2018
1 parent ac8fd0b commit 4ab5cee
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 79 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ targetCompatibility = 1.8

group = "io.github.lxgaming"
archivesBaseName = "Sledgehammer"
version = "1.12.2-1.2.12"
version = "1.12.2-1.2.13"

minecraft {
version = "1.12.2-14.23.4.2705"
Expand Down Expand Up @@ -80,7 +80,7 @@ jar {
attributes(
"FMLCorePluginContainsFMLMod": true,
"ForceLoadAsMod": true,
"MixinConfigs": "mixins.sledgehammer.core.json,mixins.sledgehammer.forge.json,mixins.sledgehammer.spongeforge.json,mixins.sledgehammer.spongevanilla.json",
"MixinConfigs": "mixins.sledgehammer.core.json,mixins.sledgehammer.forge.json,mixins.sledgehammer.sponge.json",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"TweakOrder": 0
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ private void registerMappings() {

// Mixin Forge
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.forge.common.MixinForgeHooks_Advancement", MixinCategory::isAdvancementStacktrace);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.forge.common.MixinForgeHooks_Harvest", MixinCategory::isHarvestBlock);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.forge.entity.passive.MixinEntityVillager", MixinCategory::isTravelingMerchant);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.forge.world.storage.MixinWorldInfo", MixinCategory::isCeremonyRain);

// Mixin SpongeForge

// Mixin SpongeVanilla
// Mixin Sponge
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.sponge.common.event.tracking.phase.packet.inventory.MixinBasicInventoryPacketState", MixinCategory::isInventoryDebug);
}

public void debugMessage(String format, Object... arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class MixinCategory {
@Setting(value = "ceremony-rain", comment = "Prevents Totemic from changing the weather")
private boolean ceremonyRain = false;

@Setting(value = "harvest-block", comment = "Prevents ClassCastException caused by Sponge assuming things")
private boolean harvestBlock = false;
@Setting(value = "inventory-debug", comment = "Redirects inventory debugging messages")
private boolean inventoryDebug = false;

@Setting(value = "network-system", comment = "Fixes potential deadlock on shutdown")
private boolean networkSystem = false;
Expand Down Expand Up @@ -66,8 +66,8 @@ public boolean isCeremonyRain() {
return ceremonyRain;
}

public boolean isHarvestBlock() {
return harvestBlock;
public boolean isInventoryDebug() {
return inventoryDebug;
}

public boolean isNetworkSystem() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (Toolbox.isClassPresent("net.minecraftforge.fml.relauncher.CoreModManager") || Toolbox.isClassPresent("cpw.mods.fml.relauncher.CoreModManager")) {
return super.shouldApplyMixin(targetClassName, mixinClassName);
} else {
if (!Toolbox.isForgeEnvironment()) {
return false;
}

return super.shouldApplyMixin(targetClassName, mixinClassName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2018 Alex Thomson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.lxgaming.sledgehammer.mixin.plugin;

import io.github.lxgaming.sledgehammer.util.Toolbox;
import org.apache.commons.lang3.StringUtils;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class SpongePlugin extends AbstractPlugin {

@Override
public void onLoad(String mixinPackage) {
super.onLoad(mixinPackage);
}

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

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (StringUtils.startsWith(mixinClassName, "io.github.lxgaming.sledgehammer.mixin.sponge.mod.") && !Toolbox.isForgeEnvironment()) {
return false;
}

return super.shouldApplyMixin(targetClassName, mixinClassName);
}

@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) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2018 Alex Thomson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.lxgaming.sledgehammer.mixin.sponge.common.event.tracking.phase.packet.inventory;

import io.github.lxgaming.sledgehammer.Sledgehammer;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.common.event.tracking.phase.packet.inventory.BasicInventoryPacketState;

@Mixin(value = BasicInventoryPacketState.class, priority = 1337, remap = false)
public abstract class MixinBasicInventoryPacketState {

@Redirect(method = "unwind", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;info(Ljava/lang/String;)V"))
private void onLoadAdvancementsError(Logger logger, String message) {
Sledgehammer.getInstance().debugMessage("{} - {}", message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Reference {

public static final String PLUGIN_ID = "sledgehammer";
public static final String PLUGIN_NAME = "Sledgehammer";
public static final String PLUGIN_VERSION = "1.12.2-1.2.12";
public static final String PLUGIN_VERSION = "1.12.2-1.2.13";
public static final String DESCRIPTION = "Smashes the stupid out of the server.";
public static final String AUTHORS = "LX_Gaming";
public static final String SOURCE = "https://github.com/LXGaming/Sledgehammer/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public static Text convertColor(String string) {
return TextSerializers.FORMATTING_CODE.deserialize(string);
}

public static boolean isForgeEnvironment() {
return Toolbox.isClassPresent("net.minecraftforge.fml.relauncher.CoreModManager") || Toolbox.isClassPresent("cpw.mods.fml.relauncher.CoreModManager");
}

/**
* Removes non-printable characters (excluding new line and carriage return) in the provided {@link java.lang.String String}.
*
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/mixins.sledgehammer.forge.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"common.MixinForgeHooks_Advancement",
"common.MixinForgeHooks_Harvest",
"entity.passive.MixinEntityVillager",
"world.storage.MixinWorldInfo"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"required": true,
"minVersion": "0.7.4",
"package": "io.github.lxgaming.sledgehammer.mixin.spongeforge",
"package": "io.github.lxgaming.sledgehammer.mixin.sponge",
"refmap": "mixins.sledgehammer.refmap.json",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.ForgePlugin",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.SpongePlugin",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
Expand Down
14 changes: 0 additions & 14 deletions src/main/resources/mixins.sledgehammer.spongevanilla.json

This file was deleted.

0 comments on commit 4ab5cee

Please sign in to comment.