Example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D

List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D.

Prototype

public Vector3D(double x, double y, double z) 

Source Link

Document

Simple constructor.

Usage

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
    Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z));
    MovingObjectPosition mop = player.rayTrace(10, 1);
    Block.LeftClickEvent evt = new Block.LeftClickEvent(Game.natives().toNova(player),
            Direction.fromOrdinal(mop.sideHit),
            new Vector3D(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord));
    blockInstance.events.publish(evt);//from  ww w  .  java  2s . co m
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
        float hitY, float hitZ) {
    Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z));
    Block.RightClickEvent evt = new Block.RightClickEvent(Game.natives().toNova(player),
            Direction.fromOrdinal(side), new Vector3D(hitX, hitY, hitZ));
    blockInstance.events.publish(evt);//from  w ww . j a  va2 s  .  co  m
    return evt.result;
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z));
    blockInstance.components.getOp(Collider.class).ifPresent(
            collider -> blockInstance.events.publish(new Collider.CollideEvent(Game.natives().toNova(entity))));
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public void setBlockBoundsBasedOnState(IBlockAccess access, int x, int y, int z) {
    Block blockInstance = getBlockInstance(access, new Vector3D(x, y, z));
    if (blockInstance.components.has(Collider.class)) {
        Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get();
        setBlockBounds((float) cuboid.min.getX(), (float) cuboid.min.getY(), (float) cuboid.min.getZ(),
                (float) cuboid.max.getX(), (float) cuboid.max.getY(), (float) cuboid.max.getZ());
    }/*from www  . jav a2s .  com*/
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
@SideOnly(Side.CLIENT)//w w w  . ja v a2  s  .c o m
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
    Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z));

    if (blockInstance.components.has(Collider.class)) {
        Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get();
        return Game.natives().toNative(cuboid.add(new Vector3D(x, y, z)));
    }
    return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list,
        Entity entity) {//w  ww .ja va 2s.com
    Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z));
    blockInstance.components.getOp(Collider.class).ifPresent(collider -> {
        Set<Cuboid> boxes = collider.occlusionBoxes
                .apply(Optional.ofNullable(entity != null ? Game.natives().toNova(entity) : null));

        list.addAll(boxes.stream().map(c -> c.add(new Vector3D(x, y, z)))
                .filter(c -> c.intersects((Cuboid) Game.natives().toNova(aabb)))
                .map(cuboid -> Game.natives().toNative(cuboid)).collect(Collectors.toList()));
    });
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public int getLightValue(IBlockAccess access, int x, int y, int z) {
    Block blockInstance = getBlockInstance(access, new Vector3D(x, y, z));
    Optional<LightEmitter> opEmitter = blockInstance.components.getOp(LightEmitter.class);

    if (opEmitter.isPresent()) {
        return Math.round(opEmitter.get().emittedLevel.get() * 15.0F);
    } else {/*from ww  w  . jav a 2 s .  c om*/
        return 0;
    }
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public boolean canConnectRedstone(IBlockAccess access, int x, int y, int z, int side) {
    Block blockInstance = getBlockInstance(access, new Vector3D(x, y, z));
    WrapperEvent.RedstoneConnect event = new WrapperEvent.RedstoneConnect(blockInstance.world(),
            blockInstance.position(), Direction.fromOrdinal(side));
    Game.events().publish(event);//from   w  ww.  j a va 2s  .co  m
    return event.canConnect;
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public int isProvidingWeakPower(IBlockAccess access, int x, int y, int z, int side) {
    Block blockInstance = getBlockInstance(access, new Vector3D(x, y, z));
    WrapperEvent.WeakRedstone event = new WrapperEvent.WeakRedstone(blockInstance.world(),
            blockInstance.position(), Direction.fromOrdinal(side));
    Game.events().publish(event);/*from   w w w.j av a  2s. c  o  m*/
    return event.power;
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

@Override
public int isProvidingStrongPower(IBlockAccess access, int x, int y, int z, int side) {
    Block blockInstance = getBlockInstance(access, new Vector3D(x, y, z));
    WrapperEvent.StrongRedstone event = new WrapperEvent.StrongRedstone(blockInstance.world(),
            blockInstance.position(), Direction.fromOrdinal(side));
    Game.events().publish(event);/*from  w w w.jav a  2  s .  c  o  m*/
    return event.power;
}