Skip to content

Commit

Permalink
Removed usage of Vector3f, as its a client class and I really did not…
Browse files Browse the repository at this point in the history
… need it there
  • Loading branch information
KnightMiner committed Feb 6, 2016
1 parent fbb1ea2 commit 7ef3504
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.7.10-1.1"
version = "1.7.10-1.1.1"
group = "knightminer.knightperipherals" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "KnightPeripherals"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package knightminer.knightperipherals.turtles.peripherals.tasks;

import org.lwjgl.util.vector.Vector3f;

import dan200.computercraft.api.lua.ILuaTask;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.turtle.ITurtleAccess;
Expand Down Expand Up @@ -44,7 +42,7 @@ public Object[] execute()
// grab some additional data before we get started
Block block = world.getBlock(x, y, z);
int side = Facing.oppositeSide[direction];
Vector3f clickPoint = TurtleUtil.getCenterOfSide( side );
float[] clickPoint = TurtleUtil.getCenterOfSide(side);

// find the currently selected item/stack
IInventory inv = turtle.getInventory();
Expand All @@ -55,7 +53,7 @@ public Object[] execute()
Item item = stack == null ? null : stack.getItem();

// set up data for the fake player: itemstack and position
FakePlayer fakePlayer = FakePlayerProvider.get( turtle );
FakePlayer fakePlayer = FakePlayerProvider.get(turtle);
fakePlayer.setCurrentItemOrArmor(0, stack);
fakePlayer.setSneaking(sneaking);
TurtleUtil.setPlayerPosition(fakePlayer, turtle);
Expand All @@ -69,17 +67,17 @@ public Object[] execute()
// first try an item which is used before a block is activated
Boolean clicked = false;
if (item != null) {
clicked = item.onItemUseFirst(stack, fakePlayer, world, x, y, z, side, clickPoint.getX(), clickPoint.getY(), clickPoint.getZ());
clicked = item.onItemUseFirst(stack, fakePlayer, world, x, y, z, side, clickPoint[0], clickPoint[1], clickPoint[2]);
}

// next, try the block directly
if (!clicked)
{
clicked = block != null && block.onBlockActivated(world, x, y, z, fakePlayer, side, clickPoint.getX(), clickPoint.getY(), clickPoint.getZ());
clicked = block != null && block.onBlockActivated(world, x, y, z, fakePlayer, side, clickPoint[0], clickPoint[1], clickPoint[2]);
}
// if that did not work, try the item's main action
if (!clicked && (item != null)) {
clicked = item.onItemUse(stack, fakePlayer, world, x, y, z, side, clickPoint.getX(), clickPoint.getY(), clickPoint.getZ());
clicked = item.onItemUse(stack, fakePlayer, world, x, y, z, side, clickPoint[0], clickPoint[1], clickPoint[2]);
}

// we don't want ghost stacks
Expand Down
24 changes: 11 additions & 13 deletions src/main/java/knightminer/knightperipherals/util/TurtleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import org.lwjgl.util.vector.Vector3f;

import dan200.computercraft.api.turtle.ITurtleAccess;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
Expand Down Expand Up @@ -122,24 +120,24 @@ public static ArrayList<ItemStack> entityItemsToItemStack(ArrayList<EntityItem>

/**
* Finds the center to use for clicking a block
* Credit: Cypher121
* Credit: Cypher121, modified on 2/5/2016
* @param dir ForgeDirection which is being clicked from
* @return a Vector3f of the location
* @return a float array of the location
*/
public static Vector3f getCenterOfSide(ForgeDirection dir) {
public static float[] getCenterOfSide(ForgeDirection dir) {
switch (dir) {
case UP:
return new Vector3f(0.5f, 1f, 0.5f);
return new float[]{ 0.5f, 1f, 0.5f };
case DOWN:
return new Vector3f(0.5f, 0f, 0.5f);
return new float[]{ 0.5f, 0f, 0.5f};
case NORTH:
return new Vector3f(0.5f, 0.5f, 0f);
return new float[]{ 0.5f, 0.5f, 0f};
case SOUTH:
return new Vector3f(0.5f, 0.5f, 1f);
return new float[]{ 0.5f, 0.5f, 1f};
case WEST:
return new Vector3f(0f, 0.5f, 0.5f);
return new float[]{ 0f, 0.5f, 0.5f};
case EAST:
return new Vector3f(1f, 0.5f, 0.5f);
return new float[]{ 1f, 0.5f, 0.5f};
default:
return null;
}
Expand All @@ -149,9 +147,9 @@ public static Vector3f getCenterOfSide(ForgeDirection dir) {
* Finds the center to use for clicking a block
* Credit: Cypher121
* @param side integer representing the side which is being clicked from
* @return a Vector3f of the location
* @return a float array of the location
*/
public static Vector3f getCenterOfSide(int side) {
public static float[] getCenterOfSide(int side) {
return getCenterOfSide(ForgeDirection.getOrientation(side));
}

Expand Down

0 comments on commit 7ef3504

Please sign in to comment.