pWn3d1337 / Techguns

Techguns mod for minecraft
https://minecraft.curseforge.com/projects/techguns
16 stars 4 forks source link

Protection bypass #69

Open LemADEC opened 7 years ago

LemADEC commented 7 years ago

As of Techguns.beta.1.2_alphatest3.jar, all weapons and explosives are bypassing entity and block protection (notably in spawn). We can't use the mod 'as is' on a public server.

pWn3d1337 commented 7 years ago

That's something I wanted to add, and also that it works with protection mods like FTBUtilities. But I was not sure how.

LemADEC commented 7 years ago

You don't want to rely on FTBUtilities. It's fairly broken and disabled on major servers.

Forge already supports block level protection, see this example

Regarding entity protection, I didn't check your code, so I'm not sure what's causing it.

pWn3d1337 commented 7 years ago

So just using the forge events for explosion and block break should do the trick.

About entity protection: i don't really know how this is handled. Just with damage events?

LemADEC commented 7 years ago

I know it works in my GunCus mod, just not 100% sure why:

LemADEC commented 7 years ago

Any chances we could have a fix for those protection issues in the coming week or so? Or should be consider the mod a bit too unstable for now?

pWn3d1337 commented 7 years ago

I can release a new alpha version soon. I want to fix the protection for the grenades/rockets before.

As for stability: I played with it the last two weeks on a dedicated server and had not a single crash with it.

LemADEC commented 7 years ago

Good to know, keep on the good work :)

pWn3d1337 commented 7 years ago

Im posting the explosion events now, cancelling damage and block damage works with my own event handlers.

LemADEC commented 7 years ago

Explosive charges are fixed. We'll test weapons later on

LemADEC commented 7 years ago

Bioguns can place blocks in protected area => nok Explosive effects don't break blocks in protected area => ok Entities are still getting damaged in protected area => nok

pWn3d1337 commented 7 years ago

I added a BlockPlace Event to the biogun which can be cancelled, but I have no idea how Entity protection works, is this vanilla or are you using a mod for that?

LemADEC commented 7 years ago

You need to use Arrows or IProjectile entities to deal the bullet damages, Any other sources requires some ASM into the server side of things.

pWn3d1337 commented 7 years ago

They are IProjectiles.

LemADEC commented 7 years ago

Assuming my memory got that right, you need to apply damage through the method EntityLivingBase.damageEntity(damageSource, amount), either directly or indirectly. You can do it indirectly by calling EntityLivingBase.attackEntityFrom().

pWn3d1337 commented 7 years ago

this is exactly how Techguns projectiles work.

pWn3d1337 commented 7 years ago

I need to know where this Entity Protection comes from? Vanilla? Or are you using a mod? I don't know about it.

LemADEC commented 7 years ago

It's Bukkit plugin based protection, implemented through MCPC/Cauldron/etc.

pWn3d1337 commented 7 years ago

There could be a problem with an eventHandler, I added "receiveCanceled=false", i think it could have uncancel a canceled attackEvent.

LemADEC commented 7 years ago

Not sure what you mean here? Bukkit doesn't handle entity events from forge, sadly.

pWn3d1337 commented 7 years ago

Can you provide a link to the plugin, then I can take a look at it. But if bukkit does it's own thing it might not be compatible. Techguns uses reflection to call a modified damage function instead of the vanilla one, so the damage system (damage types, hurt resist time ignore, knockback multipliers) can work. All forge event are still thrown, but if bukkit uses some own hooks on the vanilla method it might not be compatible.

LemADEC commented 7 years ago

You need to call the Vanilla/Forge method I gave you. Bukkit is replacing it with its own.

pWn3d1337 commented 7 years ago

Then it is not compatible. I need to work around the vanilla damage method since things like knockback, hurtresist time and stuff like that are very hardcoded.

You need a forge plugin for protection, that will work.

LemADEC commented 7 years ago

Which forge event are you using?

LemADEC commented 7 years ago

ForgeHooks.onLivingHurt() is always called before you do damage resolution?

pWn3d1337 commented 7 years ago

onLivingHurt is called, so this should work.

LemADEC commented 7 years ago

Grim reaper and Nuke launcher are also bypassing spawn protection (breaking dirt and stone blocks).