Posted November 14, 20222 yr Sorry for my newbie question. I need to do a new event when a player push a button but only metal button. Thank you!
November 14, 20222 yr Subscribe to the RightClickBlock event. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
November 14, 20222 yr Author Thank you for your reply! But how i ask if a player is touching a metal button?
November 14, 20222 yr Author I dont know why it doesnt work Quote public class BotonVideoGames extends StoneButtonBlock { private Hue hue; boolean luzEncendida; public BotonVideoGames(Properties properties) { super(properties); hue = new Hue(); luzEncendida = true; } @SubscribeEvent public void onPlayerInteract(PlayerInteractEvent.RightClickBlock e) { try { hue.power(luzEncendida); e.getEntity().sendSystemMessage(Component.literal("La luz esta encendida: " + luzEncendida)); } catch (IOException ev) { throw new RuntimeException(ev); } } }
November 14, 20222 yr If it's your own block, you override the use() method. See ButtonBlock.use(); Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
November 14, 20222 yr Author Sorry im very new on this. what I don't understand is how in an event I ask what block the player presses with a RightClickBlock For example i can use later inside the method e.getItemStack() and return what the player has on the hand but not which block is pushing with this item. or on the side of the block what would be the event to check the ButtonBlock.use() If you can please helpme with both. I know that It's enough with just one. Thanks a lot!
November 14, 20222 yr Being new is not an excuse. This forum does not exist, so you don't have to do your own research. It is a support forum not a school. You only need RightClickBlock if it is not your block. For the rest, read the code of ButtonBlock.use() and try to understand what it is doing. Looking where Block.use() is called from in the other minecraft code will give you more context for what is happening. Or look at other Block's use() methods that do things more like what you want to do. For your specific questions * You are passed a Level, BlockState and BlockPos which uniquely identifies the block (this is minecraft 101). A look at ButtonBlock.press() shows how they are used to change the state from unpressed to pressed. * The BlockHitResult has the side (direction). There have been at least 3 questions just this week in this forum about hit results and many others before that. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
November 14, 20222 yr Author Thank you so much Warjot, now i understand how use method works. I didnt found the method who calls use() Actually I was able to do what I wanted to do but the command I want to execute is thrown twice on the button. i can fix it with a counter, when it reach 2 it reset. this is quite ugly but it works but the eyes hurt a little
November 14, 20222 yr The method is called on both the client and sever. Check level.isClientSide Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
November 17, 20222 yr Author Warjort I can ask you for help with something else, I made a button that turns on the light in my house, one for each room. I made a Button class with all the methods. A method that it has, you put the name of the room (the same one that has the smart lamps api) and it creates a String[] with the ids. With another method it turns it on. Then I made a son class with the name of each room to write the attribute with the lamp ids in each one and call the parent method to turn them on. Can you think of a way so that the user with a set from the minecraft console can modify the operation of the button, to make this mod more universal? The idea that occurs to me but I don't know if it's possible, that the player writes to the console something from /give Player button X. Example (/give Player button RoomGames) where X is a variable. Thank you so much.
November 18, 20222 yr Perhaps check the code for other minecraft commands to see if that's possible, for example the GiveCommand class Or even write your own command Edited November 18, 20222 yr by MistaOmega
November 19, 20222 yr Author I'm not finding it. All my mod is working The only thing I want now is to make it universal so I can share it. I need to do with a command /button String String and have that give the player a button that was created with the String String parameters. If anyone has any ideas
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.