use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class ConduitGeometryUtil method preInit.
@SubscribeEvent
public static void preInit(EnderIOLifecycleEvent.Config.Post event) {
float size = (float) (0.075f + (0.175f * Config.conduitScale));
WIDTH = size;
HEIGHT = size;
HWIDTH = WIDTH / 2;
HHEIGHT = HEIGHT / 2;
final Vector3d core_min = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
CORE_MIN = core_min;
final Vector3d core_max = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
CORE_MAX = core_max;
CORE_BOUNDS = new BoundingBox(core_min, core_max);
float connectorWidth = (float) (0.25f + (Config.conduitScale * 0.5f));
for (EnumFacing dir : EnumFacing.VALUES) {
EXTERNAL_CONNECTOR_BOUNDS.put(dir, createExternalConnector(dir, CONNECTOR_DEPTH, connectorWidth));
}
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class ConduitGeometryUtil method createBoundsForConnectionController.
@Nonnull
public BoundingBox createBoundsForConnectionController(@Nonnull EnumFacing dir, @Nonnull Offset offset) {
Vector3d nonUniformScale = ForgeDirectionOffsets.forDirCopy(dir);
nonUniformScale.scale(0.5);
nonUniformScale.x = 0.8 * (1 - Math.abs(nonUniformScale.x));
nonUniformScale.y = 0.8 * (1 - Math.abs(nonUniformScale.y));
nonUniformScale.z = 0.8 * (1 - Math.abs(nonUniformScale.z));
BoundingBox bb = CORE_BOUNDS;
bb = bb.scale(nonUniformScale.x, nonUniformScale.y, nonUniformScale.z);
double offsetFromEnd = Math.min(bb.sizeX(), bb.sizeY());
offsetFromEnd = Math.min(offsetFromEnd, bb.sizeZ());
offsetFromEnd = Math.max(offsetFromEnd, 0.075);
double transMag = 0.5 - (offsetFromEnd * 1.2);
Vector3d trans = ForgeDirectionOffsets.forDirCopy(dir);
trans.scale(transMag);
bb = bb.translate(trans);
bb = bb.translate(getTranslation(dir, offset));
return bb;
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class TileElectricLight method updateLightNodes.
private void updateLightNodes() {
Set<BlockPos> before;
if (lightNodes != null && !lightNodes.isEmpty()) {
before = new HashSet<BlockPos>(lightNodes.size());
before.addAll(lightNodes);
} else {
before = Collections.emptySet();
}
Set<BlockPos> after = new HashSet<BlockPos>(17);
updatingLightNodes = true;
try {
if (lightNodes == null) {
// just created
lightNodes = new ArrayList<BlockPos>();
}
for (EnumFacing dir : EnumFacing.VALUES) {
if (dir != face && dir != face.getOpposite()) {
// skip the way we are facing
// us
Vector3d offset = ForgeDirectionOffsets.forDirCopy(dir);
addNodeInDirection(new Vector3d(offset), after);
addNodeInDirection(offset.add(ForgeDirectionOffsets.forDirCopy(face.getOpposite())), after);
}
}
// don't project behind, just in front
addNodeInDirection(ForgeDirectionOffsets.forDirCopy(face.getOpposite()), after);
Vector3d[] diags = new Vector3d[2];
if (face.getFrontOffsetX() != 0) {
diags[0] = ForgeDirectionOffsets.forDirCopy(EnumFacing.UP);
diags[1] = ForgeDirectionOffsets.forDirCopy(EnumFacing.SOUTH);
} else if (face.getFrontOffsetY() != 0) {
diags[0] = ForgeDirectionOffsets.forDirCopy(EnumFacing.EAST);
diags[1] = ForgeDirectionOffsets.forDirCopy(EnumFacing.SOUTH);
} else {
diags[0] = ForgeDirectionOffsets.forDirCopy(EnumFacing.UP);
diags[1] = ForgeDirectionOffsets.forDirCopy(EnumFacing.EAST);
}
addDiaganals(diags, new Vector3d(), after);
addDiaganals(diags, ForgeDirectionOffsets.forDirCopy(face.getOpposite()), after);
if (!before.equals(after)) {
lightNodes.clear();
for (BlockPos entry : after) {
if (!before.contains(entry) && entry != null) {
world.setBlockState(entry, block_light_node.getBlockNN().getDefaultState(), 3);
TileEntity te = world.getTileEntity(entry);
if (te instanceof TileLightNode) {
((TileLightNode) te).setParentPos(getPos());
lightNodes.add(entry);
}
} else {
lightNodes.add(entry);
}
}
for (BlockPos entry : before) {
if (!after.contains(entry) && entry != null) {
TileEntity te = world.getTileEntity(entry);
if ((te instanceof TileLightNode) && (((TileLightNode) te).getParentPos().equals(getPos()))) {
world.setBlockToAir(entry);
}
}
}
} else {
init = false;
}
} finally {
updatingLightNodes = false;
}
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class TileKillerJoe method getKillBounds.
@Nonnull
private BoundingBox getKillBounds() {
if (killBounds == NULL_AABB) {
double killerJoeAttackHeight = KillerJoeConfig.killerJoeAttackHeight.get();
double killerJoeAttackLength = KillerJoeConfig.killerJoeAttackLength.get();
double killerJoeAttackWidth = KillerJoeConfig.killerJoeAttackWidth.get();
BoundingBox bb = new BoundingBox(getLocation());
Vector3d min = bb.getMin();
Vector3d max = bb.getMax();
max.y += killerJoeAttackHeight;
min.y -= killerJoeAttackHeight;
EnumFacing facingDir = facing;
if (ForgeDirectionOffsets.isPositiveOffset(facingDir)) {
max.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeAttackLength));
min.add(ForgeDirectionOffsets.forDir(facingDir));
} else {
min.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeAttackLength));
max.add(ForgeDirectionOffsets.forDir(facingDir));
}
if (facingDir.getFrontOffsetX() == 0) {
min.x -= killerJoeAttackWidth;
max.x += killerJoeAttackWidth;
} else {
min.z -= killerJoeAttackWidth;
max.z += killerJoeAttackWidth;
}
killBounds = new BoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
return killBounds;
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class IoConfigRenderer method handleMouseInput.
public void handleMouseInput() {
if (Mouse.getEventButton() == 0) {
dragging = Mouse.getEventButtonState();
}
if (dragging) {
double dx = (Mouse.getEventDX() / (double) mc.displayWidth);
double dy = (Mouse.getEventDY() / (double) mc.displayHeight);
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
distance -= dy * 15;
} else {
yaw -= 4 * dx * 180;
pitch += 2 * dy * 180;
pitch = (float) VecmathUtil.clamp(pitch, -80, 80);
}
}
distance -= Mouse.getEventDWheel() * 0.01;
distance = VecmathUtil.clamp(distance, 0.01, 200);
long elapsed = System.currentTimeMillis() - initTime;
// Mouse Over
int x = Mouse.getEventX();
int y = Mouse.getEventY();
Vector3d start = new Vector3d();
Vector3d end = new Vector3d();
if (camera.getRayForPixel(x, y, start, end)) {
end.scale(distance * 2);
end.add(start);
updateSelection(start, end);
}
// Mouse pressed on configurable side
if (!Mouse.getEventButtonState() && camera.isValid() && elapsed > 500) {
if (Mouse.getEventButton() == 1) {
if (selection != null) {
selection.config.toggleIoModeForFace(selection.face);
PacketHandler.INSTANCE.sendToServer(new PacketIoMode(selection.config, selection.face));
}
} else if (Mouse.getEventButton() == 0 && inNeigButBounds) {
renderNeighbours = !renderNeighbours;
}
}
}
Aggregations