
oznecniV97
Members-
Posts
35 -
Joined
-
Last visited
Everything posted by oznecniV97
-
[1.10.2] [SOLVED] Server side - execute method after server stop
oznecniV97 replied to oznecniV97's topic in Modder Support
Ok, I've found a solution. boolean open = true; Socket socket = SocketFactory.getDefault().createSocket(); try { socket.setSoTimeout(5000); socket.connect(new InetSocketAddress("127.0.0.1", 25565)); socket.close(); } catch (ConnectException e) { open = false; System.err.println(e); } Using this code, if the soker.connection method throw a ConnectException it means that my server is offline (or is starting), else the server is up and running. -
[1.10.2] [SOLVED] Server side - execute method after server stop
oznecniV97 replied to oznecniV97's topic in Modder Support
Sorry guys, did you know if there's an event like the FMLServerStoppingEvent but for the start event? I need to notify a remote server when my server is ready. (For ready I means that I can access on it with a minecraft client) -
[1.10.2] Server side - Stop server from code
oznecniV97 replied to oznecniV97's topic in Modder Support
This isn't the same topic. The previous one is a topic about an action after the server stop. This one is for stop the server based on an event. Thanks @IceMetalPunk for this solution. I know, it's strange that I want to stop the server using this method, but I need it because I have a "remote" server and I need to control it without really interact with it. (I know that I didn't explain my idea, but without explain all the environment is too complex to explain just this part ). -
Hi All, I need to stop my server based on an external text file. E.g.: I have a file in a folder called "server_info.txt". Now, if this file begins with "stop" I need to stop the server. Actually I read this file using the TickHandler (TickEvent.ServerTickEvent) every x minutes but I don't know if there's a possibility to stop the server using a method like "server.stop();" (?) Thanks.
-
[1.10.2] [SOLVED] Server side - execute method after server stop
oznecniV97 replied to oznecniV97's topic in Modder Support
Oh, good point. Thanks @diesieben07 for the tip -
[1.10.2] [SOLVED] Server side - execute method after server stop
oznecniV97 replied to oznecniV97's topic in Modder Support
Do you think that is better? I thought about a server side mod just to do all inside the single command "java -jar mc_server.jar nogui" but if I can't do it I'll write an external bat to run this script after the previous command. With the second method it will works, right? -
[1.10.2] [SOLVED] Server side - execute method after server stop
oznecniV97 replied to oznecniV97's topic in Modder Support
I want to zip my world and upload it on a cloud after server stop because I switch between 2 pc's and I do this manually everytime. (a real boring action ) -
Hi guys, I want to make a mod that do some actions (like do a post call to a WebServer or other things) after the stop command is launched on server console. p.s.: I know that if I add a command in the ServerStart.cmd as last command I can run another java application that do this, but I don't want to change that file. Thanks.
-
Hi all, I want to play my .mp3 file (I don't know if .mp3 file is good or I need to convert to another one) when the player break a certain block with any item (or with none). My needs is a things like change the vanilla diamond ore breaking sound with a custom sound. Is it possible?
-
(1.12) How do i detect if a player is wearing my modded armor.
oznecniV97 replied to J_Dev's topic in Modder Support
You can try with this: Minecraft.getMinecraft().player.getArmorInventoryList().contains(mymod.head) Remember that getArmorInventoryList return an Iterable of ItemStack, not Item. -
For this I think that you can start from your "main" block and use it's position to check the other blocks beside. E.g.: Elven portal in Botania have a main block in the lowest part and this need to have 1 block in left part and one in righ part (and other blocks, but is an example). You can get the BlockPos of this main block and check if on x+1 and x-1 or z+1 and z-1 if there's the right blocks. I think that you can do this check on a TickHandler (I think that the best in this case can be the Server TickHandler). I don't know if there's some other more simplest methods to do that... UPDATE: Here you can find the Botania source code: https://github.com/Vazkii/Botania/tree/1.12
- 1 reply
-
- 1
-
-
[1.12] [SOLVED] KeyInputEvent get keyPressed
oznecniV97 replied to oznecniV97's topic in Modder Support
Oh ok, now it's clear! Thanks @diesieben07 -
[1.12] [SOLVED] KeyInputEvent get keyPressed
oznecniV97 replied to oznecniV97's topic in Modder Support
Yes, this issue is basically related to the open phase of a GUI. If I short press E I see the inventory opened but in the console I can't see nothing (Same problem with L key Advancements). In the others cases (even the E press to close the inventory) I see it. -
This code works fine for the first slot in player inventory: Minecraft mc = Minecraft.getMinecraft(); mc.playerController.windowClick(mc.player.inventoryContainer.windowId, 9, 0, ClickType.PICKUP, mc.player); mc.playerController.windowClick(mc.player.inventoryContainer.windowId, -999, 0, ClickType.PICKUP, mc.player); The first instruction is the left mouse click (3° param is mouse click, 0 for left, 1 for right) on the first slot in player inventory (2° param is inventory slot (0-4 for crafting, 5-8 for armor, 9-35 for inventory)). The second instruction is the left mouse click out of inventory GUI (to drop it down). This code works fine with the inventory closed.
-
[1.12] [SOLVED] KeyInputEvent get keyPressed
oznecniV97 replied to oznecniV97's topic in Modder Support
With this update (check if phase is END): private static Field KEYBIND_ARRAY = null; @SubscribeEvent (priority = EventPriority.LOWEST) public void onClientTick(TickEvent.ClientTickEvent event) throws Exception { if(KEYBIND_ARRAY == null){ KEYBIND_ARRAY = KeyBinding.class.getDeclaredField("KEYBIND_ARRAY"); KEYBIND_ARRAY.setAccessible(true); } if(event.phase.equals(Phase.END)){ Map<String, KeyBinding> binds = (Map<String, KeyBinding>) KEYBIND_ARRAY.get(null); for (String bind : binds.keySet()) { if(binds.get(bind).isKeyDown()){ System.out.println(bind + " - " + binds.get(bind).getDisplayName()); break; } } } } I see no difference about the issue. I have a doubt of how can I set the static Field to final because if I do that and set equals to KeyBinding.class.getDeclaredField("field") eclipse give me an error and didn't compile it because there's a throws declaration on this method. -
[1.12] [SOLVED] KeyInputEvent get keyPressed
oznecniV97 replied to oznecniV97's topic in Modder Support
Ok thanks! Now it work (more or less) with the following code: private static Map<String, KeyBinding> binds = null; @SubscribeEvent (priority = EventPriority.LOWEST) //END is not present public void onClientTick(TickEvent.ClientTickEvent event) throws Exception { if(binds == null){ Field campo = KeyBinding.class.getDeclaredField("KEYBIND_ARRAY"); campo.setAccessible(true); binds = (Map<String, KeyBinding>) campo.get(null); } for (String bind : binds.keySet()) { if(binds.get(bind).isKeyDown()){ System.out.println(bind + " - " + binds.get(bind).getDisplayName()); break; } } } The only one issue that I've found is that if I press very fast a key that have a isPressed logic (like E key) it didn't catch the pressing event and print nothing. Set this thread as solved. -
[1.12] [SOLVED] KeyInputEvent get keyPressed
oznecniV97 replied to oznecniV97's topic in Modder Support
UPDATE: If I do this code (*) in the KeyInputEvent I can see the key pressed in the console but if the key works on a isPressed logic it didn't do the base logic (Ex: if I press E, I see "key.inventory - E" but my inventory didn't open). If I do this code (*) in the PlayerTickEvent/ClientTickEvent if the key works on a isPressed logic I can't see the key pressed in the console but the key works as expected (Ex: if I press E, I can see my inventory opened but nothing in the console). (*) Field campo = KeyBinding.class.getDeclaredField("KEYBIND_ARRAY"); campo.setAccessible(true); Map<String, KeyBinding> binds = (Map<String, KeyBinding>) campo.get(null); for (String bind : binds.keySet()) { if(binds.get(bind).isPressed()){ System.out.println(bind + " - " + binds.get(bind).getDisplayName()); break; } } -
[1.12] [SOLVED] KeyInputEvent get keyPressed
oznecniV97 replied to oznecniV97's topic in Modder Support
Sorry but, why this is wrong? @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if(KeyBindings.left.isPressed()){ //do something } if(KeyBindings.right.isPressed()){ //do something } if(KeyBindings.up.isPressed()){ //do something } if(KeyBindings.down.isPressed()){ //do something } if(KeyBindings.rompi.isPressed()){ //do something } } For me it works without any problem. Which are the improvement to use the ClientTickEvent instead of this? -
Hi guys, I want to know in my KeyInputEvent which is the key pressed without write a code like this: int n = 0; if(KeyBindings.left.isPressed()){ //EXAMPLE CODE n = 1; }else if(KeyBindings.right.isPressed()){ //EXAMPLE CODE n = 2; }else if(KeyBindings.up.isPressed()){ //EXAMPLE CODE n = 3; }else if(KeyBindings.down.isPressed()){ //EXAMPLE CODE n = 4; }else if(KeyBindings.back.isPressed()){ //EXAMPLE CODE n = 5; } because I need to check on ALL the key bindings (even to vanilla ones). Is there a method to get this information from the event argument or can I get a list of all registered KeyBinding? Add: I've tryied with Set<String> binds = KeyBinding.getKeybinds(); for (String bind : binds) { System.out.println(bind); } but I can only see the categories: key.categories.misc key.categories.creative key.categories.gameplay key.categories.multiplayer key.categories.movement key.categories.inventory
-
There's a possibility to put minecraft in debug mode like an eclipse project and go ahead instruction by instruction to follow the process and verify it?
-
Sorry but, how can I do it? There's a simple method to do that or I need to check manually in the Minecraft classes?
-
Hi guys, I need to write a method that can drop an item from a slot (like the first slot) in the player main inventory without open it. I need it to "delete" this item from my inventory but without a replaceLike method (pick up the inventory slot and set it as Air) because I need to run this mod only on a client that need to access to a vanilla server. So, in short, what I need to do is a process like this: open the inventory (press E); go with mouse on the selected slot; left click with mouse (pick up the item); move the mouse out of my inventory; left click with mouse (drop the item out of my inventory); close the inventory. PS if is possible, I would like to do it without real open and close inventory, to do it in a more efficient way. Anyone have an idea on how can I do it? Thanks.
-
Thanks @ratismal but how i use this events only in this method? after that i don't want to scan every single tick
-
yeah but... what is the TickHandler?