Skip to content

Commit

Permalink
Swap to using an MC utility function for full block detection
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jan 9, 2025
1 parent 7429399 commit 11dc4a3
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

public class PaperweightBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public PaperweightBlockMaterial(BlockState block) {
Expand All @@ -47,8 +43,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

public class PaperweightBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public PaperweightBlockMaterial(BlockState block) {
Expand All @@ -47,8 +43,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

public class PaperweightBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public PaperweightBlockMaterial(BlockState block) {
Expand All @@ -47,8 +43,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

public class PaperweightBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public PaperweightBlockMaterial(BlockState block) {
Expand All @@ -47,8 +43,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

public class PaperweightBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public PaperweightBlockMaterial(BlockState block) {
Expand All @@ -47,8 +43,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

public class PaperweightBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public PaperweightBlockMaterial(BlockState block) {
Expand All @@ -47,8 +43,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

/**
* Fabric block material that pulls as much info as possible from the Minecraft
Expand All @@ -37,8 +35,6 @@
*/
public class FabricBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public FabricBlockMaterial(BlockState block) {
Expand All @@ -52,8 +48,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

/**
* Forge block material that pulls as much info as possible from the Minecraft
Expand All @@ -37,8 +35,6 @@
*/
public class NeoForgeBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public NeoForgeBlockMaterial(BlockState block) {
Expand All @@ -52,8 +48,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Clearable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;

/**
* Sponge block material that pulls as much info as possible from the Minecraft
Expand All @@ -37,8 +35,6 @@
*/
public class SpongeBlockMaterial implements BlockMaterial {

private static final AABB FULL_CUBE = AABB.unitCubeFromLowerCorner(Vec3.ZERO);

private final BlockState block;

public SpongeBlockMaterial(BlockState block) {
Expand All @@ -52,8 +48,7 @@ public boolean isAir() {

@Override
public boolean isFullCube() {
VoxelShape vs = block.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
return !vs.isEmpty() && vs.bounds().equals(FULL_CUBE);
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
}

@Override
Expand Down

0 comments on commit 11dc4a3

Please sign in to comment.