Skip to content

Commit

Permalink
fix: fixes server crash from loading client only libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperalani committed Jan 31, 2024
1 parent adecc35 commit b6f57cf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/kikis/ptdyeplus/PtdyePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.kikis.ptdyeplus.init.BlockEntityInit;
import com.kikis.ptdyeplus.init.BlockInit;
import com.kikis.ptdyeplus.init.ItemInit;
import com.kikis.ptdyeplus.jade.PonderTooltipComponentProvider;
import com.mojang.logging.LogUtils;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.ponder.PonderRegistry;
Expand Down Expand Up @@ -60,7 +61,7 @@ public static class ClientForgeEvents {

@SubscribeEvent
public static void onKeyInput(InputEvent.Key event) throws NoSuchElementException {
if(OpenStonecutter.KEY_TRY_PONDER.get().consumeClick()) {
if(PonderTooltipComponentProvider.KEY_TRY_PONDER.get().consumeClick()) {
Entity entity = minecraft.getCameraEntity();
assert entity != null;
HitResult block = entity.pick(20.0D, 0.0F, false);
Expand Down Expand Up @@ -89,7 +90,7 @@ public static void onKeyInput(InputEvent.Key event) throws NoSuchElementExceptio
public static class ClientModBusEvents {
@SubscribeEvent
public static void onKeyRegister(RegisterKeyMappingsEvent event) {
event.register(OpenStonecutter.KEY_TRY_PONDER.get());
event.register(PonderTooltipComponentProvider.KEY_TRY_PONDER.get());
}
}
}
12 changes: 0 additions & 12 deletions src/main/java/com/kikis/ptdyeplus/commands/OpenStonecutter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
import org.lwjgl.glfw.GLFW;

public class OpenStonecutter {
public static final Lazy<KeyMapping> KEY_TRY_PONDER = Lazy.of(() -> new KeyMapping(
"key.ptdyeplus.try_ponder",
KeyConflictContext.IN_GAME,
InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_B,
"key.ptdyeplus.category"
));

@SubscribeEvent
public void registerBindings(RegisterKeyMappingsEvent event) {
event.register(KEY_TRY_PONDER.get());
}

public static void register(@NotNull CommandDispatcher<CommandSourceStack> dispatcher){
dispatcher.register(Commands.literal("openStonecutter").executes(OpenStonecutter::execute));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package com.kikis.ptdyeplus.commands.stonecutter;
package com.kikis.ptdyeplus.jade;

import com.kikis.ptdyeplus.commands.OpenStonecutter;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.client.KeyMapping;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.common.util.Lazy;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.lwjgl.glfw.GLFW;
import snownee.jade.api.BlockAccessor;
import snownee.jade.api.IBlockComponentProvider;
import snownee.jade.api.ITooltip;
Expand All @@ -12,18 +19,30 @@
public enum PonderTooltipComponentProvider implements IBlockComponentProvider {
INSTANCE;

public static final Lazy<KeyMapping> KEY_TRY_PONDER = Lazy.of(() -> new KeyMapping(
"key.ptdyeplus.try_ponder",
KeyConflictContext.IN_GAME,
InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_B,
"key.ptdyeplus.category"
));

@SubscribeEvent
public void registerBindings(RegisterKeyMappingsEvent event) {
event.register(KEY_TRY_PONDER.get());
}

@Override
public void appendTooltip(
ITooltip tooltip,
BlockAccessor accessor,
IPluginConfig config
) {
String tryPonderKey = OpenStonecutter.KEY_TRY_PONDER.get().getKey().toString();
String tryPonderKey = KEY_TRY_PONDER.get().getKey().toString();
// todo: figure out how to do translation with chat colour
tooltip.add(Component.translatable(ChatFormatting.DARK_GRAY + "Press [%s" + ChatFormatting.DARK_GRAY + "] to ponder", ChatFormatting.GRAY + tryPonderKey.substring(tryPonderKey.length() - 1)));
}


@Override
public ResourceLocation getUid() {
return PonderTooltipPlugin.UID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kikis.ptdyeplus.commands.stonecutter;
package com.kikis.ptdyeplus.jade;

import com.simibubi.create.content.contraptions.actors.harvester.HarvesterBlock;
import com.simibubi.create.content.contraptions.actors.plough.PloughBlock;
Expand Down

0 comments on commit b6f57cf

Please sign in to comment.