Jump to content

squidlex

Members
  • Posts

    183
  • Joined

  • Last visited

Everything posted by squidlex

  1. That explains it, thank's so much for the in-depth explanation diesieben!
  2. Doing this using .isKeyDown() and .isKeyPressed() (I don't have my IDE on my laptop but I think that's what they're called) is tempremental and both allow me to just hold it. Using the Key input event will fire when I let go of a key and using a tick event on the client side will often not read my input. Is there a reliable way to do something if and only if a key has been tapped? Or better yet what key triggered the keyboard input event?
  3. That's where I'm stumped. Of course there is PlayerEntity.collidedHorizontally but that's a boolean and doesn't give the side. (used to be called EnumFacing not sure if it's the same or changed nowadays)
  4. A quick follow up question for anybody that knows. Is there anyway to get the side of the block a player is touching? E.g if they are touching the north face of a block
  5. My lord that's elegantly put. Thanks for the help! I'll get to work messing around with these
  6. As the title suggests! In a similar veign, I'm also trying to work out how to check if the block infront of the player's head and the block above that are air blocks. For example: X = PLAYER, O = BLOCK (from a side on perspective) X X O would be fine but... O X XO would not be I know it's a weird question but I've always wondered how mods work out stuff like this. I hope my terrible text diagrams help illustrate my question. Thanks for your help!
  7. Update: I read through the changelog and saw that Command registry has been updated. I'm guessing this is my issue
  8. Hi there! I'm looking to make my player invincible for say 10 ticks after a key is pressed. I can probably use a tick event for the ticks (duh.) but I'm not quite sure how to make my player invincible. Thanks for the help
  9. That was the problem! Thanks for spotting that, I'm really bad at spotting little errors like this. Thank you so much I can finally finish porting my mod!
  10. Not to worry, I appreciate the time you took to respond
  11. Thanks for your reply, but I'm now seeing either I worded my question poorly or I don't quite understand your reply. It doesn't sugget @p or anything like that at all when I type /commandtree edit_a_float but it does when I type /commandtree. When I type /commandtree edit_a_float and then type anything after that it returns Unknown Command.
  12. Update: I'm definitely misunderstanding this. Here's my code: public class Command { public static void register(CommandDispatcher<CommandSource> dispatcher) { final LiteralArgumentBuilder<CommandSource> root = Commands.literal("commandtree"); root.then(Commands.literal("edit_a_float").then(Commands.argument("float", FloatArgumentType.floatArg()))).executes(source -> { return editPower(source.getSource(), source.getSource().asPlayer(), FloatArgumentType.getFloat(source, "float")); }).then(Commands.argument("player", EntityArgument.player())).executes(source -> { return editPower(source.getSource(), EntityArgument.getPlayer(source, "player"), FloatArgumentType.getFloat(source, "float")); }); root.then(Commands.literal("edit_a_cooldown").then(Commands.argument("ticks", IntegerArgumentType.integer()))).executes(source -> { return editCooldown(source.getSource(), source.getSource().asPlayer(), IntegerArgumentType.getInteger(source, "ticks")); }).then(Commands.argument("player", EntityArgument.player())).executes(source -> { return editCooldown(source.getSource(), EntityArgument.getPlayer(source, "player"), IntegerArgumentType.getInteger(source, "ticks")); }); dispatcher.register(root); } private static int editPower(CommandSource source, PlayerEntity player, float amount) { System.out.println("Adjusted power by " + amount + "!"); return 1; } private static int editCooldown(CommandSource source, PlayerEntity player, int ticks) { System.out.println("Adjusted cooldown by " + ticks + "!"); return 1; } } When entering my command, edit_a_float and edit_a_cooldown are recommended, but it also recommends usernames and all the @s. When typing in a command I get the message 'Unknown Command' or 'Incorrect argument for command'. Please could someone explain to me where I'm going wrong?
  13. I'm looking to update a command tree I made for 1.12 to 1.15.2. Obviously Commands have changed to the CommandDispatcher now, so does anybody know of any good/simple source code I could look at for a basic command tree? Thanks for your help!
  14. Finally got around to watching this, For anyone stumbling upon this thread I would highly recommend! Helped me see how much I'm treating a simple Minecraft mod like a huge project for my work, thanks for sharing Draco .
  15. That's very true, I only have this as a method as my mod add's one feauture with loads of checks (capability, command, potion effect, config options etc.), so it helps readability to seperate them all into methods instead of having one massive if statement. Actually looking over everything, I'll do it using ifPresent() to avoid any issues, thanks!
  16. Hi there, I need a method to return a capability for a specific player. Here's what I'm trying to achieve (obviously this code doesn't work). private boolean returnFromACapability { player.getCapability(CapabilityProvider.SOME_CAP).ifPresent(cd -> { return cd.getBooleanValue(); // The method returnFromACapibility would return this }); return false; } I don't want to make any static variables as instances of this class are used on the Server side by different players and I'd rather not make a load of public variables outside this method as I have many similar ones and my code would get very messy. I think I'm too close to this and there's probably a super simple solution, so I figured I'd ask here. Thanks for your help!
  17. Sorry! it wasn't for me but it was obviously just a problem on my end
  18. bump because this isn't showing up even when I log out of this account
  19. This isn't showing up on the posts section for some reason
  20. I have a class that is only used when Game Stages is installed, however when running runClient with it as a dependency I get a crash. (The mod author is aware of this and other people have experienced it) If I remove the mod my classes that reference the mod show errors, which is frustrating. I want runClient to exclude running this mod, so I don't recieve errors in my IDE or in Minecraft, how would I go about blacklisting them? Thanks for your help!
  21. I just looked and wow, you're not wrong there! Thank you for your really clear explanation of that concept, it's perfect for what I'm trying to achieve I hope you have/had a great day!
  22. I've seen a lot of stuff based around tracking an entity in events and networking in Forge's code, but I'm not sure what this actually means? I've googled it but can't find any clear cut explanation other than 'entities have different tracking distances based on their type'. Could anybody tell me what these are as well? Thank you for your help!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.