-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix chunk loading passenger mount event fix
- Loading branch information
Showing
4 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/no2/bugfixerupper/common/threadlocals/MountEventSilencer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package no2.bugfixerupper.common.threadlocals; | ||
|
||
public class MountEventSilencer { | ||
private static final ThreadLocal<Boolean> SILENCE_MOUNT_EVENT = ThreadLocal.withInitial(() -> false); | ||
|
||
public static void silenceMountEvent() { | ||
SILENCE_MOUNT_EVENT.set(true); | ||
} | ||
|
||
public static void unsilenceMountEvent() { | ||
SILENCE_MOUNT_EVENT.set(false); | ||
} | ||
|
||
public static boolean isMountEventSilenced() { | ||
return SILENCE_MOUNT_EVENT.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/no2/bugfixerupper/mixin/chunkload/passenger_mount_event/EntityTypeMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package no2.bugfixerupper.mixin.chunkload.passenger_mount_event; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import no2.bugfixerupper.common.threadlocals.MountEventSilencer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(EntityType.class) | ||
public class EntityTypeMixin { | ||
|
||
|
||
@Redirect( | ||
method = "method_17843", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;startRiding(Lnet/minecraft/world/entity/Entity;Z)Z") | ||
) | ||
private static boolean startRidingSilently(Entity passenger, Entity vehicle, boolean bl) { | ||
MountEventSilencer.silenceMountEvent(); | ||
boolean ret = passenger.startRiding(vehicle, bl); | ||
MountEventSilencer.unsilenceMountEvent(); | ||
return ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters