use of net.minecraft.util.shape.VoxelShape in project roadrunner by MaxNeedsSnacks.
the class SideShapeTypeCache method isSupporting.
public static boolean isSupporting(SideShapeType supportType, BlockState state, Direction direction) {
ThreadState threadState = threadLocalState.get();
VoxelShape shape = threadState.getShape(state);
ShapeResultCache specificCache = threadState.cachedResults.computeIfAbsent(shape, $ -> new ShapeResultCache());
return specificCache.getOrCompute(shape, direction, supportType);
}
use of net.minecraft.util.shape.VoxelShape in project roadrunner by MaxNeedsSnacks.
the class PistonBlockEntityMixin method skipVoxelShapeUnion.
/**
* Avoid calling {@link VoxelShapes#union(VoxelShape, VoxelShape)} whenever possible - use precomputed merged piston head + base shapes and
* cache the results for all union calls with an empty shape as first argument. (these are all other cases)
*/
@Inject(method = "getCollisionShape", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Direction;getOffsetX()I", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void skipVoxelShapeUnion(BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir, VoxelShape voxelShape2, Direction direction, BlockState blockState2, float f) {
if (this.extending || !this.source) {
// here voxelShape2.isEmpty() is guaranteed, vanilla code would call union() which calls simplify()
VoxelShape blockShape = blockState2.getCollisionShape(world, pos);
// we cache the simplified shapes, as the simplify() method costs a lot of CPU time and allocates several objects
VoxelShape offsetAndSimplified = getOffsetAndSimplified(blockShape, Math.abs(f), f < 0f ? this.facing.getOpposite() : this.facing);
cir.setReturnValue(offsetAndSimplified);
} else {
// retracting piston heads have to act like their base as well, as the base block is replaced with the moving block
// f >= 0f is guaranteed (assuming no other mod interferes)
int index = getIndexForMergedShape(f, this.facing);
cir.setReturnValue(PISTON_BASE_WITH_MOVING_HEAD_SHAPES[index]);
}
}
use of net.minecraft.util.shape.VoxelShape in project MCDoom by AzureDoom.
the class ArchvileEntity method conjureFangs.
private void conjureFangs(double x, double z, double maxY, double y, float yaw, int warmup) {
BlockPos blockPos = new BlockPos(x, y, z);
boolean bl = false;
double d = 0.0D;
do {
BlockPos blockPos2 = blockPos.down();
BlockState blockState = this.world.getBlockState(blockPos2);
if (blockState.isSideSolidFullSquare(this.world, blockPos2, Direction.UP)) {
if (!this.world.isAir(blockPos)) {
BlockState blockState2 = this.world.getBlockState(blockPos);
VoxelShape voxelShape = blockState2.getCollisionShape(this.world, blockPos);
if (!voxelShape.isEmpty()) {
d = voxelShape.getMax(Direction.Axis.Y);
}
}
bl = true;
break;
}
blockPos = blockPos.down();
} while (blockPos.getY() >= MathHelper.floor(maxY) - 1);
if (bl) {
DoomFireEntity fang = new DoomFireEntity(this.world, x, (double) blockPos.getY() + d, z, yaw, warmup, this, config.archvile_ranged_damage);
fang.setFireTicks(age);
fang.isInvisible();
this.world.spawnEntity(fang);
}
}
use of net.minecraft.util.shape.VoxelShape in project MCDoom by AzureDoom.
the class SummonerEntity method conjureFangs.
private void conjureFangs(double x, double z, double maxY, double y, float yaw, int warmup) {
BlockPos blockPos = new BlockPos(x, y, z);
boolean bl = false;
double d = 0.0D;
do {
BlockPos blockPos2 = blockPos.down();
BlockState blockState = this.world.getBlockState(blockPos2);
if (blockState.isSideSolidFullSquare(this.world, blockPos2, Direction.UP)) {
if (!this.world.isAir(blockPos)) {
BlockState blockState2 = this.world.getBlockState(blockPos);
VoxelShape voxelShape = blockState2.getCollisionShape(this.world, blockPos);
if (!voxelShape.isEmpty()) {
d = voxelShape.getMax(Direction.Axis.Y);
}
}
bl = true;
break;
}
blockPos = blockPos.down();
} while (blockPos.getY() >= MathHelper.floor(maxY) - 1);
if (bl) {
DoomFireEntity fang = new DoomFireEntity(this.world, x, (double) blockPos.getY() + d, z, yaw, warmup, this, config.summoner_ranged_damage);
fang.setFireTicks(age);
fang.isInvisible();
this.world.spawnEntity(fang);
}
}
use of net.minecraft.util.shape.VoxelShape in project MCDoom by AzureDoom.
the class IconofsinEntity method spawnFlames.
public void spawnFlames(double x, double z, double maxY, double y, float yaw, int warmup) {
BlockPos blockPos = new BlockPos(x, y, z);
boolean bl = false;
double d = -0.75D;
do {
BlockPos blockPos2 = blockPos.down();
BlockState blockState = this.world.getBlockState(blockPos2);
if (blockState.isSideSolidFullSquare(this.world, blockPos2, Direction.UP)) {
if (!this.world.isAir(blockPos)) {
BlockState blockState2 = this.world.getBlockState(blockPos);
VoxelShape voxelShape = blockState2.getCollisionShape(this.world, blockPos);
if (!voxelShape.isEmpty()) {
d = voxelShape.getMax(Direction.Axis.Y);
}
}
bl = true;
break;
}
blockPos = blockPos.down();
} while (blockPos.getY() >= MathHelper.floor(maxY) - 1);
if (bl) {
DoomFireEntity fang = new DoomFireEntity(this.world, x, (double) blockPos.getY() + d, z, yaw, warmup, this, config.icon_melee_damage);
fang.setFireTicks(age);
fang.isInvisible();
fang.age = -150;
this.world.spawnEntity(fang);
}
}
Aggregations