-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #953 from Gu-ZT/onlyJEI/1.20.1
仅安装JEI时发送提醒
- Loading branch information
Showing
16 changed files
with
152 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
36 changes: 36 additions & 0 deletions
36
common/src/main/java/dev/dubhe/anvilcraft/mixin/ClientPacketListenerMixin.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,36 @@ | ||
package dev.dubhe.anvilcraft.mixin; | ||
|
||
import dev.dubhe.anvilcraft.AnvilCraft; | ||
import dev.dubhe.anvilcraft.api.event.entity.PlayerEvent; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.client.multiplayer.ClientPacketListener; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.network.protocol.game.ClientboundLoginPacket; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientPacketListener.class) | ||
public abstract class ClientPacketListenerMixin { | ||
@Shadow | ||
@Final | ||
private Minecraft minecraft; | ||
|
||
@Shadow | ||
public abstract ClientLevel getLevel(); | ||
|
||
@Inject( | ||
method = "handleLogin", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Options;broadcastOptions()V") | ||
) | ||
private void handleLogin(ClientboundLoginPacket packet, CallbackInfo ci) { | ||
LocalPlayer player = this.minecraft.player; | ||
if (player != null) { | ||
AnvilCraft.EVENT_BUS.post(new PlayerEvent.ClientPlayerJoin(player, player.getOnPos(), this.getLevel())); | ||
} | ||
} | ||
} |
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,16 @@ | ||
package dev.dubhe.anvilcraft.util; | ||
|
||
import dev.architectury.injectables.annotations.ExpectPlatform; | ||
|
||
public abstract class Utils { | ||
private Utils() { | ||
} | ||
|
||
/** | ||
* @return 是否只加载了 JEI | ||
*/ | ||
@ExpectPlatform | ||
public static boolean onlyJei() { | ||
throw new AssertionError(); | ||
} | ||
} |
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
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
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
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
9 changes: 9 additions & 0 deletions
9
fabric/src/main/java/dev/dubhe/anvilcraft/util/fabric/UtilsImpl.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,9 @@ | ||
package dev.dubhe.anvilcraft.util.fabric; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
public class UtilsImpl { | ||
public static boolean onlyJei() { | ||
return FabricLoader.getInstance().isModLoaded("jei") && !FabricLoader.getInstance().isModLoaded("emi"); | ||
} | ||
} |
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
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
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
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
9 changes: 9 additions & 0 deletions
9
forge/src/main/java/dev/dubhe/anvilcraft/util/forge/UtilsImpl.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,9 @@ | ||
package dev.dubhe.anvilcraft.util.forge; | ||
|
||
import net.minecraftforge.fml.ModList; | ||
|
||
public class UtilsImpl { | ||
public static boolean onlyJei() { | ||
return ModList.get().isLoaded("jei") && !ModList.get().isLoaded("emi"); | ||
} | ||
} |