Jefferzoonn Posted May 6 Report Share Posted May 6 I've been trying the guides on the wiki to create mods like the trampoline for example, but when jumping on top it applies falling damage and I would like to know if there is any way to cancel the falling damage Link to comment Share on other sites More sharing options...
Sabrium48 Posted October 19 Report Share Posted October 19 It worked with the Feather Fall Spell on the first Version of Rustbound Magic, but as of the latest update for that Mod it has stopped working. 1 Link to comment Share on other sites More sharing options...
Frepo Posted October 20 Report Share Posted October 20 I made it do the opposite (increase fall damage). It's basically a custom made behavior for the player, that extends EntityBehavior and overrides the OnFallToGround method in there. But I'm not quite sure it completely replaces the fall damage mechanic (actually I think my method adds on top of the vanilla method), I wrote that a looong time ago with little experience. But it increased the damage for sure, so I was content and never looked back at it again. Maybe you can find something useful here. Patch json Spoiler [ // HEALTH BEHAVIOR OVERHAUL { "side": "Server", "file": "game:entities/humanoid/player", "op": "add", "path": "/client/behaviors/0", "value": { "code": "BehaviorFTHealth" } }, { "side": "Server", "file": "game:entities/humanoid/player", "op": "add", "path": "/server/behaviors/0", "value": { "code": "BehaviorFTHealth" } } ] My custom behavior class Spoiler namespace fregtech { internal class BehaviorFTHealth : EntityBehavior { public BehaviorFTHealth(Entity entity) : base(entity) { } public override void Initialize(EntityProperties properties, JsonObject typeAttributes) { base.Initialize(properties, typeAttributes); } // FALL DAMAGE OVERHAUL public override void OnFallToGround(Vec3d positionBeforeFalling, double withYMotion) { float fallDmgMod = 1.8f; IInventory inv; if (!this.entity.Properties.FallDamage) { return; } double yDistance = Math.Abs(positionBeforeFalling.Y - this.entity.Pos.Y); if (yDistance < 3.5) { return; } if (withYMotion > -0.19) { return; } // reduce from gear if(this.entity is EntityPlayer) // this.entity.Api.Side == EnumAppSide.Server { EntityPlayer plr = this.entity as EntityPlayer; // GearInventory = characterInventory: // 0 = head (clothes), 1 = cape (clothes), 2 = over shirt (clothes), 3 = pants (clothes), 4 = boots (clothes), 5 = gloves (misc) // 6 = necklace (misc), 7 = brooch (misc), 8 = mask (misc), 9 = belt (misc), 10 = bracelet (misc), 11 = under shirt (clothes) // 12 = helmet (armor), 13 = body (armor), 14 = legs (armor) inv = plr.GearInventory; if(inv != null) { // each piece of clothing reduces fall damage by 5% if (!inv[0].Empty) {fallDmgMod -= 0.05f;} if (!inv[1].Empty) { fallDmgMod -= 0.05f; } if (!inv[2].Empty) { fallDmgMod -= 0.05f; } if (!inv[3].Empty) { fallDmgMod -= 0.05f; } if (!inv[4].Empty) { // boots if (inv[4].Itemstack.GetName() == "Catfeet boots") { fallDmgMod -= 0.25f; } else { fallDmgMod -= 0.05f; } } if (!inv[11].Empty) { fallDmgMod -= 0.05f; } // legs armor if (!inv[14].Empty) { } } } if (fallDmgMod <= 0.0) { return; } double fallDamage = yDistance - 3.5; double expectedYMotion = -0.04100000113248825 * Math.Pow(fallDamage, 0.75) - 0.2199999988079071; double yMotionLoss = Math.Max(0.0, -expectedYMotion + withYMotion); fallDamage -= 20.0 * yMotionLoss; if (fallDamage <= 0.0) { return; } //// TESTING //if (this.entity.World.Side == EnumAppSide.Client) //{ // (this.entity.Api as ICoreClientAPI).TriggerIngameError(this, "error-msg", Lang.Get("Extra damage factor: " + fallDmgMod, Array.Empty<object>())); //} this.entity.ReceiveDamage(new DamageSource { Source = EnumDamageSource.Fall, Type = EnumDamageType.Gravity }, (float)fallDamage*fallDmgMod); } public override string PropertyName() { //throw new NotImplementedException(); return "extrafalldamage"; } } } Maybe you can just write something like this public override void OnFallToGround(Vec3d positionBeforeFalling, double withYMotion) { return; } But again, I'm very unsure that this method completely replaces the vanilla mechanic. 1 Link to comment Share on other sites More sharing options...
Jefferzoonn Posted October 20 Author Report Share Posted October 20 8 minutes ago, Frepo said: I made it do the opposite (increase fall damage). It's basically a custom made behavior for the player, that extends EntityBehavior and overrides the OnFallToGround method in there. But I'm not quite sure it completely replaces the fall damage mechanic (actually I think my method adds on top of the vanilla method), I wrote that a looong time ago with little experience. But it increased the damage for sure, so I was content and never looked back at it again. Maybe you can find something useful here. Patch json Reveal hidden contents My custom behavior class Hide contents namespace fregtech { internal class BehaviorFTHealth : EntityBehavior { public BehaviorFTHealth(Entity entity) : base(entity) { } public override void Initialize(EntityProperties properties, JsonObject typeAttributes) { base.Initialize(properties, typeAttributes); } // FALL DAMAGE OVERHAUL public override void OnFallToGround(Vec3d positionBeforeFalling, double withYMotion) { float fallDmgMod = 1.8f; IInventory inv; if (!this.entity.Properties.FallDamage) { return; } double yDistance = Math.Abs(positionBeforeFalling.Y - this.entity.Pos.Y); if (yDistance < 3.5) { return; } if (withYMotion > -0.19) { return; } // reduce from gear if(this.entity is EntityPlayer) // this.entity.Api.Side == EnumAppSide.Server { EntityPlayer plr = this.entity as EntityPlayer; // GearInventory = characterInventory: // 0 = head (clothes), 1 = cape (clothes), 2 = over shirt (clothes), 3 = pants (clothes), 4 = boots (clothes), 5 = gloves (misc) // 6 = necklace (misc), 7 = brooch (misc), 8 = mask (misc), 9 = belt (misc), 10 = bracelet (misc), 11 = under shirt (clothes) // 12 = helmet (armor), 13 = body (armor), 14 = legs (armor) inv = plr.GearInventory; if(inv != null) { // each piece of clothing reduces fall damage by 5% if (!inv[0].Empty) {fallDmgMod -= 0.05f;} if (!inv[1].Empty) { fallDmgMod -= 0.05f; } if (!inv[2].Empty) { fallDmgMod -= 0.05f; } if (!inv[3].Empty) { fallDmgMod -= 0.05f; } if (!inv[4].Empty) { // boots if (inv[4].Itemstack.GetName() == "Catfeet boots") { fallDmgMod -= 0.25f; } else { fallDmgMod -= 0.05f; } } if (!inv[11].Empty) { fallDmgMod -= 0.05f; } // legs armor if (!inv[14].Empty) { } } } if (fallDmgMod <= 0.0) { return; } Tal vez puedas escribir algo como esto. Pero nuevamente, no estoy muy seguro de que este método reemplace completamente la mecánica básica. Thank you very much for your contribution, as soon as I have some free time I will try it. Link to comment Share on other sites More sharing options...
Recommended Posts