-
Posts
46 -
Joined
-
Last visited
Everything posted by Davidthemodder
-
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Thanks to everyone. -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
I GOT IT TO WORK!!! I registered the ModPacketHandler in my main class and it workend. (In the private void setup) -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
This is about the registering of the ModPacketHandler -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
I think the problem is that the default dist is client and it never gets registered on the server. -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Wait. Is this Right? @Mod.EventBusSubscriber(modid = UltimateSheepMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Can I post a zip file of the mod? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
So I should make my mod a git project? Like the Folder or the folder where the mod folder is? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
What? I never used Github How? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
It crashed. crash-2021-05-23_20.00.52-client.txt latest.log -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Ok -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Can I just do it twice? EDIT: Like on Server and on the Client in the two classes? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
You mean like ModServerEvent? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
@Mod.EventBusSubscriber(modid = UltimateSheepMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ModClientEvent { @SubscribeEvent public static void lightning(AttackEntityEvent event){ if(event.getEntityLiving().getHeldItemMainhand().getItem() == ModItems.LIGHTNING_HAMMER.get()){ LightningBoltEntity lightning = new LightningBoltEntity(EntityType.LIGHTNING_BOLT,event.getEntity().world); lightning.setPosition(event.getTarget().getPosX(), event.getTarget().getPosY(), event.getTarget().getPosZ()); event.getPlayer().world.addEntity(lightning); } } @SubscribeEvent public static void onCrafting(GuiOpenEvent event){ if (event.isCancelable()){ if (event.getGui() instanceof CraftingScreen){ if (event.getResult().equals(Items.APPLE)){ event.setCanceled(true); } } } } @SubscribeEvent public static void fly(TickEvent.ClientTickEvent event){ if(event.phase == TickEvent.Phase.START){ if(UltimateSheepMod.KEY.isKeyDown()){ ModPacketHandler.simpleChannel.sendToServer(new FlyActivateMessage()); } } } @SubscribeEvent public static void doClientSetup(FMLClientSetupEvent event){ ClientRegistry.registerKeyBinding(UltimateSheepMod.KEY); } @SubscribeEvent public static void doCommonSetup(FMLCommonSetupEvent event){ ModPacketHandler.init(); } -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Here the Crash report. crash-2021-05-23_19.08.29-client.txt -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
latest.log -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
It It didn´t work. -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Thanks -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
How? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
How? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
There is no error but it crashes as soon as I press the key -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
public static final KeyBinding KEY = new KeyBinding("Fly",GLFW.GLFW_KEY_V, "Ultimate Sheep Mod"); @SubscribeEvent public static void doClientSetup(FMLClientSetupEvent event){ ClientRegistry.registerKeyBinding(UltimateSheepMod.KEY); } @SubscribeEvent public static void fly(TickEvent.ClientTickEvent event){ if(event.phase == TickEvent.Phase.START){ if(UltimateSheepMod.KEY.isKeyDown()){ ModPacketHandler.simpleChannel.sendToServer(new FlyActivateMessage()); } } } public class ModPacketHandler { private static final String version = "1"; private static int id = 0; public static SimpleChannel simpleChannel; public static void init(){ simpleChannel = NetworkRegistry.newSimpleChannel(new ResourceLocation("usm:simple_channel"), () -> version, version::equals, version::equals); simpleChannel.registerMessage(id++, FlyActivateMessage.class, FlyActivateMessage::encode, FlyActivateMessage::decode, FlyActivateMessage::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER)); } } Like this? -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
public static final KeyBinding KEY = new KeyBinding("Fly",GLFW.GLFW_KEY_V, "Ultimate Sheep Mod"); @SubscribeEvent public static void doClientSetup(FMLClientSetupEvent event){ ClientRegistry.registerKeyBinding(UltimateSheepMod.KEY); } @SubscribeEvent public static void fly(TickEvent.ClientTickEvent event){ if(event.phase == TickEvent.Phase.START){ if(UltimateSheepMod.KEY.isKeyDown()){ ModPacketHandler.simpleChannel.sendToServer(new FlyActivateMessage()); } } } public class ModPacketHandler { private static final String version = "1"; private static int id = 0; public static SimpleChannel simpleChannel; public static void init(){ simpleChannel = NetworkRegistry.newSimpleChannel(new ResourceLocation("usm:simple_channel"), () -> version, version::equals, version::equals); simpleChannel.registerMessage(id++, FlyActivateMessage.class, FlyActivateMessage::encode, FlyActivateMessage::decode, FlyActivateMessage::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER)); } } public class FlyActivateMessage { public static void encode(FlyActivateMessage message,PacketBuffer packetBuffer) { } public static FlyActivateMessage decode(PacketBuffer packetBuffer) { return new FlyActivateMessage(); } public static void handle(FlyActivateMessage message, Supplier<NetworkEvent.Context> networkContext) { ServerPlayerEntity player = networkContext.get().getSender(); networkContext.get().enqueueWork(() -> { }); networkContext.get().setPacketHandled(true); } } -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
I did everything like you did but it always crashes when I try it. -
[SOLVED] How can I do somehing with Keybindings?
Davidthemodder replied to Davidthemodder's topic in Modder Support
Thank you for your help. And without you I would never have found out how to run the code. -
I want to make the player to do somethingwhen I press V. How?