Skip to content

Commit

Permalink
Fix Morph crash caused by Sponge
Browse files Browse the repository at this point in the history
  • Loading branch information
LXGaming committed Aug 7, 2019
1 parent 334589e commit 2e06362
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ dependencies {
provided("actually-additions:ActuallyAdditions:1.12.2:r145")
provided("immersive-engineering:ImmersiveEngineering:0.12:89")
provided("matteroverdrive:MatterOverdrive-1.12.2:0.7.1.0:universal")
provided("morph:Morph:1.12.2:7.1.3")
provided("mrtjp:ProjectRed:1.12.2-4.9.1.92:mechanical") {
exclude(module: "jei_1.12.2")
}
Expand Down Expand Up @@ -153,6 +154,7 @@ jar {
+ "mixins.sledgehammer.forge.json,"
+ "mixins.sledgehammer.immersiveengineering.json,"
+ "mixins.sledgehammer.matteroverdrive.json,"
+ "mixins.sledgehammer.morph.json,"
+ "mixins.sledgehammer.p455w0rdslib.json,"
+ "mixins.sledgehammer.platform.json,"
+ "mixins.sledgehammer.projectred.json,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.github.lxgaming.sledgehammer.configuration.category.mixin.ForgeMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.ImmersiveEngineeringMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.MatterOverdriveMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.MorphMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.P455w0rdsLibMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.PrimitiveMobsMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.ProjectRedMixinCategory;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class MixinCategory {
@Setting(value = "matter-overdrive", comment = "Matter Overdrive")
private MatterOverdriveMixinCategory matterOverdriveMixinCategory = new MatterOverdriveMixinCategory();

@Setting(value = "morph", comment = "Morph")
private MorphMixinCategory morphMixinCategory = new MorphMixinCategory();

@Setting(value = "p455w0rdslib", comment = "p455w0rd's Library")
private P455w0rdsLibMixinCategory p455w0rdsLibMixinCategory = new P455w0rdsLibMixinCategory();

Expand Down Expand Up @@ -110,6 +114,10 @@ public MatterOverdriveMixinCategory getMatterOverdriveMixinCategory() {
return matterOverdriveMixinCategory;
}

public MorphMixinCategory getMorphMixinCategory() {
return morphMixinCategory;
}

public P455w0rdsLibMixinCategory getP455w0rdsLibMixinCategory() {
return p455w0rdsLibMixinCategory;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.configuration.category.mixin;

import io.github.lxgaming.sledgehammer.configuration.annotation.Mapping;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

@ConfigSerializable
public class MorphMixinCategory {

@Mapping(value = "morph.MorphInfoMixin", dependencies = {"morph"})
@Setting(value = "entity-update", comment = "If 'true', fixes NullPointerException caused by onUpdate")
private boolean entityUpdate = false;

public boolean isEntityUpdate() {
return entityUpdate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.morph;

import io.github.lxgaming.sledgehammer.Sledgehammer;
import me.ichun.mods.morph.common.morph.MorphInfo;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

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

@Redirect(method = "tick",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/EntityLivingBase;onUpdate()V",
remap = true
)
)
private void onTick(EntityLivingBase entity) {
try {
entity.onUpdate();
} catch (Exception ex) {
Sledgehammer.getInstance().debug("Encountered an error while performing entity update for Morph", ex);
}
}
}
15 changes: 15 additions & 0 deletions src/main/resources/mixins.sledgehammer.morph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": false,
"minVersion": "0.7.10",
"package": "io.github.lxgaming.sledgehammer.mixin.morph",
"refmap": "mixins.sledgehammer.refmap.json",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.CorePlugin",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MorphInfoMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 2e06362

Please sign in to comment.