-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fa602c
commit 94895bc
Showing
4 changed files
with
85 additions
and
42 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
73 changes: 73 additions & 0 deletions
73
src/main/java/dev/latvian/mods/kubejs/core/LocalClientPlayerKJS.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,73 @@ | ||
package dev.latvian.mods.kubejs.core; | ||
|
||
import dev.latvian.mods.kubejs.client.KubeSessionData; | ||
import dev.latvian.mods.kubejs.net.SendDataFromClientPayload; | ||
import dev.latvian.mods.kubejs.player.PlayerStatsJS; | ||
import dev.latvian.mods.kubejs.util.NotificationToastData; | ||
import dev.latvian.mods.rhino.util.RemapPrefixForJS; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.neoforge.network.PacketDistributor; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@RemapPrefixForJS("kjs$") | ||
public interface LocalClientPlayerKJS extends ClientPlayerKJS { | ||
@Override | ||
default LocalPlayer kjs$self() { | ||
return (LocalPlayer) this; | ||
} | ||
|
||
default Minecraft kjs$getMinecraft() { | ||
return Minecraft.getInstance(); | ||
} | ||
|
||
@Override | ||
default void kjs$runCommand(String command) { | ||
kjs$self().connection.sendCommand(command); | ||
} | ||
|
||
@Override | ||
default void kjs$runCommandSilent(String command) { | ||
kjs$self().connection.sendCommand(command); | ||
} | ||
|
||
@Override | ||
default boolean isSelf() { | ||
return true; | ||
} | ||
|
||
@Override | ||
default void kjs$sendData(String channel, @Nullable CompoundTag data) { | ||
if (!channel.isEmpty()) { | ||
PacketDistributor.sendToServer(new SendDataFromClientPayload(channel, data)); | ||
} | ||
} | ||
|
||
@Override | ||
default PlayerStatsJS kjs$getStats() { | ||
return new PlayerStatsJS(kjs$self(), kjs$self().getStats()); | ||
} | ||
|
||
@Override | ||
default boolean kjs$isMiningBlock() { | ||
return Minecraft.getInstance().gameMode.isDestroying(); | ||
} | ||
|
||
@Override | ||
default void kjs$notify(NotificationToastData notification) { | ||
notification.show(); | ||
} | ||
|
||
@Override | ||
default void kjs$setActivePostShader(@Nullable ResourceLocation id) { | ||
var sessionData = KubeSessionData.of(kjs$self().connection); | ||
|
||
if (sessionData != null) { | ||
sessionData.activePostShader = id; | ||
var mc = kjs$getMinecraft(); | ||
mc.gameRenderer.checkEntityPostEffect(mc.options.getCameraType().isFirstPerson() ? mc.getCameraEntity() : null); | ||
} | ||
} | ||
} |
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