Skip to content

Commit

Permalink
book fix and lich pass fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Sep 8, 2023
1 parent d67a12b commit f5693f2
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.19
# Mod Properties
mod_version=1.19.2-10
mod_version=1.19.2-11
maven_group=dev.mrsterner.besmirchment
archives_base_name=besmirchment
# Dependencies
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/dev/mrsterner/besmirchment/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
package dev.mrsterner.besmirchment.mixin;

import dev.mrsterner.besmirchment.common.entity.interfaces.TameableDemon;
import dev.mrsterner.besmirchment.common.registry.BSMTags;
import dev.mrsterner.besmirchment.common.registry.BSMTransformations;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.scoreboard.AbstractTeam;
import net.minecraft.util.function.BooleanBiFunction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.shape.VoxelShapes;
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Entity.class)
public class EntityMixin {

@Shadow
private EntityDimensions dimensions;

@Inject(method = "isInsideWall", at = @At("HEAD"), cancellable = true)
private void isLichInsideWall(CallbackInfoReturnable<Boolean> cir){
Entity entity = Entity.class.cast(this);
if (entity instanceof LivingEntity livingEntity) {
boolean bl = BSMTransformations.isLich(livingEntity, true);
boolean bl2 = getState(livingEntity, this.dimensions.width * 0.8F);
if (bl && bl2) {
cir.setReturnValue(false);
}
}
}

private boolean getState(LivingEntity livingEntity, float width){
Box box = Box.of(livingEntity.getEyePos(), width, 1.0E-6, width);

return BlockPos.stream(box).anyMatch((pos) -> {
BlockState blockState = livingEntity.getWorld().getBlockState(pos);
if (blockState.isIn(BSMTags.GHOST_IMPASSABLE)) {
return false;
}

return !blockState.isAir() &&
blockState.shouldSuffocate(livingEntity.getWorld(), pos) &&
VoxelShapes.matchesAnywhere(blockState.getCollisionShape(livingEntity.getWorld(), pos).offset(pos.getX(), pos.getY(), pos.getZ()), VoxelShapes.cuboid(box), BooleanBiFunction.AND) &&
blockState.isIn(BSMTags.GHOST_WHITELIST)
;
});
}

@Inject(method = "getScoreboardTeam", at = @At("HEAD"), cancellable = true)
public void getScoreboardTeam(CallbackInfoReturnable<AbstractTeam> cir) {
if (this instanceof TameableDemon && ((TameableDemon) this).isTamed()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Besmirchment",
"extend": "bewitchment:book_of_shadows"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"replace": false,
"values": [
"#dirt",
"#logs",
"#nylium",
"#planks",
"#stairs",
"#slabs",
"#terracotta",
"#walls",
"#wool",
"#snow",
"#ice",
"#base_stone_overworld",
"#base_stone_nether",
"#sand",
"gravel"
]
}

0 comments on commit f5693f2

Please sign in to comment.