Skip to content

Commit

Permalink
Add ActuallyAdditions and Quark Mixins
Browse files Browse the repository at this point in the history
Disable Disruption lens from ActuallyAdditions
Disable Improved Sleeping from Quark
  • Loading branch information
LXGaming committed Feb 11, 2019
1 parent 7e14584 commit 2942dfe
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 3 deletions.
11 changes: 9 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.3.0"
version = "1.12.2-1.3.1"

minecraft {
version = "1.12.2-14.23.5.2768"
Expand Down Expand Up @@ -72,7 +72,9 @@ dependencies {
}
provided("org.spongepowered:spongeforge:1.12.2-2768-7.1.5:dev")
provided("org.spongepowered:spongevanilla:1.12.2-7.1.5:dev")
provided("actually-additions:ActuallyAdditions:1.12.2:r145")
provided("primalcore:PrimalCore:1.12.2:0.6.51")
provided("quark:Quark:r1.5:145")
}

jar {
Expand All @@ -81,7 +83,12 @@ jar {
"FMLCorePlugin": "io.github.lxgaming.sledgehammer.launch.SledgehammerLoadingPlugin",
"FMLCorePluginContainsFMLMod": true,
"ForceLoadAsMod": true,
"MixinConfigs": "mixins.sledgehammer.core.json,mixins.sledgehammer.forge.json,mixins.sledgehammer.sponge.json",
"MixinConfigs": ""
+ "mixins.sledgehammer.actuallyadditions.json,"
+ "mixins.sledgehammer.core.json,"
+ "mixins.sledgehammer.forge.json,"
+ "mixins.sledgehammer.quark.json,"
+ "mixins.sledgehammer.sponge.json",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"TweakOrder": 0
)
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/github/lxgaming/sledgehammer/Sledgehammer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.github.lxgaming.sledgehammer.integration.SpongeIntegration_Border;
import io.github.lxgaming.sledgehammer.integration.SpongeIntegration_Death;
import io.github.lxgaming.sledgehammer.integration.SpongeIntegration_Phase;
import io.github.lxgaming.sledgehammer.launch.SledgehammerLaunch;
import io.github.lxgaming.sledgehammer.manager.CommandManager;
import io.github.lxgaming.sledgehammer.manager.IntegrationManager;
import io.github.lxgaming.sledgehammer.util.Reference;
Expand Down Expand Up @@ -83,6 +84,10 @@ protected void registerIntegrations() {
}

protected void registerMixins() {
// Mixin ActuallyAdditions
getMixinMappings().put("actuallyadditions.mod.tile.MixinTileEntityAtomicReconstructor", category ->
SledgehammerLaunch.isForgeRegistered() && category.isActuallyAdditionsDisruption());

// Mixin Core
getMixinMappings().put("core.advancements.MixinAdvancementManager", MixinCategory::isAdvancementStacktrace);
getMixinMappings().put("core.block.MixinBlockGrass", MixinCategory::isBlockGrass);
Expand Down Expand Up @@ -115,12 +120,24 @@ protected void registerMixins() {
getMixinMappings().put("forge.fml.common.MixinLoader", category -> !getModMappings().isEmpty());
getMixinMappings().put("forge.fml.common.MixinMetadataCollection", category -> !getModMappings().isEmpty());

// Mixin Quark
getMixinMappings().put("quark.base.module.MixinModuleLoader", category ->
SledgehammerLaunch.isForgeRegistered() && category.isQuarkImprovedSleeping());

// Mixin Sponge
getMixinMappings().put("sponge.common.event.tracking.phase.packet.inventory.MixinBasicInventoryPacketState", MixinCategory::isInventoryDebug);
}

protected void registerMods() {
getConfig().map(Config::getModMappings).ifPresent(getModMappings()::putAll);
addModMapping("actuallyadditions", config -> config.getMixinCategory().isActuallyAdditionsDisruption());
addModMapping("quark", config -> config.getMixinCategory().isQuarkImprovedSleeping());
}

public void addModMapping(String id, Function<Config, Boolean> function) {
if (getConfig().map(function).orElse(false)) {
getModMappings().put(id, true);
}
}

public void debugMessage(String format, Object... arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
@ConfigSerializable
public class MixinCategory {

@Setting(value = "actuallyadditions-disruption", comment = "Disabled Disruption lens from ActuallyAdditions")
private boolean actuallyAdditionsDisruption = false;

@Setting(value = "advancement-stacktrace", comment = "Prints a single message instead of a stacktrace for advancement errors")
private boolean advancementStacktrace = false;

Expand Down Expand Up @@ -79,9 +82,16 @@ public class MixinCategory {
@Setting(value = "packet-spam", comment = "Cancels spammy packets")
private boolean packetSpam = false;

@Setting(value = "quark-improved-sleeping", comment = "Disables Improved Sleeping from Quark")
private boolean quarkImprovedSleeping = false;

@Setting(value = "traveling-merchant", comment = "Fixes https://github.com/Daveyx0/PrimitiveMobs/issues/59")
private boolean travelingMerchant = false;

public boolean isActuallyAdditionsDisruption() {
return actuallyAdditionsDisruption;
}

public boolean isAdvancementStacktrace() {
return advancementStacktrace;
}
Expand Down Expand Up @@ -154,6 +164,10 @@ public boolean isPacketSpam() {
return packetSpam;
}

public boolean isQuarkImprovedSleeping() {
return quarkImprovedSleeping;
}

public boolean isTravelingMerchant() {
return travelingMerchant;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2019 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.actuallyadditions.mod.tile;

import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(value = TileEntityAtomicReconstructor.class, priority = 1337)
public abstract class MixinTileEntityAtomicReconstructor extends TileEntityInventoryBase {

public MixinTileEntityAtomicReconstructor(int slots, String name) {
super(slots, name);
}

/**
* @author LX_Gaming
* @reason Disable Disruption Lens
*/
@Overwrite(remap = false)
public Lens getLens() {
Item item = inv.getStackInSlot(0).getItem();
if (item instanceof ILensItem) {
return ((ILensItem) item).getLens();
}

return ActuallyAdditionsAPI.lensDefaultConversion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2019 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.quark.base.module;

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;
import vazkii.quark.base.module.Feature;
import vazkii.quark.base.module.ModuleLoader;
import vazkii.quark.tweaks.feature.ImprovedSleeping;

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

@Inject(method = "isFeatureEnabled", at = @At(value = "HEAD"), cancellable = true)
private static void onIsFeatureEnabled(Class<? extends Feature> featureClass, CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
if (featureClass == ImprovedSleeping.class) {
callbackInfoReturnable.setReturnValue(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Reference {

public static final String ID = "sledgehammer";
public static final String NAME = "Sledgehammer";
public static final String VERSION = "1.12.2-1.3.0";
public static final String VERSION = "1.12.2-1.3.1";
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
15 changes: 15 additions & 0 deletions src/main/resources/mixins.sledgehammer.actuallyadditions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": true,
"minVersion": "0.7.10",
"package": "io.github.lxgaming.sledgehammer.mixin.actuallyadditions",
"refmap": "mixins.sledgehammer.refmap.json",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.CorePlugin",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
"mod.tile.MixinTileEntityAtomicReconstructor"
],
"injectors": {
"defaultRequire": 1
}
}
15 changes: 15 additions & 0 deletions src/main/resources/mixins.sledgehammer.quark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": true,
"minVersion": "0.7.10",
"package": "io.github.lxgaming.sledgehammer.mixin.quark",
"refmap": "mixins.sledgehammer.refmap.json",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.CorePlugin",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
"base.module.MixinModuleLoader"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 2942dfe

Please sign in to comment.