Skip to content

Commit

Permalink
Starting to change Stomps to use interface injection
Browse files Browse the repository at this point in the history
  • Loading branch information
floral-qua-floral committed Nov 30, 2024
1 parent e45e86d commit 3c8e9f5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
17 changes: 17 additions & 0 deletions api/src/main/java/com/floralquafloral/StompableEntity.java
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* <p>
* A strength of 3 represents Super Mario and Small Mario both bumping a Brick Block without destroying it.
* (Example: Rolling into a wall, Bonking)
* <p>
* 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)
* <p>
* 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 3 additions & 1 deletion mod/src/main/java/com/floralquafloral/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions mod/src/main/resources/qua_mario.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"mixins": [
"DamageSourceMixin",
"EntityMixin",
"EntityStompabilityMixin",
"LivingEntityMixin",
"PlayerEntityMixin",
"RedstoneViewMixin"
Expand Down

0 comments on commit 3c8e9f5

Please sign in to comment.