chore: moved group to net.moonleay

fix: fixed camera going meyhem when going 3rd person in NoClip
This commit is contained in:
moonleay 2024-04-23 18:12:39 +02:00
parent 0cd271f139
commit 7383fa09e8
Signed by: moonleay
GPG key ID: 82667543CCD715FB
31 changed files with 125 additions and 107 deletions

View file

@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx2G
modId=gimble
kotlinx.serialization.version=1.6.2
fabric.kotlin.version=1.10.19+kotlin.1.9.23
mavenGroup=net.moonleay.mods
mavenGroup=net.moonleay
kotlin.code.style=official
minecraft.version=1.19.2
modName=Gimble

View file

@ -1,6 +1,6 @@
package net.moonleay.mods.gimble
package net.moonleay.gimble
import net.moonleay.mods.gimble.build.BuildConstants
import net.moonleay.gimble.build.BuildConstants
import net.fabricmc.api.ModInitializer
import org.apache.logging.log4j.LogManager

View file

@ -1,11 +1,10 @@
package net.moonleay.mods.gimble.client
package net.moonleay.gimble.client
import net.moonleay.mods.gimble.build.BuildConstants
import net.moonleay.gimble.build.BuildConstants
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.KeybindingManager
import net.moonleay.mods.gimble.client.keybindings.KeybindingRegistrar
import net.moonleay.gimble.client.keybindings.KeybindingManager
import net.moonleay.gimble.client.keybindings.KeybindingRegistrar
import org.apache.logging.log4j.LogManager
internal object ClientMain : ClientModInitializer {
@ -15,7 +14,7 @@ internal object ClientMain : ClientModInitializer {
override fun onInitializeClient() {
LOGGER.info("Initializing Gimble on the client side...")
KeybindingRegistrar.registerKeybindings()
this.registerEvents()
registerEvents()
LOGGER.info("Gimble has been initialized on the client side.")
}

View file

@ -1,9 +1,9 @@
package net.moonleay.mods.gimble.client.editor
package net.moonleay.gimble.client.editor
import net.minecraft.client.MinecraftClient
import net.moonleay.mods.gimble.client.util.ChatUtil
import net.moonleay.mods.gimble.client.editor.modes.Mode
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier
import net.moonleay.gimble.client.util.ChatUtil
import net.moonleay.gimble.client.editor.modes.Mode
import net.moonleay.gimble.client.editor.modes.ModeModifier
object ClientEditor {
var CURRENT_MODE = Mode.NORMAL
@ -25,17 +25,19 @@ object ClientEditor {
CURRENT_MODE_MODIFIER.add(mod)
}
this.onModifiersUpdated()
onModifiersUpdated()
}
fun onModifiersUpdated() {
CURRENT_MODE_MODIFIER.sort()
this.checkForIncompatibleModeModifiers()
checkForIncompatibleModeModifiers()
}
fun checkForIncompatibleModeModifiers() {
if (TEMP_DISABLED_MODIFIERS.size > 0) {
CURRENT_MODE_MODIFIER.addAll(TEMP_DISABLED_MODIFIERS)
CURRENT_MODE_MODIFIER.addAll(
TEMP_DISABLED_MODIFIERS
)
TEMP_DISABLED_MODIFIERS.clear()
}
@ -53,7 +55,7 @@ object ClientEditor {
if(TEMP_DISABLED_MODIFIERS.isNotEmpty()) {
ChatUtil.addToChatHistory("The following modifiers are not supported by this editor mode and are therefore currently disabled: " +
this.getListAsString(TEMP_DISABLED_MODIFIERS), MinecraftClient.getInstance())
getListAsString(TEMP_DISABLED_MODIFIERS), MinecraftClient.getInstance())
}
}

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.client.editor.modes
package net.moonleay.gimble.client.editor.modes
enum class Mode(val displayName: String, val color: Int, val incompatibleModifiers: List<ModeModifier>){
NORMAL("NORMAL", 0x90a959, listOf(ModeModifier.NO_UPDATES, ModeModifier.BULLDOZER, ModeModifier.FORCE_PLACE)), // Do nothing

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.client.editor.modes
package net.moonleay.gimble.client.editor.modes
enum class ModeModifier(val displayName: String) {
// NONE("None"), // No Modifiers - default behavior

View file

@ -1,9 +1,8 @@
package net.moonleay.mods.gimble.client.keybindings
package net.moonleay.gimble.client.keybindings
import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
object KeybindingManager {

View file

@ -1,18 +1,18 @@
package net.moonleay.mods.gimble.client.keybindings
package net.moonleay.gimble.client.keybindings
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil
import net.moonleay.mods.gimble.build.BuildConstants
import net.moonleay.mods.gimble.client.keybindings.impl.editormode.EnableInsertModeShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.editormode.EnableReplaceModeShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.editormode.EnableVisualModeShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier.ToggleBulldozerModifierShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier.ToggleForcePlaceModifierShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier.ToggleNoClipModifierShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier.ToggleNoUpdatesModifierShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.gamemode.CreativeModeShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.gamemode.SpectatorModeShortcut
import net.moonleay.mods.gimble.client.keybindings.impl.gamemode.SurvivalModeShortcut
import net.moonleay.gimble.build.BuildConstants
import net.moonleay.gimble.client.keybindings.impl.editormode.EnableInsertModeShortcut
import net.moonleay.gimble.client.keybindings.impl.editormode.EnableReplaceModeShortcut
import net.moonleay.gimble.client.keybindings.impl.editormode.EnableVisualModeShortcut
import net.moonleay.gimble.client.keybindings.impl.editormodemodifier.ToggleBulldozerModifierShortcut
import net.moonleay.gimble.client.keybindings.impl.editormodemodifier.ToggleForcePlaceModifierShortcut
import net.moonleay.gimble.client.keybindings.impl.editormodemodifier.ToggleNoClipModifierShortcut
import net.moonleay.gimble.client.keybindings.impl.editormodemodifier.ToggleNoUpdatesModifierShortcut
import net.moonleay.gimble.client.keybindings.impl.gamemode.CreativeModeShortcut
import net.moonleay.gimble.client.keybindings.impl.gamemode.SpectatorModeShortcut
import net.moonleay.gimble.client.keybindings.impl.gamemode.SurvivalModeShortcut
import org.apache.logging.log4j.LogManager
import org.lwjgl.glfw.GLFW

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.client.keybindings.impl
package net.moonleay.gimble.client.keybindings.impl
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormode
package net.moonleay.gimble.client.keybindings.impl.editormode
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.Mode
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.Mode
class EnableInsertModeShortcut(key: KeyBinding): GimbleShortcut(key) {

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormode
package net.moonleay.gimble.client.keybindings.impl.editormode
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.Mode
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.Mode
class EnableReplaceModeShortcut(key: KeyBinding): GimbleShortcut(key) {

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormode
package net.moonleay.gimble.client.keybindings.impl.editormode
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.Mode
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.Mode
class EnableVisualModeShortcut(key: KeyBinding): GimbleShortcut(key) {

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier
package net.moonleay.gimble.client.keybindings.impl.editormodemodifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.ModeModifier
class ToggleBulldozerModifierShortcut(key: KeyBinding): GimbleShortcut(key) {
override fun onPressed(client: MinecraftClient) {

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier
package net.moonleay.gimble.client.keybindings.impl.editormodemodifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.ModeModifier
class ToggleForcePlaceModifierShortcut(key: KeyBinding): GimbleShortcut(key) {
override fun onPressed(client: MinecraftClient) {

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier
package net.moonleay.gimble.client.keybindings.impl.editormodemodifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.ModeModifier
class ToggleNoClipModifierShortcut(key: KeyBinding): GimbleShortcut(key) {
override fun onPressed(client: MinecraftClient) {

View file

@ -1,10 +1,10 @@
package net.moonleay.mods.gimble.client.keybindings.impl.editormodemodifier
package net.moonleay.gimble.client.keybindings.impl.editormodemodifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.editor.ClientEditor
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier
import net.moonleay.gimble.client.editor.ClientEditor
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.editor.modes.ModeModifier
class ToggleNoUpdatesModifierShortcut(key: KeyBinding): GimbleShortcut(key) {
override fun onPressed(client: MinecraftClient) {

View file

@ -1,9 +1,9 @@
package net.moonleay.mods.gimble.client.keybindings.impl.gamemode
package net.moonleay.gimble.client.keybindings.impl.gamemode
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.util.ChatUtil
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.util.ChatUtil
class CreativeModeShortcut(key: KeyBinding): GimbleShortcut(key) {
override fun onPressed(client: MinecraftClient) {

View file

@ -1,9 +1,9 @@
package net.moonleay.mods.gimble.client.keybindings.impl.gamemode
package net.moonleay.gimble.client.keybindings.impl.gamemode
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.util.ChatUtil
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.util.ChatUtil
class SpectatorModeShortcut(key: KeyBinding): GimbleShortcut(key) {
override fun onPressed(client: MinecraftClient) {

View file

@ -1,9 +1,9 @@
package net.moonleay.mods.gimble.client.keybindings.impl.gamemode
package net.moonleay.gimble.client.keybindings.impl.gamemode
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.moonleay.mods.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.mods.gimble.client.util.ChatUtil
import net.moonleay.gimble.client.keybindings.impl.GimbleShortcut
import net.moonleay.gimble.client.util.ChatUtil
class SurvivalModeShortcut(key: KeyBinding) : GimbleShortcut(key) {

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.client.util
package net.moonleay.gimble.client.util
import net.minecraft.client.MinecraftClient
import net.minecraft.text.Text

View file

@ -1,6 +1,6 @@
package net.moonleay.mods.gimble.datagen
package net.moonleay.gimble.datagen
import net.moonleay.mods.gimble.build.BuildConstants
import net.moonleay.gimble.build.BuildConstants
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import org.apache.logging.log4j.LogManager

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.datagen
package net.moonleay.gimble.datagen
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider

View file

@ -1,13 +1,13 @@
package net.moonleay.mods.gimble.mixin;
package net.moonleay.gimble.mixin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.moonleay.mods.gimble.client.editor.ClientEditor;
import net.moonleay.mods.gimble.client.editor.modes.Mode;
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier;
import net.moonleay.gimble.client.editor.ClientEditor;
import net.moonleay.gimble.client.editor.modes.Mode;
import net.moonleay.gimble.client.editor.modes.ModeModifier;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.mixin;
package net.moonleay.gimble.mixin;
import net.minecraft.client.Keyboard;
import org.spongepowered.asm.mixin.Mixin;

View file

@ -0,0 +1,21 @@
package net.moonleay.gimble.mixin;
import net.minecraft.client.render.Camera;
import net.moonleay.gimble.client.editor.ClientEditor;
import net.moonleay.gimble.client.editor.modes.ModeModifier;
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;
@Mixin(Camera.class)
public class NoClipCameraFix {
@Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true)
private void fixCameraInNoClip(double desiredCameraDistance, CallbackInfoReturnable<Double> cir) {
if (ClientEditor.INSTANCE.containsModifier(ModeModifier.NO_CLIP)){
cir.setReturnValue(desiredCameraDistance);
cir.cancel();
}
}
}

View file

@ -1,15 +1,9 @@
package net.moonleay.mods.gimble.mixin;
package net.moonleay.gimble.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.world.World;
import net.minecraft.world.entity.EntityLike;
import net.moonleay.mods.gimble.client.editor.ClientEditor;
import net.moonleay.mods.gimble.client.editor.modes.ModeModifier;
import net.moonleay.gimble.client.editor.ClientEditor;
import net.moonleay.gimble.client.editor.modes.ModeModifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -23,11 +17,14 @@ public class NoClipMixin {
@Inject(method = "tick", at = @At(value = "HEAD"))
private void enoClip(CallbackInfo ci) {
if (!ClientEditor.INSTANCE.containsModifier(ModeModifier.NO_CLIP))
// TODO: Add player check, add multiplayer compat
if(!((Entity)(Object)this instanceof PlayerEntity)) // Only check on player
return;
// TODO: Add player check, add multiplayer compat
if(!((Entity)(Object)this instanceof PlayerEntity))
if (!ClientEditor.INSTANCE.containsModifier(ModeModifier.NO_CLIP))
return;
PlayerEntity thePlayer = (PlayerEntity)(Object)this;
if (!thePlayer.getAbilities().flying)
return;
this.noClip = true;

View file

@ -1,9 +1,9 @@
package net.moonleay.mods.gimble.mixin;
package net.moonleay.gimble.mixin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.GameOptions;
import net.moonleay.mods.gimble.client.editor.ClientEditor;
import net.moonleay.mods.gimble.client.editor.modes.Mode;
import net.moonleay.gimble.client.editor.modes.Mode;
import net.moonleay.gimble.client.editor.ClientEditor;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.mixin;
package net.moonleay.gimble.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
@ -11,8 +11,8 @@ import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.moonleay.mods.gimble.client.editor.ClientEditor;
import net.moonleay.mods.gimble.client.editor.modes.Mode;
import net.moonleay.gimble.client.editor.ClientEditor;
import net.moonleay.gimble.client.editor.modes.Mode;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -44,9 +44,8 @@ public abstract class ReplaceModeMixin {
assert this.interactionManager != null;
if (!this.interactionManager.getCurrentGameMode().isCreative())
return;
if (!(this.crosshairTarget instanceof BlockHitResult))
if (!(this.crosshairTarget instanceof BlockHitResult blockHitResult))
return;
BlockHitResult blockHitResult = (BlockHitResult)this.crosshairTarget;
if (blockHitResult == null)
return;

View file

@ -14,19 +14,19 @@
"client": [
{
"adapter": "kotlin",
"value": "net.moonleay.mods.gimble.client.ClientMain"
"value": "net.moonleay.gimble.client.ClientMain"
}
],
"main": [
{
"adapter": "kotlin",
"value": "net.moonleay.mods.gimble.Main"
"value": "net.moonleay.gimble.Main"
}
],
"fabric-datagen": [
{
"adapter": "kotlin",
"value": "net.moonleay.mods.gimble.datagen.DataGenerator"
"value": "net.moonleay.gimble.datagen.DataGenerator"
}
]
},

View file

@ -1,13 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "net.moonleay.mods.gimble.mixin",
"package": "net.moonleay.gimble.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"NoClipMixin"
],
"client": [
"HudMixin",
"NoClipCameraFix",
"NormalModeMixin",
"ReplaceModeMixin"
],

View file

@ -1,4 +1,4 @@
package net.moonleay.mods.gimble.build
package net.moonleay.gimble.build
internal object BuildConstants {
const val modId = "${modId}"