diff --git a/common/src/main/java/com/iafenvoy/sow/item/block/TemporaryTransparentBlock.java b/common/src/main/java/com/iafenvoy/sow/item/block/TemporaryTransparentBlock.java index 9e07c56..8cad81e 100644 --- a/common/src/main/java/com/iafenvoy/sow/item/block/TemporaryTransparentBlock.java +++ b/common/src/main/java/com/iafenvoy/sow/item/block/TemporaryTransparentBlock.java @@ -8,6 +8,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; @@ -37,4 +38,11 @@ public static void place(World world, BlockPos pos, BlockState state, int tick) blockEntity.setState(s); } } + + @Override + public void onLandedUpon(World world, BlockState state, BlockPos pos, Entity entity, float fallDistance) { + if (this.getJumpVelocityMultiplier() > 2) + entity.handleFallDamage(fallDistance, 0, world.getDamageSources().fall()); + else super.onLandedUpon(world, state, pos, entity, fallDistance); + } } diff --git a/common/src/main/java/com/iafenvoy/sow/mixin/LivingEntityMixin.java b/common/src/main/java/com/iafenvoy/sow/mixin/LivingEntityMixin.java index ac6c952..a9b116a 100644 --- a/common/src/main/java/com/iafenvoy/sow/mixin/LivingEntityMixin.java +++ b/common/src/main/java/com/iafenvoy/sow/mixin/LivingEntityMixin.java @@ -2,12 +2,12 @@ import com.iafenvoy.sow.power.SongPowerData; import com.iafenvoy.sow.registry.power.MobiliumPowers; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -31,12 +31,13 @@ private void handleFallFlyingCheck(CallbackInfo ci) { } @SuppressWarnings("all") - @ModifyExpressionValue(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z", ordinal = 0)) - private boolean handleSlideSpeed(boolean original) { + @Inject(method = "tick", at = @At("RETURN")) + private void endTick(CallbackInfo ci) { + if (this.isRemoved() || this.hasNoGravity()) return; if ((Object) this instanceof PlayerEntity player && SongPowerData.byPlayer(player).powerEnabled(MobiliumPowers.MOBILIGLIDE)) { + Vec3d velocity = this.getVelocity(); + this.setVelocity(velocity.x, 0.01 / 4.0, velocity.z); this.fallDistance = 0; - return true; } - return original; } } diff --git a/common/src/main/java/com/iafenvoy/sow/power/SongPowerData.java b/common/src/main/java/com/iafenvoy/sow/power/SongPowerData.java index c30e4ed..b2de1d1 100644 --- a/common/src/main/java/com/iafenvoy/sow/power/SongPowerData.java +++ b/common/src/main/java/com/iafenvoy/sow/power/SongPowerData.java @@ -120,8 +120,11 @@ public void removeComponent(String id) { this.components.remove(id); } - public boolean powerEnabled(AbstractSongPower power) { - return this.powerEnabled(power.getCategory(), power); + public boolean powerEnabled(AbstractSongPower... powers) { + for (AbstractSongPower power : powers) + if (this.powerEnabled(power.getCategory(), power)) + return true; + return false; } public boolean powerEnabled(PowerCategory category, AbstractSongPower power) {