-
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.
Preparing to move most Entity Mixins into PlayerEntityMixin
- Loading branch information
1 parent
3c8e9f5
commit 0431012
Showing
8 changed files
with
193 additions
and
111 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
api/src/main/java/com/floralquafloral/StompableEntity.java
This file was deleted.
Oops, something went wrong.
45 changes: 36 additions & 9 deletions
45
api/src/main/java/com/floralquafloral/mixin/EntityStompabilityMixin.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 |
---|---|---|
@@ -1,25 +1,52 @@ | ||
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.Saddleable; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.damage.DamageType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
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; | ||
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; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
@SuppressWarnings("UnusedMixin") | ||
@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()) | ||
@Shadow public abstract boolean damage(DamageSource source, float amount); | ||
|
||
return StompResult.NORMAL; | ||
@Unique private static final TagKey<EntityType<?>> UNSTOMPABLE_ENTITIES = | ||
TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("qua_mario:unstompable")); | ||
@Unique private static final TagKey<EntityType<?>> HURTS_TO_STOMP_ENTITIES = | ||
TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("qua_mario:hurts_to_stomp")); | ||
@Unique private static final TagKey<EntityType<?>> IMMUNE_TO_BASIC_STOMP_ENTITIES = | ||
TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("qua_mario:immune_to_basic_stomp")); | ||
|
||
@Unique private static final TagKey<DamageType> BASIC_STOMPS = | ||
TagKey.of(RegistryKeys.DAMAGE_TYPE, Identifier.of("qua_mario:basic_stomps")); | ||
|
||
@Override public StompResult qua_mario$stomp(PlayerEntity mario, Identifier stompType, DamageSource damageSource, float amount) { | ||
Entity self = (Entity) (Object) this; | ||
|
||
if(self instanceof VehicleEntity || (self instanceof Saddleable saddleable && saddleable.isSaddled())) | ||
if((!(self instanceof MinecartEntity minecart) || minecart.getMinecartType() == AbstractMinecartEntity.Type.RIDEABLE)) | ||
if(mario.startRiding(self, false)) | ||
return StompResult.MOUNT; | ||
|
||
if(getType().isIn(UNSTOMPABLE_ENTITIES)) return StompResult.FAIL; | ||
if(getType().isIn(HURTS_TO_STOMP_ENTITIES)) return StompResult.PAINFUL; | ||
if(getType().isIn(IMMUNE_TO_BASIC_STOMP_ENTITIES) && damageSource.isIn(BASIC_STOMPS)) return StompResult.FAIL; | ||
|
||
boolean damaged = damage(damageSource, amount); | ||
if(damaged) return StompResult.NORMAL; | ||
else return StompResult.FAIL; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
api/src/main/java/com/floralquafloral/mixin/StompableEntity.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,28 @@ | ||
package com.floralquafloral.mixin; | ||
|
||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.util.Identifier; | ||
|
||
public interface StompableEntity { | ||
StompResult qua_mario$stomp(PlayerEntity mario, Identifier stompType, DamageSource damageSource, float amount); | ||
|
||
/** | ||
* NORMAL - The Stomp behaves normally. Would be returned by a Goomba. | ||
* PAINFUL - Trying to Stomp this entity hurts Mario. Would be returned by a Spiny or a Piranha Plant. | ||
* GLANCING - Used internally. Returning this is not recommended. | ||
* RESISTED - Mario bounces off this entity without hurting it. Would be returned by a Wiggler after the first time it's been stomped. | ||
* FAIL_IF_BASIC - Mario passes through the entity unless he's Ground Pounding. Would be returned by a Blockhopper (look it up). | ||
* FAIL - Mario can't stomp this entity. Would be returned by a Boo. | ||
* MOUNT - Trying to Stomp this entity instead Mounts it. Would be returned by Yoshi. | ||
*/ | ||
enum StompResult { | ||
NORMAL, | ||
PAINFUL, | ||
GLANCING, | ||
RESISTED, | ||
FAIL_IF_BASIC, | ||
FAIL, | ||
MOUNT | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
mod/src/main/resources/data/qua_mario/tags/damage_type/basic_stomps.json
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,6 @@ | ||
{ | ||
"values": [ | ||
"qua_mario:stomp", | ||
"qua_mario:spin_jump" | ||
] | ||
} |
Oops, something went wrong.