Jump to content

BliX5

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by BliX5

  1. I'm trying to make a GUI display when you press a key. So far I have the keybind ready, but I'm trying to get the GUI to work. Is there a way to create a TileEntity without connecting it to a block or a workaround for making a standalone GUI? Thanks in advance.
  2. Game blocks hits, hits that do hit have incorrect damage. I will try this
  3. I want cancel the ClickEvent event if the player is on attack cooldown, which I did, but if you click during attack cooldown, the game stores what that hit would have been and makes the next hit that energy, decreasing the attack strength for the final hit. In short, spam clicking will stop the player from spam hitting, but does lower damage, which isn’t what I want. I need a workaround for this
  4. Yes, I know, but this is also the event I want to cancel, which is what I need help with.
  5. I’m not looking for the last attacked entity, I’m looking for the entity the player is currently attacking, and I assumed it could do that.
  6. Still confused about how to go about this.
  7. Originally I just wanted to make an event that cancelled a player's hit when they were on attack cooldown, as part of my combat system. But when the player did hit, it continued the cooldown and canceled the damage like intended, but the damage the target took when the player made a full hit was based on the first hit during cooldown, which meant if you spam clicked, you're full hit would do less damage, which was not what I wanted. Here's the code I made previously that did this: @SubscribeEvent public static void onClickEvent(InputEvent.ClickInputEvent event) { Minecraft mc = Minecraft.getInstance(); PlayerEntity player = mc.player; if (event.isAttack()) { float cooldown = player.getCooledAttackStrength(0); if(cooldown < 1) { event.setCanceled(true); } } } I tried to fix this myself by taking the target and cooldown and adding extra damage, which was obviously a mistake because it overcomplicated the code and it ended up not working anyways.
  8. Will a static field work in transferring information between two client events? Edit: Tried it, AttackEntityEvent is still called late like I explained earlier, despite having a higher priority.
  9. No, I'm saying that the client needs information from the server before the server can detect it, which is my point. Edit: I think you misunderstood what I meant. The server event is called after the client event, so when the player hits, the client calls the server for the entity it's attacking, and of course, since the server is late, the client will finish it's process with null and the previous information is left for the next hit. Whatever entity the player is currently attacking or last attacked.
  10. Tried it, but since ServerEvents are called after ClientEvents, it stores the target too late for the client event to register it on the first hit. In other words, it will damage the target of the previous hit instead of the current hit.
  11. How would I find the entity the player is attacking client side? I've been searching for the past day and couldn't find anything.
  12. I'm using ClickInputEvent so that I can cancel an attack cooldown entirely, instead of just the damage the attack does. In other words, I need to detect the client-side left click, not just the attack.
  13. Still have no luck in finding any solution.
  14. I'm making an event that detects a player attack, which all works well. Now I need to detect the entity the player is attacking. I tried doing this with getLastAttackedEntity, but it always returns null for some reason. Here's the event I have: @SubscribeEvent public static void onClickEvent(InputEvent.ClickInputEvent event) { PlayerEntity player = Minecraft.getInstance().player; if (event.isAttack()) { BotwMod.LOGGER.debug(player.getLastAttackedEntity()); } }
  15. Thanks, it works now! Here's my final code: @SubscribeEvent public static void onClickEvent(InputEvent.ClickInputEvent event) { PlayerEntity player = Minecraft.getInstance().player; if(event.isAttack()) { if(player.getCooledAttackStrength(0) < 1) { event.setCanceled(true); } } }
  16. Nevermind, I just needed to replace "Entity" in Entity player = Minecraft.getInstance().player; with PlayerEntity.
  17. if(player.getCooledAttackStrength(0) < 1) { event.setCanceled(true); } Doesn't work for me, it doesn't think getCooledAttackStrength exists. What am I missing?
  18. Would this work? Entity player = Minecraft.getInstance().player;
  19. @SubscribeEvent public static void onClickEvent(InputEvent.ClickInputEvent event, Entity entityIn) { PlayerEntity player = (PlayerEntity)entityIn; if(event.isAttack()) { if(player.getCooledAttackStrength(0) < 1) { event.setCanceled(true); } } } Pretty sure this doesn't work because events shouldn't have any other parameters, but this is the only way I could think of calling it.
  20. Before when I called getCooledAttackStrenght, I was using AttackEntityEvent to call it. @SubscribeEvent public static void onPlayerHit(AttackEntityEvent event) { if(event.getPlayer().getCooledAttackStrength(0) < 1.0F) { event.setCanceled(true); } } I couldn't find a way to call this method again with ClickInputEvent without my game crashing.
  21. How do I call getCooledAttackStrength from the ClickInputEvent?
  22. I need the AttackEntityEvent to determine when the player is on attack cooldown or not, unless there is another way to access that.
  23. I only know the basics of Java, and barely anything about how Forge works. It would be great if you could help me find an alternative instead of listing everything I'm doing wrong.
  24. Main Class: @Mod("botw") public class BotwMod { public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "botw"; public BotwMod() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.addListener(this::setup); ModBlocks.BLOCKS.register(bus); ModItems.ITEMS.register(bus); ModEntityTypes.ENTITY_TYPES.register(bus); MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGHEST, ModServerEvents::onPlayerHit); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, ModClientEvents::onClickEvent); } private void setup(final FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(() -> { }); } private void doClientStuff(final FMLClientSetupEvent event) { } ModClientEvents: @Mod.EventBusSubscriber(modid = BotwMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ModClientEvents { public static float a = 1; @SubscribeEvent public static void onClickEvent(InputEvent.ClickInputEvent event) { BotwMod.LOGGER.debug("ModClientEvents"); //used for debugging if(event.isAttack()) { if(ModClientEvents.a < 1) { ModClientEvents.a = 1; event.setCanceled(true); } } } } ModServerEvents: @Mod.EventBusSubscriber(modid = BotwMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class ModServerEvents { @SubscribeEvent public static void onPlayerHit(AttackEntityEvent event) { BotwMod.LOGGER.debug("ModServerEvents"); //used for debugging ModClientEvents.a = event.getPlayer().getCooledAttackStrength(0); } }
×
×
  • Create New...

Important Information

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