Jump to content

squidlex

Members
  • Posts

    183
  • Joined

  • Last visited

Everything posted by squidlex

  1. Thanks for all your help, when I use that in my KeyInputEvent I get a crash. I don't want to bother you any more as it's unrelated to the OT so I've started a new topic asking for more information on how Networks work, thank you for explaining where I was going wrong!
  2. Ah, thank you, do you have any example source code of this? I've got a PacketHandler setup but I'm not sure how I'd send a message from the server, rather than from the client.
  3. Oh I see, thank you! Would I send over my server values straight from my config or from the event itself?
  4. I'm trying to setup a common config that is read from the physical server over the physical client, however the physical client is taking presedence over it. Why is this happening and how can I fix it? Config: @EventBusSubscriber(modid = Dodge.MODID, bus = EventBusSubscriber.Bus.MOD) public final class ConfigHandler { public static class Common { public final ForgeConfigSpec.DoubleValue dodgePower; public final ForgeConfigSpec.IntValue hungerRequirement; public final ForgeConfigSpec.BooleanValue allowDodgeWhileAirborne; public final ForgeConfigSpec.BooleanValue enableCooldown; public final ForgeConfigSpec.IntValue cooldownLength; public final ForgeConfigSpec.BooleanValue displayParticles; public final ForgeConfigSpec.BooleanValue fancyParticles; public Common(ForgeConfigSpec.Builder builder) { // BALANCE dodgePower = builder .comment("How powerful each player's dodge is. Defaults at 1 which is just under 3 blocks.") .defineInRange("balance.power", 1, 0, Double.MAX_VALUE); hungerRequirement = builder.comment( "How many half drumsticks the player needs to dodge. Set this to -1 to disable this feature. By default it's the same as sprinting, 6.") .defineInRange("balance.hungerRequirement", 6, -1, 20); allowDodgeWhileAirborne = builder.comment( "Set this to true to allow the player to dodge whilst in midair. Note the player always has this ability in creative mode.") .define("balance.allowDodgeWhileAirborne", false); // COOLDOWN enableCooldown = builder.comment("Set this to false to disable the cooldown bar completely.") .define("cooldown.enabled", true); cooldownLength = builder .comment("How long the dodge takes to cooldown in (roughly) seconds. This defaults to 4.") .defineInRange("cooldown.duration", 3, 1, Integer.MAX_VALUE); // PARTICLES displayParticles = builder .comment("Set this to false to disable the particles emitted when a player dodges") .define("particles.enableParticles", true); fancyParticles = builder.comment( "Set this to true to enable fancy particles, many prefer the old particles so that is now the default.") .define("particles.fancy", false); } } public static final Common COMMON; public static final ForgeConfigSpec COMMON_SPEC; static { final Pair<Common, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Common::new); COMMON_SPEC = specPair.getRight(); COMMON = specPair.getLeft(); } // Bakers @SubscribeEvent public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent) { if (configEvent.getConfig().getSpec() == ConfigHandler.COMMON_SPEC) { bakeCommonConfig(); } } // Common public static double dodgePower; public static int hungerRequirement, cooldownLength; public static boolean allowDodgeWhileAirborne, enableCooldown, displayParticles, fancyParticles; public static void bakeCommonConfig() { dodgePower = COMMON.dodgePower.get(); hungerRequirement = COMMON.hungerRequirement.get(); cooldownLength = COMMON.cooldownLength.get() * 20; allowDodgeWhileAirborne = COMMON.allowDodgeWhileAirborne.get(); enableCooldown = COMMON.enableCooldown.get(); displayParticles = COMMON.displayParticles.get(); fancyParticles = COMMON.fancyParticles.get(); } } Where it is used: public class DodgeEvents { @SubscribeEvent public void onKeyPressed(InputEvent.KeyInputEvent event) { if (Dodge.DodgeClient.DODGE_KEY.isKeyDown() && DodgeGui.len <= 0 && spamPreventer >= 12) { if (player.isCreative() || player.isSpectator() || player.onGround || ConfigHandler.allowDodgeWhileAirborne) { //DO STUFF } } } How it is called in my main class: public Dodge() { ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigHandler.COMMON_SPEC); DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { MinecraftForge.EVENT_BUS.register(new DodgeEvents()); } I think it has something to do with my DistExecutor, is there any workaround for this?
  5. I'd completely misunderstood how they work, thank you so much for the clarification So if I wanted a config that would apply to all worlds, and be read from the physical server over the physical client I could use common? Thanks for your in-depth answer I really appreciate it.
  6. As my server config is world save specific, is there anyway modpack creators can create a default one for any world created with my mod installed? I've seen alot of people use common configs but I don't think they sync across the server and client. Thank you!
  7. Thanks for the code I really appreciate it! For some reason even with this code, which I agree should definitely work, it constantly outputs that it has been double pressed. Thanks for your help though
  8. Thanks for the replying, how did you go about implementing your boolean? I tried using one as so if (Minecraft.getInstance().gameSettings.keyBindLeft.isKeyPressed && notPressed) { if (timer > 0) { timer = 0; // Do something from double tap } else { timer = 10; } notPressed = false; } else if(!Minecraft.getInstance().gameSettings.keyBindLeft.isKeyPressed) { notPressed = true; } This however never fired.
  9. Hi again, sorry to be a pain but do you have any source code I can look at? I'm having some issues with this firing multiple times. No worries if not
  10. Currently my mod is using both a server config and a client config, the issue here is that the server config appears to be save specific, which would cause issues for modpack creators. Is there any way I can make my common config sync with a server's common config? The config is used for balancing and if the player can change it just for themselves issues would arise. Thanks for your help!
  11. Is anyone aware of an alternate method to this? I'd imagine it works but I'm getting some odd behaviour in using both onKeyPressed() and isKeyDown() whilst using a boolean flag to make it only fire once. I've tried this in KeyInputEvent, ClientTickEvent and PlayerTickEvent. The issue is that when I hold down the key it will fire randomly at times and act as a double press. Edit: I tried onKeyPressed() by itself, and seperately tried isKeyDown() whilst using a boolean flag.
  12. I want to check if the default move back key is double tapped. I've tried looking into how Minecraft handles sprinting but I can't find the actual check for a double tap. Thanks for your help!
  13. I'm currently using ForgeConfigSpec builder which populates the config in the order it loads. Is there anyway to make it populate in the order of my code? I found another forum post on this that suggests using CommentedFileConfig builder, so if anyone knows of anywhere I can learn how to use it I'd appreciate it! Thanks for the help! Edit, I learned what define does I'm an idiot
  14. No worries at all man! You can find it on Mine and Slash's curse page and then click source. The issue is that MY mod breaks mine and slash but you can see that its HUD is rendered as the EXPERIENCE type in its source code. If you find a solution please let me know
  15. It's not because this stops rendering mods that use ElementType.EXPERIENCE as I said in my OP. If you don't believe me, look at the source code for mods such as mine and slash. The given code would stop that mod from loading all of its HUD.
  16. If anyone knows how to stop rendering specific parts of the HUD I'd really appreciate it
  17. Good point, I want it to not render. Sorry for not being clear.
  18. I want to disable the vanilla experience bar, however my current method of if (event.getType() == RenderGameOverlayEvent.ElementType.EXPERIENCE) { event.setCanceled(true); } Also disables any other mods HUDs that use ElementType.EXPERIENCE. is there anyway I can disable the vanilla exp bar without affecting anything else? Thanks for your help!
  19. Wow, thank you for such an in depth response! I'll get to work on testing it out ?
  20. Hi all, I'm currently trying to remove the infinity enchantment from bows, would this be possible with access transformers? I wan't to do this without breaking anything so I figured it's a good idea to ask. Thanks for your help!
  21. Ah that's not what I'm after, I'll rewrite my code for the entity type and get back to you. Many thanks. Edit: Turns out I didn't set up my deffered register correctly, works a charm now! Thanks for the support.
  22. Thanks for all your help diesieben07 but I ended up just using the vanilla EntityType.ARROW for now. Are there any issues with this approach if I'm happy with my arrow looking like the vanilla one? I'll take a look at those, thanks for the advice
×
×
  • Create New...

Important Information

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