List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D
public Vector3D(double x, double y, double z)
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D round(Vector3D vec) { return new Vector3D(FastMath.round(vec.getX()), FastMath.round(vec.getY()), FastMath.round(vec.getZ())); }
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D ceil(Vector3D vec) { return new Vector3D(FastMath.ceil(vec.getX()), FastMath.ceil(vec.getY()), FastMath.ceil(vec.getZ())); }
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D floor(Vector3D vec) { return new Vector3D(FastMath.floor(vec.getX()), FastMath.floor(vec.getY()), FastMath.floor(vec.getZ())); }
From source file:nova.core.util.math.Vector3DUtil.java
public static Vector3D abs(Vector3D vec) { return new Vector3D(FastMath.abs(vec.getX()), FastMath.abs(vec.getY()), FastMath.abs(vec.getZ())); }
From source file:nova.core.wrapper.mc.forge.v17.asm.StaticForwarder.java
public static void chunkSetBlockEvent(Chunk chunk, int x, int y, int z, Block oldBlock, int oldMeta, Block newBlock, int newMeta) { // Publish the event Game.events()//from w w w . ja va 2 s. c om .publish(new BlockEvent.Change(Game.natives().toNova(chunk.worldObj), new Vector3D((chunk.xPosition << 4) + x, y, (chunk.zPosition << 4) + z), Game.natives().toNova(oldBlock), Game.natives().toNova(newBlock))); }
From source file:nova.core.wrapper.mc.forge.v17.launcher.ForgeEventHandler.java
@SubscribeEvent public void playerInteractEvent(PlayerInteractEvent event) { nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact( Game.natives().toNova(event.world), new Vector3D(event.x, event.y, event.z), Game.natives().toNova(event.entityPlayer), nova.core.event.PlayerEvent.Interact.Action.values()[event.action.ordinal()]); Game.events().publish(evt);/*from w w w . ja va 2 s . c o m*/ event.useBlock = Event.Result.values()[evt.useBlock.ordinal()]; event.useItem = Event.Result.values()[evt.useItem.ordinal()]; event.setCanceled(evt.isCanceled()); }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java
@Override public void onBlockHarvested(World world, int x, int y, int z, int meta, 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, x, y, z), getBlockInstance(world, new Vector3D(x, y, z))); }/*from w ww. ja v a2s . c om*/ }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java
@Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { Block blockInstance;//from ww w. j ava 2s . 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, x, y, z); if (harvestedBlocks.containsKey(position)) { blockInstance = harvestedBlocks.remove(position); } else { blockInstance = getBlockInstance(world, new Vector3D(x, y, z)); } 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.v17.wrapper.block.forward.FWBlock.java
@Override public void onNeighborBlockChange(World world, int x, int y, int z, net.minecraft.block.Block otherBlock) { Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z)); // Minecraft does not provide the neighbor :( Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent(Optional.empty()); blockInstance.events.publish(evt);/* ww w .j a va 2 s . c o m*/ }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java
@Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { Block blockInstance = getBlockInstance(world, new Vector3D(x, y, z)); Block.RemoveEvent evt = new Block.RemoveEvent(Optional.of(Game.natives().toNova(player))); blockInstance.events.publish(evt);/*from w w w.jav a 2s. c o m*/ if (evt.result) { return super.removedByPlayer(world, player, x, y, z, willHarvest); } return false; }