use of gregapi.block.misc.BlockBaseBars in project gregtech6 by GregTech6.
the class Behavior_Gun method trace.
public MovingObjectPosition trace(World aWorld, Vec3 aPosA, Vec3 aPosB, boolean aHitThings) {
if (Double.isNaN(aPosA.xCoord) || Double.isNaN(aPosA.yCoord) || Double.isNaN(aPosA.zCoord) || Double.isNaN(aPosB.xCoord) || Double.isNaN(aPosB.yCoord) || Double.isNaN(aPosB.zCoord))
return null;
int tCount = 1000, aAX = UT.Code.roundDown(aPosA.xCoord), aAY = UT.Code.roundDown(aPosA.yCoord), aAZ = UT.Code.roundDown(aPosA.zCoord), aBX = UT.Code.roundDown(aPosB.xCoord), aBY = UT.Code.roundDown(aPosB.yCoord), aBZ = UT.Code.roundDown(aPosB.zCoord);
byte tSide = SIDE_UNKNOWN;
while (tCount-- >= 0) {
Block aBlock = WD.block(aWorld, aAX, aAY, aAZ);
byte aMeta = WD.meta(aWorld, aAX, aAY, aAZ);
if (aBlock.getMaterial() == Material.water || aBlock.getMaterial() == Material.lava) {
return new MovingObjectPosition(aAX, aAY, aAZ, tSide, aPosA, T);
} else if (aBlock.getMaterial() == Material.glass || aBlock == Blocks.redstone_lamp || aBlock == Blocks.lit_redstone_lamp) {
if (aHitThings) {
OreDictItemData tData = OM.anydata(ST.make(aBlock, 1, aMeta));
for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) {
long tAmount = tMaterial.mAmount / OP.scrapGt.mAmount;
while (tAmount-- > 0) ST.drop(aWorld, aAX + 0.2 + RNGSUS.nextFloat() * 0.6, aAY + 0.1 + RNGSUS.nextFloat() * 0.5, aAZ + 0.2 + RNGSUS.nextFloat() * 0.6, OP.scrapGt.mat(tMaterial.mMaterial, 1));
}
}
} else if (aBlock == Blocks.fence || aBlock == Blocks.fence_gate || aBlock == Blocks.web || aBlock == Blocks.mob_spawner || aBlock instanceof BlockPane || aBlock instanceof BlockRail || aBlock instanceof BlockTorch || aBlock instanceof BlockBaseBars || aBlock instanceof BlockBaseSpike || aBlock.getMaterial() == Material.cactus || aBlock.getMaterial() == Material.fire || aBlock.getMaterial() == Material.air || aBlock.getMaterial() == Material.carpet || aBlock.getMaterial() == Material.cloth || aBlock.getMaterial() == Material.leaves || aBlock.getMaterial() == Material.plants || aBlock.getMaterial() == Material.vine) {
// Just ignore or assume the Player shot through them.
} else if (aBlock.canCollideCheck(aMeta, F)) {
MovingObjectPosition tPos = aBlock.collisionRayTrace(aWorld, aAX, aAY, aAZ, aPosA, aPosB);
if (tPos != null)
return tPos;
}
if (aAX == aBX && aAY == aBY && aAZ == aBZ)
return null;
if (Double.isNaN(aPosA.xCoord) || Double.isNaN(aPosA.yCoord) || Double.isNaN(aPosA.zCoord))
return null;
tSide = SIDE_UNKNOWN;
double tAX = aAX, tAY = aAY, tAZ = aAZ, tBX = aAX, tBY = aAY, tBZ = aAZ;
double tDiffX = aPosB.xCoord - aPosA.xCoord, tDiffY = aPosB.yCoord - aPosA.yCoord, tDiffZ = aPosB.zCoord - aPosA.zCoord;
if (aAX != aBX) {
if (aBX > aAX)
tAX++;
tBX = (tAX - aPosA.xCoord) / tDiffX;
}
if (aAY != aBY) {
if (aBY > aAY)
tAY++;
tBY = (tAY - aPosA.yCoord) / tDiffY;
}
if (aAZ != aBZ) {
if (aBZ > aAZ)
tAZ++;
tBZ = (tAZ - aPosA.zCoord) / tDiffZ;
}
if (tBX < tBY && tBX < tBZ) {
if (aBX > aAX)
tSide = SIDE_X_NEG;
else
tSide = SIDE_X_POS;
aPosA.xCoord = tAX;
aPosA.yCoord += tDiffY * tBX;
aPosA.zCoord += tDiffZ * tBX;
} else if (tBY < tBZ) {
if (aBY > aAY)
tSide = SIDE_Y_NEG;
else
tSide = SIDE_Y_POS;
aPosA.xCoord += tDiffX * tBY;
aPosA.yCoord = tAY;
aPosA.zCoord += tDiffZ * tBY;
} else {
if (aBZ > aAZ)
tSide = SIDE_Z_NEG;
else
tSide = SIDE_Z_POS;
aPosA.xCoord += tDiffX * tBZ;
aPosA.yCoord += tDiffY * tBZ;
aPosA.zCoord = tAZ;
}
aAX = UT.Code.roundDown(aPosA.xCoord);
if (tSide == SIDE_X_POS)
aAX--;
aAY = UT.Code.roundDown(aPosA.yCoord);
if (tSide == SIDE_Y_POS)
aAY--;
aAZ = UT.Code.roundDown(aPosA.zCoord);
if (tSide == SIDE_Z_POS)
aAZ--;
}
return null;
}
Aggregations