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.v18.wrapper.block.forward.FWBlock.java

@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
    // HACK: called before block is destroyed by the player prior to the
    // player getting the drops. Determine drops here.
    // hack is needed because the player sets the block to air *before*
    // getting the drops. woo good logic from mojang.
    if (!player.capabilities.isCreativeMode) {
        harvestedBlocks.put(new BlockPosition(world, pos.getX(), pos.getY(), pos.getZ()),
                getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())));
    }//from   w w w  .  j ava 2 s  . c om
}

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

@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    Block blockInstance;/*w  w  w  .  j  av a  2 s .c  o m*/

    // see onBlockHarvested for why the harvestedBlocks hack exists
    // this method will be called exactly once after destroying the block
    BlockPosition position = new BlockPosition((World) world, pos.getX(), pos.getY(), pos.getZ());
    if (harvestedBlocks.containsKey(position)) {
        blockInstance = harvestedBlocks.remove(position);
    } else {
        blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    }

    Block.DropEvent event = new Block.DropEvent(blockInstance);
    blockInstance.events.publish(event);

    return new ArrayList<>(event.drops.stream().map(item -> (ItemStack) Game.natives().toNative(item))
            .collect(Collectors.toCollection(ArrayList::new)));
}

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

@Override
public TileEntity createTileEntity(World world, IBlockState state) {
    FWTile fwTile = FWTileLoader.loadTile(dummy.getID());
    if (lastExtendedStatePos != null) {
        fwTile.block.components.getOrAdd(new MCBlockTransform(dummy, Game.natives().toNova(world), new Vector3D(
                lastExtendedStatePos.getX(), lastExtendedStatePos.getY(), lastExtendedStatePos.getZ())));
        lastExtendedStatePos = null;/*from   w ww. j  a va2 s .  c o  m*/
    }
    return fwTile;
}

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

@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state,
        net.minecraft.block.Block neighborBlock) {
    Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    // Minecraft does not provide the neighbor :(
    Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent(Optional.empty());
    blockInstance.events.publish(evt);/*from w w  w. j a v a  2s  .  co  m*/
}

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

@Override
public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
    Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    Block.RemoveEvent evt = new Block.RemoveEvent(Optional.of(Game.natives().toNova(player)));
    blockInstance.events.publish(evt);//from  w  w w  . j  a  v  a2s. c  o  m
    if (evt.result) {
        return super.removedByPlayer(world, pos, player, willHarvest);
    }
    return false;
}

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

@Override
public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) {
    Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    MovingObjectPosition mop = player.rayTrace(10, 1);
    Block.LeftClickEvent evt = new Block.LeftClickEvent(Game.natives().toNova(player),
            Direction.fromOrdinal(mop.sideHit.ordinal()),
            new Vector3D(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord));
    blockInstance.events.publish(evt);/*from   w ww . ja  v  a 2s.c  o m*/
}

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

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player,
        EnumFacing side, float hitX, float hitY, float hitZ) {
    Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    Block.RightClickEvent evt = new Block.RightClickEvent(Game.natives().toNova(player),
            Direction.fromOrdinal(side.ordinal()), new Vector3D(hitX, hitY, hitZ));
    blockInstance.events.publish(evt);/*from  www  . j ava2  s.  c o m*/
    return evt.result;
}

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

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) {
    Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    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.v18.wrapper.block.forward.FWBlock.java

@Override
public void setBlockBoundsBasedOnState(IBlockAccess access, BlockPos pos) {
    Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));
    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  ww w  .  j a v  a2s .c  o m*/
}

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

@Override
public AxisAlignedBB getSelectedBoundingBox(World world, BlockPos pos) {
    Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()));

    if (blockInstance.components.has(Collider.class)) {
        Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get();
        return Game.natives().toNative(cuboid.add(new Vector3D(pos.getX(), pos.getY(), pos.getZ())));
    }/*from w w  w.j a v  a  2  s . c o m*/
    return super.getSelectedBoundingBox(world, pos);
}