-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2366dea
commit 6dd650c
Showing
5 changed files
with
101 additions
and
4 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
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
40 changes: 40 additions & 0 deletions
40
...main/java/net/frozenblock/trailiertales/mixin/common/apparition/BlockCollisionsMixin.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,40 @@ | ||
package net.frozenblock.trailiertales.mixin.common.apparition; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.frozenblock.trailiertales.block.EctoplasmBlock; | ||
import net.frozenblock.trailiertales.entity.Apparition; | ||
import net.minecraft.world.level.BlockCollisions; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.EntityCollisionContext; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(BlockCollisions.class) | ||
public class BlockCollisionsMixin { | ||
|
||
@Shadow | ||
@Final | ||
private CollisionContext context; | ||
|
||
@ModifyExpressionValue( | ||
method = "computeNext", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/BlockGetter;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;" | ||
) | ||
) | ||
public BlockState trailierTales$modifyBlockStateForApparitions(BlockState original) { | ||
if (this.context instanceof EntityCollisionContext entityCollisionContext) { | ||
if (entityCollisionContext.getEntity() instanceof Apparition) { | ||
return original.getBlock() instanceof EctoplasmBlock ? original : Blocks.AIR.defaultBlockState(); | ||
} | ||
} | ||
|
||
return original; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/net/frozenblock/trailiertales/mixin/common/apparition/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,29 @@ | ||
package net.frozenblock.trailiertales.mixin.common.apparition; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.frozenblock.trailiertales.entity.Apparition; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import java.util.List; | ||
|
||
@Mixin(Entity.class) | ||
public class EntityMixin { | ||
|
||
@ModifyExpressionValue( | ||
method = "collide", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/Level;getEntityCollisions(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;" | ||
) | ||
) | ||
private List<VoxelShape> trailierTales$noApparitionCollisions(List<VoxelShape> original) { | ||
if (Entity.class.cast(this) instanceof Apparition) { | ||
return List.of(); | ||
} | ||
|
||
return original; | ||
} | ||
|
||
} |
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