1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-19 11:39:50 +01:00

General cleanup (deprecated+whitespace)

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot 2011-02-02 00:02:08 +01:00
parent b01fc3ffa8
commit 474817bf11
27 changed files with 224 additions and 244 deletions

View file

@ -31,7 +31,7 @@ public interface Chunk {
/**
* Gets a block from this chunk
*
*
* @param x 0-15
* @param y 0-127
* @param z 0-15

View file

@ -62,11 +62,11 @@ public class Location implements Cloneable {
public double getX() {
return x;
}
/**
* Gets the floored value of the X component, indicating the block that
* this location is contained with.
*
*
* @return block X
*/
public int getBlockX() {
@ -94,7 +94,7 @@ public class Location implements Cloneable {
/**
* Gets the floored value of the Y component, indicating the block that
* this location is contained with.
*
*
* @return block y
*/
public int getBlockY() {
@ -122,7 +122,7 @@ public class Location implements Cloneable {
/**
* Gets the floored value of the Z component, indicating the block that
* this location is contained with.
*
*
* @return block z
*/
public int getBlockZ() {
@ -211,7 +211,7 @@ public class Location implements Cloneable {
public String toString() {
return "Location{" + "world=" + world + "x=" + x + "y=" + y + "z=" + z + "pitch=" + pitch + "yaw=" + yaw + '}';
}
public Vector toVector() {
return new Vector(x, y, z);
}

View file

@ -306,7 +306,7 @@ public enum Material {
* @return true if this material is a block
*/
public boolean isBlock() {
return id < 256;
return id < 256;
}
/**
@ -355,7 +355,7 @@ public enum Material {
return result;
}
static {
for (Material material : values()) {
lookupId.put(material.getId(), material);

View file

@ -30,10 +30,10 @@ public interface Server {
* @return An array of Players that are currently online
*/
public Player[] getOnlinePlayers();
/**
* Broadcast a message to all players.
*
*
* @param message the message
* @return the number of players
*/
@ -75,24 +75,6 @@ public interface Server {
*/
public World[] getWorlds();
/**
* Gets the in-game time on the server (in hours*1000)
*
* @return The current time in hours*1000
* @deprecated Use World.getTime
*/
@Deprecated
public long getTime();
/**
* Sets the in-game time on the server (in hours*1000)
*
* @param time The time to set the in-game time to (in hours*1000)
* @deprecated Use World.setTime
*/
@Deprecated
public void setTime(long time);
/**
* Reloads the server, refreshing settings and plugin information
*/

View file

@ -100,57 +100,55 @@ public interface World {
/**
* Drop an item exactly at the specified location.
*
*
* @param loc
* @param item
* @return dropped item entity
*/
public ItemDrop dropItem(Location loc, ItemStack item);
/**
* Drop an item as if it was mined (randomly placed).
*
*
* @param loc
* @param item
* @return dropped item entity
*/
public ItemDrop dropItemNaturally(Location loc, ItemStack item);
/**
* Spawns an arrow.
*
*
* @param loc
* @param velocity velocity vector
* @param speed a reasonable speed is 0.6
* @param spread a reasonable spread is 12
* @return the arrow entity
*/
public Arrow spawnArrow(Location loc, Vector velocity,
float speed, float spread);
public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread);
/**
* Spawns a tree at a location.
*
*
* @param loc
* @param type
* @return whether the tree was created
*/
public boolean generateTree(Location loc, TreeType type);
/**
* Spawns a tree at a location.
*
*
* @param loc
* @param type
* @param delegate
* @return whether the tree was created
*/
public boolean generateTree(Location loc, TreeType type,
BlockChangeDelegate delegate);
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
/**
* Spawns a regular passenger minecart.
*
*
* @param loc
* @return
*/
@ -158,7 +156,7 @@ public interface World {
/**
* Spawns a storage minecart.
*
*
* @param loc
* @return
*/
@ -166,30 +164,30 @@ public interface World {
/**
* Spawns a powered minecart.
*
*
* @param loc
* @return
*/
public PoweredMinecart spawnPoweredMinecart(Location loc);
/**
* Spawn a boat.
*
*
* @param loc
* @return
*/
public Boat spawnBoat(Location loc);
/**
* Get a list of all entities.
*
*
* @return
*/
public List<Entity> getEntities();
/**
* Get a list of all living entities.
*
*
* @return
*/
public List<LivingEntity> getLivingEntities();
@ -209,7 +207,7 @@ public interface World {
* @return Id of this world
*/
public long getId();
/**
* Gets the default spawn location.
*/

View file

@ -79,10 +79,10 @@ public interface Block {
* @return block type-id
*/
int getTypeId();
/**
* Gets the light level between 0-15
*
*
* @return light level
*/
byte getLightLevel();
@ -187,17 +187,17 @@ public interface Block {
* @return Biome type containing this block
*/
Biome getBiome();
/**
* Returns true if the block is being powered by Redstone.
*
*
* @return
*/
boolean isBlockPowered();
/**
* Returns true if the block is being indirectly powered by Redstone.
*
*
* @return
*/
boolean isBlockIndirectlyPowered();

View file

@ -17,7 +17,7 @@ import org.bukkit.material.MaterialData;
public interface BlockState {
/**
* Gets the block represented by this BlockState
*
*
* @return Block that this BlockState represents
*/
Block getBlock();

View file

@ -8,40 +8,40 @@ import java.util.Map.Entry;
import org.bukkit.plugin.Plugin;
public class PluginCommandYamlParser {
public static List<Command> parse(Plugin plugin) {
List<Command> pluginCmds = new ArrayList<Command>();
Object object = plugin.getDescription().getCommands();
if (object == null)
return pluginCmds;
return pluginCmds;
@SuppressWarnings("unchecked")
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>)object;
if (map != null) {
for(Entry<String, Map<String, Object>> entry : map.entrySet()) {
Command newCmd = new PluginCommand(entry.getKey(),plugin);
Command newCmd = new PluginCommand(entry.getKey(),plugin);
Object description = entry.getValue().get("description");
Object usage = entry.getValue().get("usage");
Object aliases = entry.getValue().get("aliases");
if (description != null)
newCmd.setTooltip(description.toString());
if (usage != null) {
newCmd.setUsage(usage.toString());
}
if (aliases != null) {
List<String> aliasList = new ArrayList<String>();
for(String a : aliases.toString().split(",")) {
aliasList.add(a);
}
newCmd.setAliases(aliasList);
}
pluginCmds.add(newCmd);
}
}

View file

@ -38,7 +38,7 @@ public interface Entity {
/**
* Returns a unique id for this entity
*
*
* @return Entity id
*/
public int getEntityId();

View file

@ -24,7 +24,7 @@ public interface HumanEntity extends LivingEntity {
/**
* Returns the ItemStack currently in your hand, can be empty.
*
*
* @return The ItemStack of the item you are currently holding.
*/
public ItemStack getItemInHand();
@ -32,17 +32,17 @@ public interface HumanEntity extends LivingEntity {
/**
* Sets the item to the given ItemStack, this will replace whatever the
* user was holding.
*
*
* @param item The ItemStack which will end up in the hand
* @return
* @return
*/
public void setItemInHand(ItemStack item);
/**
* Changes the item in hand to another of your 'action slots'.
*
*
* @param index The new index to use, only valid ones are 0-8.
*
*
public void selectItemInHand( int index );
*/
}

View file

@ -18,44 +18,44 @@ public interface LivingEntity extends Entity {
* @param health New health represented from 0-20
*/
public void setHealth(int health);
/**
* Throws an egg from the entity.
*/
public Egg throwEgg();
/**
* Throws a snowball from the entity.
*/
public Snowball throwSnowball();
/**
* Shoots an arrow from the entity.
*
*
* @return
*/
public Arrow shootArrow();
/**
* Returns whether this entity is inside a vehicle.
*
*
* @return
*/
public boolean isInsideVehicle();
/**
* Leave the current vehicle. If the entity is currently in a vehicle
* (and is removed from it), true will be returned, otherwise false will
* be returned.
*
*
* @return
*/
public boolean leaveVehicle();
/**
* Get the vehicle that this player is inside. If there is no vehicle,
* null will be returned.
*
*
* @return
*/
public Vehicle getVehicle();

View file

@ -18,7 +18,7 @@ public enum MobType {
SQUID("Squid");
private String name;
private static final Map<String, MobType> mapping
= new HashMap<String, MobType>();
@ -35,7 +35,7 @@ public enum MobType {
public String getName() {
return name;
}
public static MobType fromName(String name) {
return mapping.get(name);
}

View file

@ -1,5 +1,5 @@
/**
*
*
*/
package org.bukkit.event.block;
@ -22,7 +22,7 @@ public class BlockCanBuildEvent extends BlockEvent {
/**
* Returns whether or not the block can be built here. By default, returns
* Minecraft's answer on whether the block can be built
*
*
* @return boolean whether or not the block can be built
*/
public boolean isBuildable() {

View file

@ -22,7 +22,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
/**
* Returns the player doing the damage
*
*
* @return
*/
public Player getPlayer() {
@ -31,7 +31,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
/**
* Returns the level of damage to the block
*
*
* @return
*/
public BlockDamageLevel getDamageLevel() {

View file

@ -6,7 +6,7 @@ import org.bukkit.event.Event;
/**
* Thrown when a block physics check is called
*
*
* @author Dinnerbone
*/
public class BlockPhysicsEvent extends BlockEvent {

View file

@ -55,39 +55,39 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
public Player getPlayer() {
return player;
}
/**
* Clarity method for getting the placed block. Not really needed
* except for reasons of clarity
*
*
* @return Block the block that was placed
*/
public Block getBlockPlaced() {
return getBlock();
}
/**
* Returns the state of the block which was replaced. Material type air mostly.
*
* Returns the state of the block which was replaced. Material type air mostly.
*
* @return BlockState of block which was replaced.
*/
public BlockState getBlockReplacedState() {
return this.replacedBlockState;
}
/**
* Get the block that this block was placed against
*
*
* @return Block the block that the new block was placed against
*/
public Block getBlockAgainst() {
return placedAgainst;
}
/**
* Returns the item in your hand when you placed the block
*
*
* @return ItemStack the item in your hand when placing the block
*/
public ItemStack getItemInHand() {
@ -100,16 +100,16 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
* player is in Spawn). Note that this is an entirely different check
* than BLOCK_CANBUILD, as this refers to a player, not universe-physics
* rule like cactus on dirt.
*
*
* @return boolean whether the server would allow a player to build here
*/
public boolean canBuild() {
return this.canBuild;
}
/**
* Sets the canBuild state of this event. Set to true if you want the
* player to be able to build.
* player to be able to build.
*/
public void setBuild(boolean canBuild) {
this.canBuild = canBuild;

View file

@ -15,7 +15,7 @@ import org.bukkit.block.BlockFace;
public class BlockRedstoneEvent extends BlockFromToEvent {
private int oldCurrent;
private int newCurrent;
public BlockRedstoneEvent(Block block, BlockFace face, int oldCurrent, int newCurrent) {
super(Type.REDSTONE_CHANGE, block, face);
this.oldCurrent = oldCurrent;

View file

@ -30,17 +30,17 @@ public class BlockRightClickEvent extends BlockEvent {
public Player getPlayer() {
return player;
}
/**
* Get the block that this block was placed against
*
*
* @return Block the block that the new block was placed against
*/
public Block getBlockAgainst() {
return clickedBlock;
}
/**
* @return BlockFace the direction this block was clicked
*/
@ -50,7 +50,7 @@ public class BlockRightClickEvent extends BlockEvent {
/**
* Returns the item in your hand when you placed the block
*
*
* @return ItemStack the item in your hand when placing the block
*/
public ItemStack getItemInHand() {

View file

@ -16,7 +16,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent implements Canc
super(Event.Type.ENTITY_DAMAGEDBY_ENTITY, damagee, cause, damage);
this.damager = damager;
}
protected EntityDamageByEntityEvent(Type damageType, Entity damager, Entity damagee, DamageCause cause, int damage)
{
super(damageType, damagee, cause, damage);

View file

@ -6,30 +6,30 @@ import org.bukkit.entity.Player;
* Represents a player animation event
*/
public class PlayerAnimationEvent extends PlayerEvent {
private PlayerAnimationType animationType;
/*
* Construct a new event
*
*
* @param type The event type
* @param player The player instance
*/
public PlayerAnimationEvent(final Type type, final Player player) {
super(type, player);
// Only supported animation type for now:
animationType = PlayerAnimationType.ARM_SWING;
}
/*
* Get the type of this animation event
*
*
* @returns the animation type
*/
public PlayerAnimationType getAnimationType()
{
return animationType;
}
}

View file

@ -26,7 +26,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
/**
* Get the egg.
*
*
* @return the egg
*/
public Egg getEgg() {

View file

@ -57,10 +57,10 @@ public class PlayerListener implements Listener {
*/
public void onPlayerTeleport(PlayerMoveEvent event) {
}
/**
* Called when a player uses an item
*
*
* @param event Relevant event details
*/
public void onPlayerItem(PlayerItemEvent event) {
@ -81,10 +81,10 @@ public class PlayerListener implements Listener {
*/
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
}
/**
* Called when a player plays an animation, such as an arm swing
*
*
* @param event Relevant event details
*/
public void onPlayerAnimation(PlayerAnimationEvent event) {

View file

@ -9,21 +9,21 @@ import org.bukkit.Material;
public interface Inventory {
/**
* Returns the size of the inventory
*
*
* @return The inventory size
*/
public int getSize();
/**
* Return the name of the inventory
*
*
* @return The inventory name
*/
public String getName();
/**
* Get the ItemStack found in the slot at the given index
*
*
* @param index The index of the Slot's ItemStack to return
* @return The ItemStack in the slot
*/
@ -31,7 +31,7 @@ public interface Inventory {
/**
* Stores the ItemStack at the given index
*
*
* @param index The index where to put the ItemStack
* @param item The ItemStack to set
*/
@ -39,60 +39,60 @@ public interface Inventory {
/**
* Stores the given ItemStacks in the inventory.
*
*
* This will try to fill existing stacks and empty slots as good as it can.
* It will return a HashMap of what it couldn't fit.
*
*
* @param items The ItemStacks to add
* @return
* @return
*/
public HashMap<Integer, ItemStack> addItem(ItemStack... items);
/**
* Removes the given ItemStacks from the inventory.
*
*
* It will try to remove 'as much as possible' from the types and amounts you
* give as arguments. It will return a HashMap of what it couldn't remove.
*
*
* @param items The ItemStacks to remove
* @return
* @return
*/
public HashMap<Integer, ItemStack> removeItem(ItemStack... items);
/**
* Get all ItemStacks from the inventory
*
*
* @return All the ItemStacks from all slots
*/
public ItemStack[] getContents();
/**
* Set the inventory's contents
*
*
* @return All the ItemStacks from all slots
*/
public void setContents(ItemStack[] items);
/**
* Check if the inventory contains any ItemStacks with the given materialId
*
*
* @param materialId The materialId to check for
* @return If any ItemStacks were found
*/
public boolean contains(int materialId);
public boolean contains(int materialId);
/**
* Check if the inventory contains any ItemStacks with the given material
*
*
* @param material The material to check for
* @return If any ItemStacks were found
*/
public boolean contains(Material material);
public boolean contains(Material material);
/**
* Check if the inventory contains any ItemStacks matching the given ItemStack
* This will only match if both the type and the amount of the stack match
*
*
* @param item The ItemStack to match against
* @return If any matching ItemStacks were found
*/
@ -100,24 +100,24 @@ public interface Inventory {
/**
* Find all slots in the inventory containing any ItemStacks with the given materialId
*
*
* @param materialId The materialId to look for
* @return The Slots found.
*/
public HashMap<Integer, ? extends ItemStack> all(int materialId);
public HashMap<Integer, ? extends ItemStack> all(int materialId);
/**
* Find all slots in the inventory containing any ItemStacks with the given material
*
*
* @param materialId The material to look for
* @return The Slots found.
*/
public HashMap<Integer, ? extends ItemStack> all(Material material);
public HashMap<Integer, ? extends ItemStack> all(Material material);
/**
* Find all slots in the inventory containing any ItemStacks with the given ItemStack
* This will only match slots if both the type and the amount of the stack match
*
*
* @param item The ItemStack to match against
* @return The Slots found.
*/
@ -125,7 +125,7 @@ public interface Inventory {
/**
* Find the first slot in the inventory containing an ItemStack with the given materialId
*
*
* @param materialId The materialId to look for
* @return The Slot found.
*/
@ -133,7 +133,7 @@ public interface Inventory {
/**
* Find the first slot in the inventory containing an ItemStack with the given material
*
*
* @param materialId The material to look for
* @return The Slot found.
*/
@ -142,7 +142,7 @@ public interface Inventory {
/**
* Find the first slot in the inventory containing an ItemStack with the given stack
* This will only match a slot if both the type and the amount of the stack match
*
*
* @param item The ItemStack to match against
* @return The Slot found.
*/
@ -150,21 +150,21 @@ public interface Inventory {
/**
* Find the first empty Slot.
*
*
* @return The first empty Slot found.
*/
public int firstEmpty();
/**
* Remove all stacks in the inventory matching the given materialId.
*
*
* @param materialId The material to remove
*/
public void remove(int materialId);
/**
* Remove all stacks in the inventory matching the given material.
*
*
* @param material The material to remove
*/
public void remove(Material material);
@ -172,14 +172,14 @@ public interface Inventory {
/**
* Remove all stacks in the inventory matching the given stack.
* This will only match a slot if both the type and the amount of the stack match
*
*
* @param item The ItemStack to match against
*/
public void remove(ItemStack item);
/**
* Clear out a particular slot in the index
*
*
* @param index The index to empty.
*/
public void clear(int index);

View file

@ -6,21 +6,21 @@ package org.bukkit.inventory;
public interface Slot {
/**
* Gets the inventory this slot belongs to
*
*
* @return The inventory
*/
public Inventory getInventory();
/**
* Get the index this slot belongs to
*
*
* @return Index of the slot
*/
public int getIndex();
/**
* Get the item from the slot.
*
*
* @return ItemStack in the slot.
*/
public ItemStack getItem();

View file

@ -23,7 +23,7 @@ public class Dye extends MaterialData {
public Dye(final Material type, final byte data) {
super(type, data);
}
/**
* Gets the current color of this dye
*
@ -41,4 +41,4 @@ public class Dye extends MaterialData {
public void setColor(DyeColor color) {
setData(color.getData());
}
}
}

View file

@ -39,7 +39,7 @@ public class MaterialData {
/**
* Sets the raw data of this material
*
*
* @param data New raw data
*/
public void setData(byte data) {

View file

@ -9,23 +9,23 @@ import org.bukkit.World;
* storing Vectors long term may be dangerous if passing code modifies the
* Vector later. If you want to keep around a Vector, it may be wise to call
* <code>clone()</code> in order to get a copy.
*
*
* @author sk89q
*/
public class Vector implements Cloneable {
private static final long serialVersionUID = -2657651106777219169L;
private static Random random = new Random();
/**
* Threshold for fuzzy equals().
*/
private static final double epsilon = 0.000001;
protected double x;
protected double y;
protected double z;
/**
* Construct the vector with all components as 0.
*/
@ -34,10 +34,10 @@ public class Vector implements Cloneable {
this.y = 0;
this.z = 0;
}
/**
* Construct the vector with provided integer components.
*
*
* @param x
* @param y
* @param z
@ -50,7 +50,7 @@ public class Vector implements Cloneable {
/**
* Construct the vector with provided double components.
*
*
* @param x
* @param y
* @param z
@ -63,7 +63,7 @@ public class Vector implements Cloneable {
/**
* Construct the vector with provided float components.
*
*
* @param x
* @param y
* @param z
@ -76,7 +76,7 @@ public class Vector implements Cloneable {
/**
* Adds the vector by another.
*
*
* @param vec
* @return the same vector
*/
@ -89,7 +89,7 @@ public class Vector implements Cloneable {
/**
* Subtracts the vector by another.
*
*
* @param vec
* @return the same vector
*/
@ -102,7 +102,7 @@ public class Vector implements Cloneable {
/**
* Multiplies the vector by another.
*
*
* @param vec
* @return the same vector
*/
@ -112,10 +112,10 @@ public class Vector implements Cloneable {
z *= vec.z;
return this;
}
/**
* Divides the vector by another.
*
*
* @param vec
* @return the same vector
*/
@ -125,56 +125,56 @@ public class Vector implements Cloneable {
z /= vec.z;
return this;
}
/**
* Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2). The value
* of this method is not cached and uses a costly square-root function, so
* do not repeatedly call this method to get the vector's magnitude. NaN
* will be returned if the inner result of the sqrt() function overflows,
* which will be caused if the length is too long.
*
*
* @return the magnitude
*/
public double length() {
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
}
/**
* Gets the magnitude of the vector squared.
*
*
* @return the magnitude
*/
public double lengthSquared() {
return Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2);
}
/**
* Get the distance between this vector and another. The value
* of this method is not cached and uses a costly square-root function, so
* do not repeatedly call this method to get the vector's magnitude. NaN
* will be returned if the inner result of the sqrt() function overflows,
* which will be caused if the distance is too long.
*
*
* @return the distance
*/
public double distance(Vector o) {
return Math.sqrt(Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2)
+ Math.pow(z - o.z, 2));
}
/**
* Get the squared distance between this vector and another.
*
*
* @return the distance
*/
public double distanceSquared(Vector o) {
return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2)
+ Math.pow(z - o.z, 2);
}
/**
* Gets the angle between this vector and another in radians.
*
*
* @param other
* @return angle in radians
*/
@ -182,10 +182,10 @@ public class Vector implements Cloneable {
double dot = dot(other) / (length() * other.length());
return (float)Math.acos(dot);
}
/**
* Sets this vector to the midpoint between this vector and another.
*
*
* @param other
* @return this same vector (now a midpoint)
*/
@ -195,10 +195,10 @@ public class Vector implements Cloneable {
z = (z + other.z) / 2;
return this;
}
/**
* Gets a new midpoint vector between this vector and another.
*
*
* @param other
* @return a new midpoint vector
*/
@ -208,10 +208,10 @@ public class Vector implements Cloneable {
z = (z + other.z) / 2;
return new Vector(x, y, z);
}
/**
* Performs scalar multiplication, multiplying all components with a scalar.
*
*
* @param m
* @return the same vector
*/
@ -221,10 +221,10 @@ public class Vector implements Cloneable {
z *= m;
return this;
}
/**
* Performs scalar multiplication, multiplying all components with a scalar.
*
*
* @param m
* @return the same vector
*/
@ -234,10 +234,10 @@ public class Vector implements Cloneable {
z *= m;
return this;
}
/**
* Performs scalar multiplication, multiplying all components with a scalar.
*
*
* @param m
* @return the same vector
*/
@ -247,26 +247,26 @@ public class Vector implements Cloneable {
z *= m;
return this;
}
/**
* Calculates the dot product of this vector with another. The dot product
* is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar.
*
*
* @param other
* @return dot product
*/
public double dot(Vector other) {
return x * other.x + y * other.y + z * other.z;
}
/**
* Calculates the cross product of this vector with another. The cross
* product is defined as:
*
*
* x = y1 * z2 - y2 * z1<br/>
* y = z1 * x2 - z2 * x1<br/>
* z = x1 * y2 - x2 * y1
*
*
* @param o
* @return the same vector
*/
@ -279,25 +279,25 @@ public class Vector implements Cloneable {
z = newZ;
return this;
}
/**
* Converts this vector to a unit vector (a vector with length of 1).
*
*
* @return the same vector
*/
public Vector normalize() {
double length = length();
x /= length;
y /= length;
z /= length;
return this;
}
/**
* Zero this vector's components.
*
*
* @return the same vector
*/
public Vector zero() {
@ -306,12 +306,12 @@ public class Vector implements Cloneable {
z = 0;
return this;
}
/**
* Returns whether this vector is in an axis-aligned bounding box.
* The minimum and maximum vectors given must be truly the minimum and
* maximum X, Y and Z components.
*
*
* @param min
* @param max
* @return whether this vector is in the AABB
@ -321,10 +321,10 @@ public class Vector implements Cloneable {
&& y >= min.y && y <= max.y
&& z >= min.z && z <= max.z;
}
/**
* Returns whether this vector is within a sphere.
*
*
* @param origin
* @param radius
* @return whether this vector is in the sphere
@ -335,29 +335,29 @@ public class Vector implements Cloneable {
+ Math.pow(origin.z - z, 2))
<= Math.pow(radius, 2);
}
/**
* Gets the X component.
*
*
* @return
*/
public double getX() {
return x;
}
/**
* Gets the floored value of the X component, indicating the block that
* this vector is contained with.
*
*
* @return block X
*/
public int getBlockX() {
return (int)Math.floor(x);
}
/**
* Gets the Y component.
*
*
* @return
*/
public double getY() {
@ -367,16 +367,16 @@ public class Vector implements Cloneable {
/**
* Gets the floored value of the Y component, indicating the block that
* this vector is contained with.
*
*
* @return block y
*/
public int getBlockY() {
return (int)Math.floor(y);
}
/**
* Gets the Z component.
*
*
* @return
*/
public double getZ() {
@ -386,16 +386,16 @@ public class Vector implements Cloneable {
/**
* Gets the floored value of the Z component, indicating the block that
* this vector is contained with.
*
*
* @return block z
*/
public int getBlockZ() {
return (int)Math.floor(z);
}
/**
* Set the X component.
*
*
* @param x
* @return x
*/
@ -406,7 +406,7 @@ public class Vector implements Cloneable {
/**
* Set the X component.
*
*
* @param x
* @return x
*/
@ -417,7 +417,7 @@ public class Vector implements Cloneable {
/**
* Set the X component.
*
*
* @param x
* @return x
*/
@ -428,7 +428,7 @@ public class Vector implements Cloneable {
/**
* Set the Y component.
*
*
* @param y
* @return y
*/
@ -439,7 +439,7 @@ public class Vector implements Cloneable {
/**
* Set the Y component.
*
*
* @param y
* @return y
*/
@ -450,7 +450,7 @@ public class Vector implements Cloneable {
/**
* Set the Y component.
*
*
* @param y
* @return y
*/
@ -461,7 +461,7 @@ public class Vector implements Cloneable {
/**
* Set the Z component.
*
*
* @param z
* @return z
*/
@ -472,7 +472,7 @@ public class Vector implements Cloneable {
/**
* Set the Z component.
*
*
* @param z
* @return z
*/
@ -483,7 +483,7 @@ public class Vector implements Cloneable {
/**
* Set the Z component.
*
*
* @param z
* @return z
*/
@ -494,19 +494,19 @@ public class Vector implements Cloneable {
/**
* Checks to see if two objects are equal.
*
*
* Only two Vectors can ever return true. This method uses a fuzzy match
* to account for floating point errors. The epsilon can be retrieved
* with epsilon.
* with epsilon.
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector)obj;
return Math.abs(x - other.x) < epsilon
&& Math.abs(y - other.y) < epsilon
&& Math.abs(z - other.z) < epsilon;
@ -515,7 +515,7 @@ public class Vector implements Cloneable {
/**
* Returns a hash code for this vector. Due to floating point errors, this
* hash code should not be used in hash tables of any sort.
*
*
* @return hash code
*/
@Override
@ -527,7 +527,7 @@ public class Vector implements Cloneable {
/**
* Get a new vector.
*
*
* @return vector
*/
@Override
@ -537,16 +537,16 @@ public class Vector implements Cloneable {
/**
* Returns this vector's components as x,y,z.
*
*
*/
@Override
public String toString() {
return x + "," + y + "," + z;
}
/**
* Gets a Location version of this vector with yaw and pitch being 0.
*
*
* @param world
* @return the location
*/
@ -556,26 +556,26 @@ public class Vector implements Cloneable {
/**
* Gets a Location version of this vector.
*
*
* @param world
* @return the location
*/
public Location toLocation(World world, float yaw, float pitch) {
return new Location(world, x, y, z, yaw, pitch);
}
/**
* Get the threshold used for equals().
*
*
* @return
*/
public static double getEpsilon() {
return epsilon;
}
/**
* Gets the minimum components of two vectors.
*
*
* @param v1
* @param v2
* @return minimum
@ -586,10 +586,10 @@ public class Vector implements Cloneable {
Math.min(v1.y, v2.y),
Math.min(v1.z, v2.z));
}
/**
* Gets the maximum components of two vectors.
*
*
* @param v1
* @param v2
* @return maximum
@ -600,11 +600,11 @@ public class Vector implements Cloneable {
Math.max(v1.y, v2.y),
Math.max(v1.z, v2.z));
}
/**
* Gets a random vector with components having a random value between
* 0 and 1.
*
*
* @return
*/
public static Vector getRandom() {