From 3c8e9f56a945375fd090eb7424915603e86d3656 Mon Sep 17 00:00:00 2001 From: Floral <49110090+floral-qua-floral@users.noreply.github.com> Date: Sat, 30 Nov 2024 15:18:14 -0500 Subject: [PATCH] Starting to change Stomps to use interface injection --- .../com/floralquafloral/StompableEntity.java | 17 +++++++++++++ .../definitions/actions/ActionDefinition.java | 6 +++++ .../mixin/EntityStompabilityMixin.java | 25 +++++++++++++++++++ .../floralquafloral/mixin/EntityMixin.java | 4 ++- mod/src/main/resources/qua_mario.mixins.json | 1 + 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 api/src/main/java/com/floralquafloral/StompableEntity.java create mode 100644 api/src/main/java/com/floralquafloral/mixin/EntityStompabilityMixin.java diff --git a/api/src/main/java/com/floralquafloral/StompableEntity.java b/api/src/main/java/com/floralquafloral/StompableEntity.java new file mode 100644 index 0000000..cd5b9fd --- /dev/null +++ b/api/src/main/java/com/floralquafloral/StompableEntity.java @@ -0,0 +1,17 @@ +package com.floralquafloral; + +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.util.Identifier; + +public interface StompableEntity { + StompResult qua_mario$stomp(Identifier stompType, DamageSource damageSource, float amount); + + enum StompResult { + NORMAL, + PAINFUL, + GLANCING, + RESISTED, + FAIL_IF_BASIC, + FAIL + } +} diff --git a/api/src/main/java/com/floralquafloral/definitions/actions/ActionDefinition.java b/api/src/main/java/com/floralquafloral/definitions/actions/ActionDefinition.java index 2c92170..5a8bfe9 100644 --- a/api/src/main/java/com/floralquafloral/definitions/actions/ActionDefinition.java +++ b/api/src/main/java/com/floralquafloral/definitions/actions/ActionDefinition.java @@ -136,10 +136,16 @@ public boolean doSpeedScaling() { class BumpingRule { /** * A strength of 4 represents Super Mario being able to destroy a Brick Block, but Small Mario only bumping it. + * (Example: Ground Pound, hitting a block from below) + *

+ * A strength of 3 represents Super Mario and Small Mario both bumping a Brick Block without destroying it. + * (Example: Rolling into a wall, Bonking) *

* A strength of 2 represents Super Mario being able to shatter a Flip Block, and Small Mario having no effect on it. + * (Example: Spin Jump) *

* A strength of 1 represents Mario landing on a block and having no effect on it. + * (Example: Regular jump) */ public static final BumpingRule JUMPING = new BumpingRule(4, 1); public static final BumpingRule FALLING = new BumpingRule(4, 1); diff --git a/api/src/main/java/com/floralquafloral/mixin/EntityStompabilityMixin.java b/api/src/main/java/com/floralquafloral/mixin/EntityStompabilityMixin.java new file mode 100644 index 0000000..8215574 --- /dev/null +++ b/api/src/main/java/com/floralquafloral/mixin/EntityStompabilityMixin.java @@ -0,0 +1,25 @@ +package com.floralquafloral.mixin; + +import com.floralquafloral.StompableEntity; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Entity.class) +public abstract class EntityStompabilityMixin implements StompableEntity { + @Shadow public abstract EntityType getType(); + + @Override public StompResult qua_mario$stomp(Identifier stompType, DamageSource damageSource, float amount) { +// if(getType().isIn()) + + return StompResult.NORMAL; + } +} diff --git a/mod/src/main/java/com/floralquafloral/mixin/EntityMixin.java b/mod/src/main/java/com/floralquafloral/mixin/EntityMixin.java index 7a6dae6..754ff42 100644 --- a/mod/src/main/java/com/floralquafloral/mixin/EntityMixin.java +++ b/mod/src/main/java/com/floralquafloral/mixin/EntityMixin.java @@ -1,6 +1,7 @@ package com.floralquafloral.mixin; import com.floralquafloral.MarioQuaMario; +import com.floralquafloral.StompableEntity; import com.floralquafloral.mariodata.MarioDataManager; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.moveable.MarioMainClientData; @@ -18,6 +19,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; import net.minecraft.entity.MovementType; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; @@ -44,7 +46,7 @@ import java.util.Set; @Mixin(Entity.class) -public abstract class EntityMixin { +public class EntityMixin { @Inject(at = @At("HEAD"), method = "setSwimming(Z)V", cancellable = true) private void setSwimming(boolean swimming, CallbackInfo ci) { Entity entity = (Entity) (Object) this; diff --git a/mod/src/main/resources/qua_mario.mixins.json b/mod/src/main/resources/qua_mario.mixins.json index 6d2a4a9..37c8f5b 100644 --- a/mod/src/main/resources/qua_mario.mixins.json +++ b/mod/src/main/resources/qua_mario.mixins.json @@ -5,6 +5,7 @@ "mixins": [ "DamageSourceMixin", "EntityMixin", + "EntityStompabilityMixin", "LivingEntityMixin", "PlayerEntityMixin", "RedstoneViewMixin"