Switch to Gradle. Use git log --follow for history.

This converts the project into a multi-module Gradle build.

By default, Git does not show history past a rename, so use git log
--follow to see further history.
This commit is contained in:
sk89q
2014-11-14 11:27:39 -08:00
parent 44559cde68
commit 7192780251
714 changed files with 333 additions and 834 deletions

View File

@ -0,0 +1,113 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.entity;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.NbtValued;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a mutable "snapshot" of an entity.
*
* <p>An instance of this class contains all the information needed to
* accurately reproduce the entity, provided that the instance was
* made correctly. In some implementations, it may not be possible to get a
* snapshot of entities correctly, so, for example, the NBT data for an entity
* may be missing.</p>
*
* <p>This class identifies entities using its entity type string, although
* this is not very efficient as the types are currently not interned. This
* may be changed in the future.</p>
*/
public class BaseEntity implements NbtValued {
private String id;
private CompoundTag nbtData;
/**
* Create a new base entity.
*
* @param id the entity type ID
* @param nbtData NBT data
*/
public BaseEntity(String id, CompoundTag nbtData) {
setTypeId(id);
setNbtData(nbtData);
}
/**
* Create a new base entity with no NBT data.
*
* @param id the entity type ID
*/
public BaseEntity(String id) {
setTypeId(id);
}
/**
* Make a clone of a {@link BaseEntity}.
*
* @param other the object to clone
*/
public BaseEntity(BaseEntity other) {
checkNotNull(other);
setTypeId(other.getTypeId());
setNbtData(other.getNbtData());
}
@Override
public boolean hasNbtData() {
return true;
}
@Nullable
@Override
public CompoundTag getNbtData() {
return nbtData;
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
this.nbtData = nbtData;
}
/**
* Get the entity that determines the type of entity.
*
* @return the entity ID
*/
public String getTypeId() {
return id;
}
/**
* Set the entity ID that determines the type of entity.
*
* @param id the id
*/
public void setTypeId(String id) {
checkNotNull(id);
this.id = id;
}
}

View File

@ -0,0 +1,71 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Faceted;
import com.sk89q.worldedit.util.Location;
import javax.annotation.Nullable;
/**
* A reference to an instance of an entity that exists in an {@link Extent}
* and thus would have position and similar details.
*
* <p>This object cannot be directly cloned because it represents a particular
* instance of an entity, but a {@link BaseEntity} can be created from
* this entity by calling {@link #getState()}.</p>
*/
public interface Entity extends Faceted {
/**
* Get a copy of the entity's state.
*
* <p>In some cases, this method may return {@code null} if a snapshot
* of the entity can't be created. It may not be possible, for example,
* to get a snapshot of a player.</p>
*
* @return the entity's state or null if one cannot be created
*/
@Nullable
BaseEntity getState();
/**
* Get the location of this entity.
*
* @return the location of the entity
*/
Location getLocation();
/**
* Get the extent that this entity is on.
*
* @return the extent
*/
Extent getExtent();
/**
* Remove this entity from it container.
*
* @return true if removal was successful
*/
boolean remove();
}

View File

@ -0,0 +1,286 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.WorldVectorFace;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.world.World;
/**
* Represents a player
*/
public interface Player extends Entity, Actor {
/**
* Return the world that the player is on.
*
* @return the world
*/
World getWorld();
/**
* Returns true if the entity is holding a pick axe.
*
* @return whether a pick axe is held
*/
boolean isHoldingPickAxe();
/**
* Get the player's cardinal direction (N, W, NW, etc.) with an offset. May return null.
* @param yawOffset offset that is added to the player's yaw before determining the cardinal direction
*
* @return the direction
*/
PlayerDirection getCardinalDirection(int yawOffset);
/**
* Get the ID of the item that the player is holding.
*
* @return the item id of the item the player is holding
*/
int getItemInHand();
/**
* Get the Block that the player is holding.
*
* @return the item id of the item the player is holding
*/
BaseBlock getBlockInHand() throws WorldEditException;
/**
* Gives the player an item.
*
* @param type The item id of the item to be given to the player
* @param amount How many items in the stack
*/
void giveItem(int type, int amount);
/**
* Get this actor's block bag.
*
* @return the actor's block bag
*/
BlockBag getInventoryBlockBag();
/**
* Return whether this actor has creative mode.
*
* @return true if creative mode is enabled
*/
boolean hasCreativeMode();
/**
* Find a position for the actor to stand that is not inside a block.
* Blocks above the player will be iteratively tested until there is
* a series of two free blocks. The actor will be teleported to
* that free position.
*
* @param searchPos search position
*/
void findFreePosition(WorldVector searchPos);
/**
* Set the actor on the ground.
*
* @param searchPos The location to start searching from
*/
void setOnGround(WorldVector searchPos);
/**
* Find a position for the player to stand that is not inside a block.
* Blocks above the player will be iteratively tested until there is
* a series of two free blocks. The player will be teleported to
* that free position.
*/
void findFreePosition();
/**
* Go up one level to the next free space above.
*
* @return true if a spot was found
*/
boolean ascendLevel();
/**
* Go up one level to the next free space above.
*
* @return true if a spot was found
*/
boolean descendLevel();
/**
* Ascend to the ceiling above.
*
* @param clearance How many blocks to leave above the player's head
* @return whether the player was moved
*/
boolean ascendToCeiling(int clearance);
/**
* Ascend to the ceiling above.
*
* @param clearance How many blocks to leave above the player's head
* @param alwaysGlass Always put glass under the player
* @return whether the player was moved
*/
boolean ascendToCeiling(int clearance, boolean alwaysGlass);
/**
* Just go up.
*
* @param distance How far up to teleport
* @return whether the player was moved
*/
boolean ascendUpwards(int distance);
/**
* Just go up.
*
* @param distance How far up to teleport
* @param alwaysGlass Always put glass under the player
* @return whether the player was moved
*/
boolean ascendUpwards(int distance, boolean alwaysGlass);
/**
* Make the player float in the given blocks.
*
* @param x The X coordinate of the block to float in
* @param y The Y coordinate of the block to float in
* @param z The Z coordinate of the block to float in
*/
void floatAt(int x, int y, int z, boolean alwaysGlass);
/**
* Get the point of the block that is being stood in.
*
* @return point
*/
WorldVector getBlockIn();
/**
* Get the point of the block that is being stood upon.
*
* @return point
*/
WorldVector getBlockOn();
/**
* Get the point of the block being looked at. May return null.
* Will return the farthest away air block if useLastBlock is true and no other block is found.
*
* @param range how far to checks for blocks
* @param useLastBlock try to return the last valid air block found
* @return point
*/
WorldVector getBlockTrace(int range, boolean useLastBlock);
/**
* Get the face that the player is looking at.
*
* @param range the range
* @param useLastBlock try to return the last valid air block found
* @return a face
*/
WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock);
/**
* Get the point of the block being looked at. May return null.
*
* @param range How far to checks for blocks
* @return point
*/
WorldVector getBlockTrace(int range);
/**
* Get the point of the block being looked at. May return null.
*
* @param range How far to checks for blocks
* @return point
*/
WorldVector getSolidBlockTrace(int range);
/**
* Get the player's cardinal direction (N, W, NW, etc.). May return null.
*
* @return the direction
*/
PlayerDirection getCardinalDirection();
/**
* Get the actor's position.
*
* <p>If the actor has no permission, then a dummy location is returned.</p>
*
* @return the actor's position
* @deprecated use {@link #getLocation()}
*/
@Deprecated
WorldVector getPosition();
/**
* Get the player's view pitch in degrees.
*
* @return pitch
* @deprecated use {@link #getLocation()}
*/
@Deprecated
double getPitch();
/**
* Get the player's view yaw in degrees.
*
* @return yaw
* @deprecated use {@link #getLocation()}
*/
@Deprecated
double getYaw();
/**
* Pass through the wall that you are looking at.
*
* @param range How far to checks for blocks
* @return whether the player was pass through
*/
boolean passThroughForwardWall(int range);
/**
* Move the player.
*
* @param pos where to move them
* @param pitch the pitch (up/down) of the player's view in degrees
* @param yaw the yaw (left/right) of the player's view in degrees
*/
void setPosition(Vector pos, float pitch, float yaw);
/**
* Move the player.
*
* @param pos where to move them
*/
void setPosition(Vector pos);
}

View File

@ -0,0 +1,151 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.entity.metadata;
/**
* Describes various classes of entities.
*/
public interface EntityType {
/**
* Test whether the entity is a player-derived entity.
*
* @return true if a player derived entity
*/
boolean isPlayerDerived();
/**
* Test whether the entity is a projectile.
*
* @return true if a projectile
*/
boolean isProjectile();
/**
* Test whether the entity is an item.
*
* @return true if an item
*/
boolean isItem();
/**
* Test whether the entity is a falling block.
*
* @return true if a falling block
*/
boolean isFallingBlock();
/**
* Test whether the entity is a painting.
*
* @return true if a painting
*/
boolean isPainting();
/**
* Test whether the entity is an item frame.
*
* @return true if an item frame
*/
boolean isItemFrame();
/**
* Test whether the entity is a boat.
*
* @return true if a boat
*/
boolean isBoat();
/**
* Test whether the entity is a minecart.
*
* @return true if a minecart
*/
boolean isMinecart();
/**
* Test whether the entity is a primed TNT block.
*
* @return true if TNT
*/
boolean isTNT();
/**
* Test whether the entity is an experience orb.
*
* @return true if an experience orb
*/
boolean isExperienceOrb();
/**
* Test whether the entity is a living entity.
*
* <p>A "living entity" is the superclass of many living entity classes
* in Minecraft.</p>
*
* @return true if a living entity
*/
boolean isLiving();
/**
* Test whether the entity is an animal.
*
* @return true if an animal
*/
boolean isAnimal();
/**
* Test whether the entity is an ambient creature, which includes
* the bat.
*
* @return true if an ambient creature
*/
boolean isAmbient();
/**
* Test whether the entity is a non-player controlled character, which
* includes villagers, NPCs from mods, and so on.
*
* @return true if an NPC
*/
boolean isNPC();
/**
* Test whether the entity is the iron golem from Minecraft.
*
* @return true if an iron golem
*/
boolean isGolem();
/**
* Test whether the entity is tameable and is tamed.
*
* @return true if tamed
*/
boolean isTamed();
/**
* Test whether the entity has been named (tagged).
*
* @return true if named
*/
boolean isTagged();
}