Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using fists for knockback is op #7

Open
tubposs opened this issue May 7, 2019 · 2 comments
Open

using fists for knockback is op #7

tubposs opened this issue May 7, 2019 · 2 comments

Comments

@tubposs
Copy link

tubposs commented May 7, 2019

im doing some mapmaking and this mod was absolutely perfect for what i needed, but ive found out that if you just punch enemies rapidly you can just knock them back as much as you need and even deal more damage than slow weapons, ive tried many things to fix this like making the players base attack speed less but that never works, and setting the config to give iframes when i attack npcs somewhat works but isnt the best solution

@ProfHugo
Copy link
Owner

ProfHugo commented May 9, 2019

I was aware of this when I was playing around with it a while ago, and I implemented a countermeasure specifically for this.

from EntityHandler.java

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerAttack(AttackEntityEvent event) {
	if (!event.isCanceled()) {
		EntityPlayer player = event.getEntityPlayer();
		if (player.getEntityWorld().isRemote) {
			return;
		}
		float str = player.getCooledAttackStrength(0);
		if (str <= NodamiConfig.attackCancelThreshold) {
			event.setCanceled(true);
			return;
		}
		if (str <= NodamiConfig.knockbackCancelThreshold) {
			// Don't worry, it's only magic
			player.hurtTime = -1;
		}
	}
}

	@SubscribeEvent(priority = EventPriority.LOWEST)
	public void onKnockback(LivingKnockBackEvent event) {
		if (!event.isCanceled()) {
			Entity attacker = event.getAttacker();
			if (attacker != null && !attacker.getEntityWorld().isRemote) {
				// IT'S ONLY MAGIC
				if (attacker instanceof EntityPlayer && ((EntityPlayer) attacker).hurtTime == -1) {
					event.setCanceled(true);
					((EntityPlayer) attacker).hurtTime = 0;
				}
			}
		}
	}

from NodamiConfig.java

private static void syncConfig() {
	// line30-33
	attackCancelThreshold = config.getFloat("attackCancelThreshold", "thresholds", 0.1f, -0.1f, 1, "How weak a player's attack can be before it gets nullified, from 0 (0%, cancels multiple attacks on the same tick) to 1 (100%, players cannot attack), or -0.1 (disables this feature)");
	knockbackCancelThreshold = config.getFloat("knockbackCancelThreshold", "thresholds", 0.75f, -0.1f, 1, "How weak a player's attack can be before the knockback gets nullified, from 0 (0%, cancels multiple attacks on the same tick) to 1 (100%, no knockback), or -0.1 (disables this feature)");
	// line 36-44
}

Despite being a very bootleg implementation, I've tested this quite extensively and so far it works fine for me. Could you give me more detail as to how you were able to knockback enemies with weak attacks even with the default configs. Give me a list of mods you're using alongside aswell, since this may very well be due to mod intereactions.

@tubposs
Copy link
Author

tubposs commented May 9, 2019

im pretty sure it was because the player has a base attack time of 4 which is really fast, and by removing iframes on all entities all my punch or non-tool items i could hit them like 3 times a second for what the game thought was a fully charged attack despite doing 1 dmg a hit, testing with weapons that reduce my attack speed worked as intended however
list of mods:
[1.12] RPG-HUD-3.6.6.2
AmbientSounds v2.0.8 mc1.12
Antique-Atlas-1.12
AppleCore-mc1.12.2-3.2.0
Baubles-1.12-1.5.2 (1)
BetterFoliage-MC1.12-2.1.10
BetterFps-1.4.8
CodeChickenLib-1.12.1
ConquestReforged-3.0.2-mc1.12.2
CustomNPCs_1.12.2(30Jan19) (1)
FastAsyncWorldEdit-forge112-18.04.20-cfe47d2-1080-19.5.14
foamfix-0.9.5-1.12.2-anarchy
forge-1.12.2-14.23.5.2768-universal
Forgelin-1.8.2
FullscreenWindowed-1.12-1.6.0
HungerOverhaul-1.12.2-1.3.3.jenkins148
journeymap-1.12.2-5.5.2
Just-Enough-Items-Mod-1.12.2
luaj-jse-3.0.1
MorePlayerModels_1.12.2(18jan18)
nashorn
NBTEdit-0.7
nodami-1.12.2-1.2.1
NotEnoughIDs-1.5.4.3
Not-Enough-Items-1.12.2-Recommended
OptiFine_1.12.2_HD_U_D1
Pam's+HarvestCraft+1.12.2zb
PotionCore-1.6_for_1.12.2
quickhotbar_112_1.05
ScalingHealth-1.12.2-1.3.32-134
ServerRedirect-Forge-MC1.12.2-1.3.7
ShadowMC-1.12-3.8.0
SilentLib-1.12.2-3.0.13+167
Thaumcraft-1.12.2-6.1.BETA19
VariedCommodities_1.12.2(15may18
WorldEdit CUI Forge Edition 2-2.1.2-mf-1.12.2-14.23.0.2487
worldedit-forge-mc1.12-6.1.8-dist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants