2525import java .util .List ;
2626
2727/**
28- * Called from Block#addCollisionBoxToList(BlockPos, AxisAlignedBB, List, AxisAlignedBB).
28+ * Called from {@link Block#addCollisionBoxToList(BlockPos, AxisAlignedBB, List, AxisAlignedBB)} .
2929 * Used to hook into block collision, used to modify the bounding boxes of blocks.
3030 *
3131 * @author Brady
3232 * @since 4/10/2017
3333 */
3434public final class BoundingBoxEvent {
3535
36+ /**
37+ * Singleton instance of this event
38+ */
39+ private static final BoundingBoxEvent EVENT = new BoundingBoxEvent ();
40+
3641 /**
3742 * The block itself
3843 */
39- private final Block block ;
44+ private Block block ;
4045
4146 /**
4247 * The position of the block
4348 */
44- private final BlockPos pos ;
49+ private BlockPos pos ;
4550
4651 /**
4752 * The bounding box of the block
@@ -51,20 +56,12 @@ public final class BoundingBoxEvent {
5156 /**
5257 * Colliding list being added onto
5358 */
54- private final List <AxisAlignedBB > collidingBoxes ;
59+ private List <AxisAlignedBB > collidingBoxes ;
5560
5661 /**
5762 * Entity being checked, may be {@code null}
5863 */
59- private final Entity entity ;
60-
61- public BoundingBoxEvent (Block block , BlockPos pos , AxisAlignedBB aabb , List <AxisAlignedBB > collidingBoxes , @ Nullable Entity entity ) {
62- this .block = block ;
63- this .pos = pos ;
64- this .aabb = aabb ;
65- this .collidingBoxes = collidingBoxes ;
66- this .entity = entity ;
67- }
64+ private Entity entity ;
6865
6966 /**
7067 * Sets the block's bounding box. Setting it to
@@ -123,4 +120,13 @@ public String toString() {
123120 ", entity=" + entity +
124121 '}' ;
125122 }
123+
124+ public static BoundingBoxEvent get (Block block , BlockPos pos , AxisAlignedBB aabb , List <AxisAlignedBB > collidingBoxes , @ Nullable Entity entity ) {
125+ EVENT .block = block ;
126+ EVENT .pos = pos ;
127+ EVENT .aabb = aabb ;
128+ EVENT .collidingBoxes = collidingBoxes ;
129+ EVENT .entity = entity ;
130+ return EVENT ;
131+ }
126132}
0 commit comments