Jump to content

Wolfboycoolkid

Members
  • Posts

    8
  • Joined

  • Last visited

Wolfboycoolkid's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. After trying to figure this out I'm confused. I'm pretty confident I know what I have to change & where But then there's these lines of code that I have a vague idea of what they do but no idea how to reproduce them. @@ -1200,7 +_,7 @@
  2. Alright, I've update my forge to the latest, although from what I can tell the change was done on 1.19, which isn't useful for me as I'm using 1.18.2. Also I'm now using Forge 40.1.76 - 1.18.2 I'm not sure how I can show where I'm using the method precisely without you having to search through the code. Also for this I'm using an actual IDE (Intellij) so my code has changed slightly, as well I've changed some stuff that I think is better. package com.shadowdragon.swordtember.events; import com.shadowdragon.swordtember.advanceditems.AmethystBroadswordItem; import com.shadowdragon.swordtember.registry.Items; import net.minecraft.Util; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.TextComponent; import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.server.ServerLifecycleHooks; @Mod.EventBusSubscriber public class LivingEntityHurt { @SubscribeEvent public static void onEntityAttacked(LivingHurtEvent event) { if (event != null && event.getEntity() != null && event.getSource().getEntity() != null) { // Attacking entity LivingEntity entity = (LivingEntity) event.getSource().getEntity(); // Item in main-hand of entity Item item = entity.getMainHandItem().getItem(); Item amethystBroadsword = Items.amethystBroadsword.get(); boolean yeetTarget = false; // Is Amethyst Broadsword if (item instanceof AmethystBroadswordItem) { // If they're a player, wait for the max cooldown to attack // Else just attack if (entity instanceof Player player) { float testVar = player.getAttackStrengthScale(0.0f); // <--- HERE // Nope float cooldownPercent = player.getCooldowns().getCooldownPercent(amethystBroadsword, 0.1f); // Debug if (!entity.level.isClientSide()) { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); if (server != null) { server.getPlayerList().broadcastMessage(new TextComponent(Float.toString(testVar)), ChatType.SYSTEM, Util.NIL_UUID); } } } else { yeetTarget = true; } } // Yeet the target if (yeetTarget) { float knockbackAmount = 6.5f; double knockbackX = 0 - entity.getLookAngle().x(); double knockbackZ = 0 - entity.getLookAngle().z(); event.getEntityLiving().knockback(knockbackAmount, knockbackX, knockbackZ); } } } }
  3. Looking at it yep, I do have that problem. Seeing as getAttackStrengthScale resets to 0 every attack I'm not sure how to get it before it resets, how would I do that? Also if there's any more context I need to give tell me, I'm new to this My code: public static void onEntityAttacked(LivingHurtEvent event) { if (event != null && event.getEntity() != null && event.getSource().getEntity() != null) { // Attacking entity LivingEntity entity = (LivingEntity) event.getSource().getEntity(); // Item in main-hand of entity Item item = entity.getMainHandItem().getItem(); Item amethystBroadsword = SwordtemberModItems.AMETHYST_BROADSWORD.get(); boolean yeetTarget = false; // Is Amethyst Broadsword if (item instanceof AmethystBroadswordItem) { // If they're a player, wait for the max cooldown to attack // Else just attack if (entity instanceof Player) { Player player = (Player) entity; float testVar = player.getAttackStrengthScale(0.0f); // Nope float cooldownPercent = player.getCooldowns().getCooldownPercent(amethystBroadsword, 0.1f); // Debug if (!entity.level.isClientSide()) { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); if (server != null) { server.getPlayerList().broadcastMessage(new TextComponent(Float.toString(testVar)), ChatType.SYSTEM, Util.NIL_UUID); } } } else { yeetTarget = true; } } // Yeet the target if (yeetTarget == true) { float knockbackAmount = 6.5f; double knockbackX = 0 - entity.getLookAngle().x(); double knockbackZ = 0 - entity.getLookAngle().z(); event.getEntityLiving().knockback(knockbackAmount, knockbackX, knockbackZ); } } }
  4. I'm trying to do this but it always returns 0.0, there's no dynamic change. Increasing it gives weird numbers till a max of 66.6668. Player player = (Player) entity; float testVar = player.getAttackStrengthScale(0.0f);
  5. I want to get the progress of the attack indicator. I have a weapon that has a lot of knockback, I want to balance by applying the knockback based on how much progress the attack indicator has. If you don't know what I'm talking about have a look at the video, it's the long sword in the middle.
×
×
  • Create New...

Important Information

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