Stop placing blocks in entities.

This commit is contained in:
James McKay committed 2015-10-07 22:20:04 +11:00
1 parent 8bfddeda62
commit 1b463ec79c
3 files changed
+16

No files matched your search

@@ -3,6 +3,7 @@ package portablejim.bbw.core;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import portablejim.bbw.IWand;
import portablejim.bbw.basics.Point3d;
@@ -50,9 +51,11 @@ public class WandWorker {
Point3d supportingPoint = currentCandidate.move(placeDirection.getOpposite());
Block candidateSupportingBlock = world.getBlock(supportingPoint);
int candidateSupportingMeta = world.getMetadata(supportingPoint);
AxisAlignedBB blockBB = AxisAlignedBB.getBoundingBox((double)currentCandidate.x, (double)currentCandidate.y, currentCandidate.z, currentCandidate.x + 1, currentCandidate.y + 1, currentCandidate.z + 1);
if(world.blockIsAir(currentCandidate)
&& targetBlock.equals(candidateSupportingBlock)
&& targetMetadata == candidateSupportingMeta
&& !world.entitiesInBox(blockBB)
&& allCandidates.add(currentCandidate)) {
toPlace.add(currentCandidate);
switch (placeDirection) {
@@ -1,10 +1,14 @@
package portablejim.bbw.shims;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import portablejim.bbw.basics.Point3d;
import java.util.List;
/**
* Wrap a world to provide basic functions.
*/
@@ -54,4 +58,10 @@ public class BasicWorldShim implements IWorldShim {
}
return 0;
}
@Override
public boolean entitiesInBox(AxisAlignedBB box) {
List entitiesWithinAABB = world.getEntitiesWithinAABB(EntityLivingBase.class, box);
return entitiesWithinAABB.size() > 0;
}
}
@@ -1,6 +1,7 @@
package portablejim.bbw.shims;
import net.minecraft.block.Block;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import portablejim.bbw.basics.Point3d;
@@ -18,4 +19,6 @@ public interface IWorldShim {
void setBlockToAir(Point3d blockPos);
int getMetadata(Point3d blockPos);
boolean entitiesInBox(AxisAlignedBB box);
}