Skip to content

Commit

Permalink
Made Phantoms able to walk up stairs and not bug on paths while Phasing
Browse files Browse the repository at this point in the history
* Also made version include MC version
  • Loading branch information
apace100 committed Jun 25, 2020
1 parent bd1e589 commit 4ae9a6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
cca_version=2.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
}

0 comments on commit 4ae9a6d

Please sign in to comment.