From 4ae9a6d30633fc215e21f925f80860949dece196 Mon Sep 17 00:00:00 2001 From: Apace Date: Thu, 25 Jun 2020 18:00:46 +0200 Subject: [PATCH] Made Phantoms able to walk up stairs and not bug on paths while Phasing * Also made version include MC version --- gradle.properties | 4 ++-- .../mixin/AbstractBlockStateMixin.java | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index dc9fd5c8..20da9723 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,11 +8,11 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.8.8+build.202 # Mod Properties - mod_version = 0.1.1 + mod_version = 1.16-0.1.1 maven_group = io.github.apace100.origins archives_base_name = Origins # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api fabric_version=0.13.1+build.370-1.16 - cca_version=2.4.0-nightly.1.16-rc1.build.2 \ No newline at end of file + cca_version=2.4.0 \ No newline at end of file diff --git a/src/main/java/io/github/apace100/origins/mixin/AbstractBlockStateMixin.java b/src/main/java/io/github/apace100/origins/mixin/AbstractBlockStateMixin.java index b0d1058e..760de5bb 100644 --- a/src/main/java/io/github/apace100/origins/mixin/AbstractBlockStateMixin.java +++ b/src/main/java/io/github/apace100/origins/mixin/AbstractBlockStateMixin.java @@ -6,15 +6,18 @@ import net.minecraft.block.*; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +@SuppressWarnings("deprecation") @Mixin(AbstractBlock.AbstractBlockState.class) public abstract class AbstractBlockStateMixin { @@ -30,14 +33,19 @@ private void phaseThroughBlocks(BlockView world, BlockPos pos, ShapeContext cont VoxelShape blockShape = getBlock().getCollisionShape(asBlockState(), world, pos, context); if(!blockShape.isEmpty() && context instanceof EntityShapeContext && !getBlock().isIn(ModTags.UNPHASABLE)) { EntityShapeContext entityContext = (EntityShapeContext)context; - if(!entityContext.isAbove(blockShape, pos, false) || entityContext.isDescending()) { - Entity entity = ((EntityShapeContextAccess)context).getEntity(); - if(PowerTypes.PHASING.isActive(entity) && PowerTypes.PHASING.get(entity).isActive()) { - info.setReturnValue(VoxelShapes.empty()); + Entity entity = ((EntityShapeContextAccess)context).getEntity(); + if(entity != null) { + if(!isAbove(entity, blockShape, pos, false) || entityContext.isDescending()) { + if(PowerTypes.PHASING.isActive(entity) && PowerTypes.PHASING.get(entity).isActive()) { + info.setReturnValue(VoxelShapes.empty()); + } } - } - } } + + @Unique + private boolean isAbove(Entity entity, VoxelShape shape, BlockPos pos, boolean defaultValue) { + return entity.getY() > (double)pos.getY() + shape.getMax(Direction.Axis.Y) - (entity.isOnGround() ? 8.05/16.0 : 0.0015); + } }