-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Footstep sounds no longer play when Mario's current action is a Slidi…
…ng action. Game event is also not emitted (so no triggering things like Sculk Sensors with nonexistent footsteps).
- Loading branch information
1 parent
8730945
commit a427a07
Showing
13 changed files
with
143 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
api/src/main/java/com/fqf/mario_qua_mario/interfaces/IStompableEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.fqf.mario_qua_mario.interfaces; | ||
|
||
import com.fqf.mario_qua_mario.mariodata.IMarioAuthoritativeData; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.Saddleable; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.damage.DamageType; | ||
import net.minecraft.entity.vehicle.AbstractMinecartEntity; | ||
import net.minecraft.entity.vehicle.MinecartEntity; | ||
import net.minecraft.entity.vehicle.VehicleEntity; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.registry.tag.TagKey; | ||
import net.minecraft.util.Identifier; | ||
|
||
/** | ||
* An entity can implement this interface and override its methods to change Stomp attacks interact with it. | ||
*/ | ||
public interface IStompableEntity { | ||
default StompResult mqm$getStompResult( | ||
IMarioAuthoritativeData mario, | ||
Identifier stompType, | ||
boolean canMount, | ||
DamageSource damageSource, | ||
float amount | ||
) { | ||
// Only entities can be stomped. | ||
if(!(this instanceof Entity entity)) return StompResult.FAIL; | ||
|
||
// Mario can mount some entities by falling onto them from above, like how he mounts Yoshi in most games. | ||
if(canMount && this.mqm$isStompMountable() && mario.getMario().startRiding(entity, false)) | ||
return StompResult.MOUNT; | ||
|
||
// Various datapack-tag-driven interactions | ||
if(entity.getType().isIn(UNSTOMPABLE_ENTITIES)) return StompResult.FAIL; | ||
if(entity.getType().isIn(HURTS_TO_STOMP_ENTITIES)) return StompResult.PAINFUL; | ||
if(entity.getType().isIn(IMMUNE_TO_BASIC_STOMP_ENTITIES) && damageSource.isIn(BASIC_STOMPS)) return StompResult.FAIL; | ||
|
||
// Attempt to apply the damage from the stomp to the entity. | ||
// If the damage goes through, then Mario should do a normal stomp. | ||
// If it doesn't, that means the entity is probably immune for whatever reason, and Mario should do a Resisted stomp. | ||
boolean damaged = entity.damage(damageSource, amount); | ||
|
||
if(damaged) return StompResult.NORMAL; | ||
else return StompResult.RESISTED; | ||
} | ||
|
||
default boolean mqm$isStompMountable() { | ||
if(this instanceof VehicleEntity vehicle) { | ||
// If we're a vehicle, then: | ||
// - If we're a Minecart, then return true if we're an empty minecart (as opposed to, i.e., a Chest Minecart) | ||
// - If we're not a Minecart, then return true | ||
return !(vehicle instanceof MinecartEntity minecart) || minecart.getMinecartType() != AbstractMinecartEntity.Type.RIDEABLE; | ||
} | ||
if(this instanceof Saddleable saddleable) { | ||
// If we're something that can be saddled, then: | ||
// - If we're saddled, then return true | ||
// - If we're not saddled, then return false | ||
return saddleable.isSaddled(); | ||
} | ||
|
||
// If we're neither a vehicle nor saddleable, then return false. | ||
return false; | ||
} | ||
|
||
TagKey<EntityType<?>> UNSTOMPABLE_ENTITIES = | ||
TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("mario_qua_mario:unstompable")); | ||
TagKey<EntityType<?>> HURTS_TO_STOMP_ENTITIES = | ||
TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("mario_qua_mario:hurts_to_stomp")); | ||
TagKey<EntityType<?>> IMMUNE_TO_BASIC_STOMP_ENTITIES = | ||
TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("mario_qua_mario:immune_to_basic_stomp")); | ||
|
||
TagKey<DamageType> BASIC_STOMPS = | ||
TagKey.of(RegistryKeys.DAMAGE_TYPE, Identifier.of("mario_qua_mario:basic_stomps")); | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/java/com/fqf/mario_qua_mario/interfaces/StompResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.fqf.mario_qua_mario.interfaces; | ||
|
||
public enum StompResult { | ||
NORMAL, | ||
PAINFUL, | ||
GLANCING, | ||
RESISTED, | ||
FAIL, | ||
MOUNT | ||
} |
9 changes: 9 additions & 0 deletions
9
api/src/main/java/com/fqf/mario_qua_mario/mixin/EntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.fqf.mario_qua_mario.mixin; | ||
|
||
import net.minecraft.entity.Entity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(Entity.class) | ||
public abstract class EntityMixin { | ||
|
||
} |
15 changes: 0 additions & 15 deletions
15
api/src/main/java/com/fqf/mario_qua_mario/mixin/ExampleMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
accessWidener v2 named | ||
|
||
accessible class net/minecraft/client/gui/hud/InGameHud$HeartType | ||
accessible class net/minecraft/client/gui/hud/InGameHud$HeartType | ||
extendable method net/minecraft/entity/Entity stepOnBlock (Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;ZZLnet/minecraft/util/math/Vec3d;)Z | ||
extendable method net/minecraft/entity/Entity playStepSounds (Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters