Skip to content

Commit

Permalink
Fix EntityBlock placement
Browse files Browse the repository at this point in the history
  • Loading branch information
boq committed Aug 26, 2018
1 parent 777ea74 commit a8c86f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/openmods/entity/EntityBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class EntityBlock extends Entity implements IEntityAdditionalSpawnData {
private static final String TAG_BLOCK_META = "BlockMeta";
private static final String TAG_BLOCK_ID = "BlockId";

public static final EnumFacing[] PLACE_DIRECTIONS = { EnumFacing.UP, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST, EnumFacing.DOWN };
public static final EnumFacing[] PLACE_DIRECTIONS = { EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST, EnumFacing.DOWN, EnumFacing.UP };
private static final String TAG_BLOCK_STATE_ID = "BlockState";

private boolean hasGravity = false;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void onUpdate() {
// setHeight((float)block.getBlockBoundsMaxY());

if (world instanceof WorldServer && shouldPlaceBlock()) {
final BlockPos dropPos = new BlockPos(posX, posY, posZ);
final BlockPos dropPos = new BlockPos(getEntityBoundingBox().getCenter());
if (!tryPlaceBlock((WorldServer)world, dropPos)) dropBlock();

setDead();
Expand All @@ -191,10 +191,10 @@ protected boolean shouldPlaceBlock() {

private boolean tryPlaceBlock(final WorldServer world, final BlockPos pos) {
return FakePlayerPool.instance.executeOnPlayer(world, (PlayerUserReturning<Boolean>)fakePlayer -> {
if (tryPlaceBlock(fakePlayer, world, pos, EnumFacing.DOWN)) return true;
if (tryPlaceBlock(fakePlayer, world, pos, EnumFacing.UP)) return true;

for (EnumFacing dir : PLACE_DIRECTIONS) {
if (tryPlaceBlock(fakePlayer, world, pos, dir)) return true;
if (tryPlaceBlock(fakePlayer, world, pos.offset(dir), dir)) return true;
}
return false;
});
Expand Down

0 comments on commit a8c86f6

Please sign in to comment.