mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 16:09:05 +00:00
IBlock:
-Fixed canCollide function, added maxVolume parameter.
This commit is contained in:
1 parent
d54035687c
commit
1110748504
4 files changed
+23
-12
No files matched your search
@@ -10,6 +10,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -132,10 +133,18 @@ public class ScriptBlock implements IBlock {
|
||||
return NpcAPI.Instance().getINbt(compound);
|
||||
}
|
||||
|
||||
public boolean isCollidable() {
|
||||
boolean minBoundsZero = block.getBlockBoundsMinX() == 0 && block.getBlockBoundsMinY() == 0 && block.getBlockBoundsMinZ() == 0;
|
||||
boolean maxBoundsZero = block.getBlockBoundsMaxX() == 0 && block.getBlockBoundsMaxY() == 0 && block.getBlockBoundsMaxZ() == 0;
|
||||
public boolean canCollide(double maxVolume) {
|
||||
AxisAlignedBB alignedBB = block.getCollisionBoundingBoxFromPool(world.getMCWorld(),getX(),getY(),getZ());
|
||||
if (alignedBB == null) {
|
||||
return false;
|
||||
}
|
||||
double xEdge = alignedBB.maxX - alignedBB.minX;
|
||||
double yEdge = alignedBB.maxY - alignedBB.minY;
|
||||
double zEdge = alignedBB.maxZ - alignedBB.minZ;
|
||||
return Math.abs(xEdge * yEdge * zEdge) > maxVolume;
|
||||
}
|
||||
|
||||
return !(minBoundsZero && maxBoundsZero);
|
||||
public boolean canCollide() {
|
||||
return canCollide(0);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package noppes.npcs.scripted;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -21,12 +20,9 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
@@ -332,7 +328,7 @@ public class ScriptWorld implements IWorld {
|
||||
IBlock block = getBlock((int)currentPos.xCoord, (int)currentPos.yCoord, (int)currentPos.zCoord);
|
||||
if (block != null && stopOnBlock) {
|
||||
if ((!stopOnLiquid || block.getMCBlock() instanceof BlockLiquid)
|
||||
&& (!stopOnCollision || block.isCollidable()))
|
||||
&& (!stopOnCollision || block.canCollide()))
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptDamageSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
|
||||
protected T entity;
|
||||
@@ -152,7 +151,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
|
||||
if (block != null && stopOnBlock) {
|
||||
if ((!stopOnLiquid || block.getMCBlock() instanceof BlockLiquid)
|
||||
&& (!stopOnCollision || block.isCollidable()))
|
||||
&& (!stopOnCollision || block.canCollide()))
|
||||
return entities.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,5 +104,12 @@ public interface IBlock {
|
||||
*/
|
||||
INbt getTileEntityNBT();
|
||||
|
||||
boolean isCollidable();
|
||||
/**
|
||||
*
|
||||
* @param maxVolume The volume threshold to determine whether this block's bounding box collides, if it has one.
|
||||
* @return Whether this block can be collided with
|
||||
*/
|
||||
boolean canCollide(double maxVolume);
|
||||
|
||||
boolean canCollide();
|
||||
}
|
||||
Reference in new issue
Block a user