Skip to content

Commit a8b6be9

Browse files
committed
Add ShapeType parameter to BlockMaterial.isFullCube
1 parent 0db42f7 commit a8b6be9

16 files changed

Lines changed: 232 additions & 37 deletions

File tree

verification/src/changes/accepted-core-public-api-changes.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,14 @@
2323
"METHOD_REMOVED"
2424
]
2525
}
26+
],
27+
"Why on earth is this even an issue?": [
28+
{
29+
"type": "com.sk89q.worldedit.world.registry.BlockMaterial",
30+
"member": "Method com.sk89q.worldedit.world.registry.BlockMaterial.isFullCube()",
31+
"changes": [
32+
"METHOD_ABSTRACT_NOW_DEFAULT"
33+
]
34+
}
2635
]
2736
}

verification/src/changes/accepted-sponge-public-api-changes.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
"changes": [
77
"METHOD_REMOVED"
88
]
9+
},
10+
{
11+
"type": "com.sk89q.worldedit.sponge.SpongeBlockMaterial",
12+
"member": "Method com.sk89q.worldedit.sponge.SpongeBlockMaterial.isFullCube()",
13+
"changes": [
14+
"METHOD_REMOVED"
15+
]
916
}
1017
]
1118
}

worldedit-bukkit/adapters/adapter-1.21.11/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_11/PaperweightBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919

2020
package com.sk89q.worldedit.bukkit.adapter.impl.v1_21_11;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

31-
public class PaperweightBlockMaterial implements BlockMaterial {
34+
public class PaperweightBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3235

3336
private final BlockState block;
3437

@@ -42,8 +45,16 @@ public boolean isAir() {
4245
}
4346

4447
@Override
45-
public boolean isFullCube() {
46-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
48+
protected VoxelShape getShape(ShapeType shapeType) {
49+
return switch (shapeType) {
50+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
51+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
52+
};
53+
}
54+
55+
@Override
56+
protected boolean isShapeFullBlock(VoxelShape shape) {
57+
return Block.isShapeFullBlock(shape);
4758
}
4859

4960
@Override

worldedit-bukkit/adapters/adapter-1.21.4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_4/PaperweightBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919

2020
package com.sk89q.worldedit.bukkit.adapter.impl.v1_21_4;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

31-
public class PaperweightBlockMaterial implements BlockMaterial {
34+
public class PaperweightBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3235

3336
private final BlockState block;
3437

@@ -42,8 +45,16 @@ public boolean isAir() {
4245
}
4346

4447
@Override
45-
public boolean isFullCube() {
46-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
48+
protected VoxelShape getShape(ShapeType shapeType) {
49+
return switch (shapeType) {
50+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
51+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
52+
};
53+
}
54+
55+
@Override
56+
protected boolean isShapeFullBlock(VoxelShape shape) {
57+
return Block.isShapeFullBlock(shape);
4758
}
4859

4960
@Override

worldedit-bukkit/adapters/adapter-1.21.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_5/PaperweightBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919

2020
package com.sk89q.worldedit.bukkit.adapter.impl.v1_21_5;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

31-
public class PaperweightBlockMaterial implements BlockMaterial {
34+
public class PaperweightBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3235

3336
private final BlockState block;
3437

@@ -42,8 +45,16 @@ public boolean isAir() {
4245
}
4346

4447
@Override
45-
public boolean isFullCube() {
46-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
48+
protected VoxelShape getShape(ShapeType shapeType) {
49+
return switch (shapeType) {
50+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
51+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
52+
};
53+
}
54+
55+
@Override
56+
protected boolean isShapeFullBlock(VoxelShape shape) {
57+
return Block.isShapeFullBlock(shape);
4758
}
4859

4960
@Override

worldedit-bukkit/adapters/adapter-1.21.6/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_6/PaperweightBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919

2020
package com.sk89q.worldedit.bukkit.adapter.impl.v1_21_6;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

31-
public class PaperweightBlockMaterial implements BlockMaterial {
34+
public class PaperweightBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3235

3336
private final BlockState block;
3437

@@ -42,8 +45,16 @@ public boolean isAir() {
4245
}
4346

4447
@Override
45-
public boolean isFullCube() {
46-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
48+
protected VoxelShape getShape(ShapeType shapeType) {
49+
return switch (shapeType) {
50+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
51+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
52+
};
53+
}
54+
55+
@Override
56+
protected boolean isShapeFullBlock(VoxelShape shape) {
57+
return Block.isShapeFullBlock(shape);
4758
}
4859

4960
@Override

worldedit-bukkit/adapters/adapter-1.21.9/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_9/PaperweightBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919

2020
package com.sk89q.worldedit.bukkit.adapter.impl.v1_21_9;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

31-
public class PaperweightBlockMaterial implements BlockMaterial {
34+
public class PaperweightBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3235

3336
private final BlockState block;
3437

@@ -42,8 +45,16 @@ public boolean isAir() {
4245
}
4346

4447
@Override
45-
public boolean isFullCube() {
46-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
48+
protected VoxelShape getShape(ShapeType shapeType) {
49+
return switch (shapeType) {
50+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
51+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
52+
};
53+
}
54+
55+
@Override
56+
protected boolean isShapeFullBlock(VoxelShape shape) {
57+
return Block.isShapeFullBlock(shape);
4758
}
4859

4960
@Override

worldedit-bukkit/adapters/adapter-26.1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_1/PaperweightBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919

2020
package com.sk89q.worldedit.bukkit.adapter.impl.v26_1;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

31-
public class PaperweightBlockMaterial implements BlockMaterial {
34+
public class PaperweightBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3235

3336
private final BlockState block;
3437

@@ -42,8 +45,16 @@ public boolean isAir() {
4245
}
4346

4447
@Override
45-
public boolean isFullCube() {
46-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
48+
protected VoxelShape getShape(ShapeType shapeType) {
49+
return switch (shapeType) {
50+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
51+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
52+
};
53+
}
54+
55+
@Override
56+
protected boolean isShapeFullBlock(VoxelShape shape) {
57+
return Block.isShapeFullBlock(shape);
4758
}
4859

4960
@Override

worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcBlockMaterial.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@
1919

2020
package com.sk89q.worldedit.coremc.internal;
2121

22-
import com.sk89q.worldedit.world.registry.BlockMaterial;
22+
import com.sk89q.worldedit.blocks.ShapeType;
23+
import com.sk89q.worldedit.internal.block.AbstractBlockMaterial;
2324
import net.minecraft.core.BlockPos;
2425
import net.minecraft.world.Clearable;
2526
import net.minecraft.world.level.EmptyBlockGetter;
2627
import net.minecraft.world.level.block.Block;
2728
import net.minecraft.world.level.block.EntityBlock;
2829
import net.minecraft.world.level.block.state.BlockState;
2930
import net.minecraft.world.level.material.PushReaction;
31+
import net.minecraft.world.phys.shapes.CollisionContext;
32+
import net.minecraft.world.phys.shapes.VoxelShape;
3033

3134
/**
3235
* Minecraft block material implementation for platforms sharing native code.
3336
* Pulls as much info as possible from the Minecraft BlockState.
3437
*/
35-
public final class CoreMcBlockMaterial implements BlockMaterial {
38+
public final class CoreMcBlockMaterial extends AbstractBlockMaterial<VoxelShape> {
3639

3740
private final BlockState block;
3841

@@ -46,8 +49,16 @@ public boolean isAir() {
4649
}
4750

4851
@Override
49-
public boolean isFullCube() {
50-
return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO));
52+
protected VoxelShape getShape(ShapeType shapeType) {
53+
return switch (shapeType) {
54+
case SHAPE -> block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
55+
case VISUAL_SHAPE -> block.getVisualShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty());
56+
};
57+
}
58+
59+
@Override
60+
protected boolean isShapeFullBlock(VoxelShape shape) {
61+
return Block.isShapeFullBlock(shape);
5162
}
5263

5364
@Override
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.worldedit.blocks;
21+
22+
public enum ShapeType {
23+
SHAPE,
24+
VISUAL_SHAPE,
25+
}

0 commit comments

Comments
 (0)