Jump to content

Recommended Posts

Posted

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.

 

Posted

You can see how that is rendered in Gui.renderCrossHair() using Player.getAttackStrengthScale()

  • Thanks 1

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.

Posted

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);
Posted

Do you really think this question is in anyway answerable?

It's 2 lines of code without any context.

 

My guess is you have the same or a similar problem to this: https://forums.minecraftforge.net/topic/114943-make-an-enchantment-specifically-for-a-shovel/#comment-509407

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.

Posted
  On 9/3/2022 at 11:25 PM, warjort said:

Do you really think this question is in anyway answerable?

It's 2 lines of code without any context.

 

My guess is you have the same or a similar problem to this: https://forums.minecraftforge.net/topic/114943-make-an-enchantment-specifically-for-a-shovel/#comment-509407

Expand  

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);
			}
		}
	}
Posted

Yes, you have the same problem as the other post (assuming you don't have a recent version of forge).

 

This is something that was very recently changed:

https://maven.minecraftforge.net/net/minecraftforge/forge/1.19.2-43.1.15/forge-1.19.2-43.1.15-changelog.txt

- 43.1.6  [1.19.x] Moved Player.resetAttackStrengthTicker() to the end of Player.attack() (#9000)

https://github.com/MinecraftForge/MinecraftForge/pull/9000

 

You can try the latest version of forge to see if your code now works.

 

  Quote

Also if there's any more context I need to give tell me, I'm new to this

Expand  

Being able to answer this question (rather than guessing) required knowing;

* where you are using the method

* which version of forge you are using

These are just part of the https://en.wikipedia.org/wiki/Five_Ws used to give a complete description of a problem.

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.

Posted
  On 9/4/2022 at 3:40 PM, warjort said:

Yes, you have the same problem as the other post (assuming you don't have a recent version of forge).

 

This is something that was very recently changed:

https://maven.minecraftforge.net/net/minecraftforge/forge/1.19.2-43.1.15/forge-1.19.2-43.1.15-changelog.txt

- 43.1.6  [1.19.x] Moved Player.resetAttackStrengthTicker() to the end of Player.attack() (#9000)

https://github.com/MinecraftForge/MinecraftForge/pull/9000

 

You can try the latest version of forge to see if your code now works.

 

Being able to answer this question (rather than guessing) required knowing;

* where you are using the method

* which version of forge you are using

These are just part of the https://en.wikipedia.org/wiki/Five_Ws used to give a complete description of a problem.

Expand  

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);
            }
        }
    }
}
Posted

The change has not been applied to 1.18.2, it was only added to 1.19.2 yesterday. 🙂 

https://github.com/MinecraftForge/MinecraftForge/commit/2a4230868ffaf5c364cfbea8c66e6c12176bd1c4

If you want to speed up the process, you can submit a PR for 1.18.2.

This change was regarded as a feature so it's not guaranteed to get backported to earlier versions unless somebody steps to do it.

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.

Posted (edited)

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 @@
Edited by Wolfboycoolkid
Posted

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.

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ignore shrimple, it doesn't work with Oculus. Also, enableShaders was alr true when it said that towards the end of the log. If you could also figure out why my tags are messed up that'd be cool too, but that's a later issue. https://drive.google.com/drive/folders/1ovEKDZECUCl7zZxGfpyQcS4s5PZPQyfa?usp=drive_link
    • accidental duplicate mesage cuz lag
    • https://gnomebot.dev/paste/231527759279685634/1372324909073563730/1372324908629102716 https://gnomebot.dev/paste/231527759279685634/1372320454861262908/1372320454299090996 seems like theres a registry sync error, not sure what that means though, however in an old pack i played on, i actually had a registry sync error happen whenever the world tried too save and it would suddenly stop loading chunks, is there a mod fix for this or some way too bypass registry syncing? is this a server problem? i have no issues with the pack on pc, only on my server.
    • i think the problem is the player animator library but i need it for one of my main mods is there any way i can fix this? The game crashed: rendering overlay Error: java.lang.IllegalArgumentException: Failed to create player model for default heres the crash report: https://pastebin.com/U5Wp8ysb
    • I have been an enthusiastic investor in crypt0currencies for several years, and my digital assets have been integral to my financial strategy. A few months ago, I encountered a distressing predicament when I lost access to my primary cryptocurrency walleet after clicking on an airdrop link that inadvertently connected to my walleet. The dread of potentially losing all my hard-earned funds was overwhelming, leaving me uncertain about where to seek assistance. In my pursuit of solutions, I stumbled upon ChainDigger Retrievers. From our initial consultation to the triumphant recovery of my assets, the team exhibited exceptional expertise. They provided comprehensive explanations of the recovery process, ensuring I was informed at every stage and offering reassurance during this tumultuous time. Their approach was not only meticulous but also compassionate, which significantly alleviated my anxiety. ChainDigger Retrievers unwavering commitment to resolving my issue was evident throughout the process. Leveraging their profound understanding of crypt0currency technology and digital forensics, they initiated an exhaustive investigation to trace the transactions linked to my compromised wallet. Their meticulous analysis and relentless determination were apparent as they left no stone unturned in their quest to recover my funds. After several days of diligent investigation, the team successfully recovered everything I had lost. They uncovered that the link I had clicked contained malware, which scammeers had used to infiltrate my walleet. This revelation was both alarming and enlightening, underscoring the inherent risks associated with crypt0currency transactions when proper precautions are not taken.Thanks to ChainDigger Retrievers, I not only regained everything but also acquired invaluable knowledge about safeguarding my investments. Their expertise and steadfast support transformed a daunting situation into a manageable one, and I am profoundly grateful for their assistance. I can now continue my investment journey with renewed confidence, knowing that I have a trustworthy ally in ChainDigger Retrievers. Their client satisfaction is truly commendable, and I wholeheartedly recommend their services to anyone facing similar challenges in the crypt0currency realm. With their help, I was able to turn a distressing time into a positive outcome, and I will forever be grateful for their support.  
  • Topics

×
×
  • Create New...

Important Information

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