Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
Revert "Retain BoundingBoxEvent instance"
Browse files Browse the repository at this point in the history
This reverts commit a973814
It was evidently problematic
  • Loading branch information
ZeroMemes committed Oct 15, 2018
1 parent b2dd72b commit e872b7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,23 @@
import java.util.List;

/**
* Called from {@link Block#addCollisionBoxToList(BlockPos, AxisAlignedBB, List, AxisAlignedBB)}.
* Called from Block#addCollisionBoxToList(BlockPos, AxisAlignedBB, List, AxisAlignedBB).
* Used to hook into block collision, used to modify the bounding boxes of blocks.
*
* @author Brady
* @since 4/10/2017
*/
public final class BoundingBoxEvent {

/**
* Singleton instance of this event
*/
private static final BoundingBoxEvent EVENT = new BoundingBoxEvent();

/**
* The block itself
*/
private Block block;
private final Block block;

/**
* The position of the block
*/
private BlockPos pos;
private final BlockPos pos;

/**
* The bounding box of the block
Expand All @@ -56,12 +51,20 @@ public final class BoundingBoxEvent {
/**
* Colliding list being added onto
*/
private List<AxisAlignedBB> collidingBoxes;
private final List<AxisAlignedBB> collidingBoxes;

/**
* Entity being checked, may be {@code null}
*/
private Entity entity;
private final Entity entity;

public BoundingBoxEvent(Block block, BlockPos pos, AxisAlignedBB aabb, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity) {
this.block = block;
this.pos = pos;
this.aabb = aabb;
this.collidingBoxes = collidingBoxes;
this.entity = entity;
}

/**
* Sets the block's bounding box. Setting it to
Expand Down Expand Up @@ -120,13 +123,4 @@ public String toString() {
", entity=" + entity +
'}';
}

public static BoundingBoxEvent get(Block block, BlockPos pos, AxisAlignedBB aabb, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity) {
EVENT.block = block;
EVENT.pos = pos;
EVENT.aabb = aabb;
EVENT.collidingBoxes = collidingBoxes;
EVENT.entity = entity;
return EVENT;
}
}
2 changes: 1 addition & 1 deletion src/main/java/clientapi/load/mixin/MixinBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void canCollideCheck(IBlockState state, boolean hitIfLiquid, CallbackInf
private void addCollisionBox(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean isActualState, CallbackInfo ci) {
synchronized (this) {
Block block = (Block) (Object) (this);
bbEvent = BoundingBoxEvent.get(block, pos, block.getCollisionBoundingBox(state, world, pos), collidingBoxes, entity);
bbEvent = new BoundingBoxEvent(block, pos, block.getCollisionBoundingBox(state, world, pos), collidingBoxes, entity);
ClientAPI.EVENT_BUS.post(bbEvent);
}
}
Expand Down

0 comments on commit e872b7d

Please sign in to comment.