Skip to content

Commit

Permalink
Fix Network error caused by primitivemobs
Browse files Browse the repository at this point in the history
  • Loading branch information
LXGaming committed Aug 7, 2019
1 parent 2e06362 commit 9f13930
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ dependencies {
}
provided("p455w0rds-library:p455w0rdslib:1.12.2:2.2.151")
provided("primalcore:PrimalCore:1.12.2:0.6.51")
provided("primitive-mobs:primitivemobs:1.2.3a")
provided("quark:Quark:r1.5:145")
provided("reliquary-v1-3:Reliquary:1.12.2:1.3.4.786")
provided("ruins-structure-spawning-system:Ruins:1.12.2")
Expand Down Expand Up @@ -157,6 +158,7 @@ jar {
+ "mixins.sledgehammer.morph.json,"
+ "mixins.sledgehammer.p455w0rdslib.json,"
+ "mixins.sledgehammer.platform.json,"
+ "mixins.sledgehammer.primitivemobs.json,"
+ "mixins.sledgehammer.projectred.json,"
+ "mixins.sledgehammer.quark.json,"
+ "mixins.sledgehammer.ruins.json,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@
@ConfigSerializable
public class PrimitiveMobsMixinCategory {

@Mapping(value = "primitivemobs.message.MessagePrimitiveJumpingMixin", dependencies = {"primitivemobs"})
@Setting(value = "networking", comment = "If 'true', fixes NullPointerException caused by MessagePrimitiveJumping")
private boolean network = false;

@Mapping(value = "forge.entity.passive.EntityVillagerMixin")
@Setting(value = "traveling-merchant", comment = "If 'true', fixes https://github.com/Daveyx0/PrimitiveMobs/issues/59 (Sponge only).")
private boolean travelingMerchant = false;

public boolean isNetwork() {
return network;
}

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.primitivemobs.message;

import net.daveyx0.primitivemobs.message.MessagePrimitiveJumping;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.UUID;

@Mixin(value = MessagePrimitiveJumping.Handler.class, priority = 1337, remap = false)
public abstract class MessagePrimitiveJumpingMixin {

@Inject(method = "onMessage",
at = @At(value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/world/World;getPlayerEntityByUUID(Ljava/util/UUID;)Lnet/minecraft/entity/player/EntityPlayer;"
),
remap = true,
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true
)
private void onMessage(MessagePrimitiveJumping message, MessageContext ctx, CallbackInfoReturnable<IMessage> callbackInfoReturnable,
UUID id, EntityPlayer truePlayer) {
if (truePlayer == null) {
callbackInfoReturnable.setReturnValue(null);
}
}
}
15 changes: 15 additions & 0 deletions src/main/resources/mixins.sledgehammer.primitivemobs.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.primitivemobs",
"refmap": "mixins.sledgehammer.refmap.json",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.CorePlugin",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
"message.MessagePrimitiveJumpingMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 9f13930

Please sign in to comment.