mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-15 21:01:24 +01:00
Generic cleanup/reformat.
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
parent
6a7e7141f8
commit
f981a18f45
@ -24,7 +24,7 @@ import org.bukkit.World;
|
||||
|
||||
public class CraftWorld implements World {
|
||||
private final WorldServer world;
|
||||
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
public CraftWorld(WorldServer world) {
|
||||
@ -42,7 +42,7 @@ public class CraftWorld implements World {
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
return world.d(x, z);
|
||||
}
|
||||
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
return new Location(this, world.spawnX, world.e(world.spawnX, world.spawnZ), world.spawnZ);
|
||||
}
|
||||
@ -89,7 +89,7 @@ public class CraftWorld implements World {
|
||||
// However, this entity is not at the moment backed by a server entity class so it may be left.
|
||||
return new CraftItemDrop(world.getServer(), entity);
|
||||
}
|
||||
|
||||
|
||||
public ItemDrop dropItemNaturally(Location loc, ItemStack item) {
|
||||
double xs = world.l.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
|
||||
double ys = world.l.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
|
||||
@ -108,7 +108,7 @@ public class CraftWorld implements World {
|
||||
arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
|
||||
return (Arrow) arrow.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
||||
public Minecart spawnMinecart(Location loc) {
|
||||
EntityMinecart minecart = new EntityMinecart(
|
||||
world,
|
||||
@ -120,7 +120,7 @@ public class CraftWorld implements World {
|
||||
world.a(minecart);
|
||||
return (Minecart) minecart.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
||||
public StorageMinecart spawnStorageMinecart(Location loc) {
|
||||
EntityMinecart minecart = new EntityMinecart(
|
||||
world,
|
||||
@ -132,7 +132,7 @@ public class CraftWorld implements World {
|
||||
world.a(minecart);
|
||||
return (StorageMinecart) minecart.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
||||
public PoweredMinecart spawnPoweredMinecart(Location loc) {
|
||||
EntityMinecart minecart = new EntityMinecart(
|
||||
world,
|
||||
@ -144,13 +144,13 @@ public class CraftWorld implements World {
|
||||
world.a(minecart);
|
||||
return (PoweredMinecart) minecart.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
||||
public Boat spawnBoat(Location loc) {
|
||||
EntityBoat boat = new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ());
|
||||
world.a(boat);
|
||||
return (Boat) boat.getBukkitEntity();
|
||||
}
|
||||
|
||||
|
||||
public boolean generateTree(Location loc, TreeType type) {
|
||||
return generateTree(loc, type, world);
|
||||
}
|
||||
@ -158,29 +158,19 @@ public class CraftWorld implements World {
|
||||
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
|
||||
switch (type) {
|
||||
case BIG_TREE:
|
||||
return (new WorldGenBigTree())
|
||||
.generate(delegate, rand,
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return new WorldGenBigTree().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
case BIRCH:
|
||||
return (new WorldGenForest())
|
||||
.generate(delegate, rand,
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return new WorldGenForest().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
case REDWOOD:
|
||||
return (new WorldGenTaiga2())
|
||||
.generate(delegate, rand,
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return new WorldGenTaiga2().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
case TALL_REDWOOD:
|
||||
return (new WorldGenTaiga1())
|
||||
.generate(delegate, rand,
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
case TREE:
|
||||
default:
|
||||
return (new WorldGenTrees())
|
||||
.generate(delegate, rand,
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return new WorldGenTrees().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TileEntity getTileEntityAt(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
@ -256,12 +246,10 @@ public class CraftWorld implements World {
|
||||
|
||||
public List<Entity> getEntities() {
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
for (Object o : world.b) {
|
||||
|
||||
for (Object o: world.b) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt
|
||||
= (net.minecraft.server.Entity)o;
|
||||
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
|
||||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
// Assuming that bukkitEntity isn't null
|
||||
@ -270,27 +258,25 @@ public class CraftWorld implements World {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<LivingEntity> getLivingEntities() {
|
||||
List<LivingEntity> list = new ArrayList<LivingEntity>();
|
||||
|
||||
for (Object o : world.b) {
|
||||
|
||||
for (Object o: world.b) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt
|
||||
= (net.minecraft.server.Entity)o;
|
||||
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
|
||||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
|
||||
// Assuming that bukkitEntity isn't null
|
||||
if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) {
|
||||
list.add((LivingEntity)bukkitEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -134,10 +134,10 @@ public class CraftBlock implements Block {
|
||||
public int getTypeId() {
|
||||
return chunk.getHandle().a(this.x & 0xF, this.y & 0x7F, this.z & 0xF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the light level between 0-15
|
||||
*
|
||||
*
|
||||
* @return light level
|
||||
*/
|
||||
public byte getLightLevel() {
|
||||
@ -170,8 +170,7 @@ public class CraftBlock implements Block {
|
||||
* @return Block at the given face
|
||||
*/
|
||||
public Block getFace(final BlockFace face, final int distance) {
|
||||
return getRelative(face.getModX() * distance, face.getModY() * distance,
|
||||
face.getModZ() * distance);
|
||||
return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,11 +231,11 @@ public class CraftBlock implements Block {
|
||||
public String toString() {
|
||||
return "CraftBlock{" + "chunk=" + chunk + "x=" + x + "y=" + y + "z=" + z + '}';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notch uses a 0-5 to mean DOWN, UP, EAST, WEST, NORTH, SOUTH
|
||||
* in that order all over. This method is convenience to convert for us.
|
||||
*
|
||||
*
|
||||
* @return BlockFace the BlockFace represented by this number
|
||||
*/
|
||||
public static BlockFace notchToBlockFace(int notch) {
|
||||
|
@ -125,7 +125,7 @@ public class CraftBlockState implements BlockState {
|
||||
public void setTypeId(final int type) {
|
||||
this.type = type;
|
||||
world.getHandle().e(x, y, z, type);
|
||||
|
||||
|
||||
createData((byte)0);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
/**
|
||||
* Represents a dispenser.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
/**
|
||||
* Represents a note block.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
/**
|
||||
* Represents an arrow.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftArrow extends CraftEntity implements Arrow {
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Boat;
|
||||
|
||||
/**
|
||||
* A minecart.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftBoat extends CraftVehicle implements Boat {
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Egg;
|
||||
|
||||
/**
|
||||
* An egg.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftEgg extends CraftEntity implements Egg {
|
||||
|
@ -37,7 +37,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
// Monsters
|
||||
else if (entity instanceof EntityMonster) {
|
||||
if (entity instanceof EntityZombie) {
|
||||
if (entity instanceof EntityZombie) {
|
||||
if (entity instanceof EntityPigZombie) { return new CraftPigZombie( server, (EntityPigZombie) entity); }
|
||||
else { return new CraftZombie( server, (EntityZombie) entity); }
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Fireball;
|
||||
|
||||
/**
|
||||
* A Fireball.
|
||||
*
|
||||
*
|
||||
* @author Cogito
|
||||
*/
|
||||
public class CraftFireball extends CraftEntity implements Fireball {
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Fish;
|
||||
|
||||
/**
|
||||
* A Fish.
|
||||
*
|
||||
*
|
||||
* @author Cogito
|
||||
*/
|
||||
public class CraftFish extends CraftEntity implements Fish {
|
||||
|
@ -4,7 +4,6 @@ package org.bukkit.craftbukkit.entity;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
@ -8,12 +8,12 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
/**
|
||||
* Represents an item drop.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftItemDrop extends CraftEntity implements ItemDrop {
|
||||
private EntityItem item;
|
||||
|
||||
|
||||
public CraftItemDrop(CraftServer server, EntityItem entity) {
|
||||
super(server, entity);
|
||||
this.item = entity;
|
||||
|
@ -79,7 +79,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
if (entity.vehicle == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
entity.setPassengerOf(null);
|
||||
return true;
|
||||
}
|
||||
@ -88,12 +88,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
if (entity.vehicle == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
org.bukkit.entity.Entity vehicle = (entity.vehicle.getBukkitEntity());
|
||||
if (vehicle instanceof Vehicle) {
|
||||
return (Vehicle) vehicle;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.PoweredMinecart;
|
||||
|
||||
/**
|
||||
* A powered minecart.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftPoweredMinecart extends CraftMinecart
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Snowball;
|
||||
|
||||
/**
|
||||
* A snowball.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftSnowball extends CraftEntity implements Snowball {
|
||||
|
@ -9,12 +9,12 @@ import org.bukkit.entity.StorageMinecart;
|
||||
|
||||
/**
|
||||
* A storage minecart.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart {
|
||||
private CraftInventory inventory;
|
||||
|
||||
|
||||
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
|
||||
super(server, entity);
|
||||
inventory = new CraftInventory( entity );
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Vehicle;
|
||||
|
||||
/**
|
||||
* A vehicle.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public abstract class CraftVehicle extends CraftEntity implements Vehicle {
|
||||
@ -17,7 +17,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
|
||||
public Entity getPassenger() {
|
||||
return isEmpty() ? null : (getHandle().passenger.getBukkitEntity());
|
||||
}
|
||||
|
||||
|
||||
public boolean setPassenger(Entity passenger) {
|
||||
if(passenger instanceof CraftEntity){
|
||||
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
|
||||
@ -30,12 +30,12 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
|
||||
public boolean isEmpty() {
|
||||
return getHandle().passenger == null;
|
||||
}
|
||||
|
||||
|
||||
public boolean eject() {
|
||||
if (getHandle().passenger == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
getHandle().passenger.setPassengerOf(null);
|
||||
return true;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||
public int firstPartial(ItemStack item) {
|
||||
return firstPartial(item.getTypeId());
|
||||
}
|
||||
|
||||
|
||||
public HashMap<Integer, ItemStack> addItem(ItemStack... items) {
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
@ -202,13 +202,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||
int amount = item.getAmount();
|
||||
int partialAmount = partialItem.getAmount();
|
||||
int maxAmount = partialItem.getMaxStackSize();
|
||||
|
||||
|
||||
// Check if it fully fits
|
||||
if (amount + partialAmount <= maxAmount) {
|
||||
partialItem.setAmount( amount + partialAmount );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// It fits partially
|
||||
partialItem.setAmount( maxAmount );
|
||||
item.setAmount( amount + partialAmount - maxAmount );
|
||||
|
@ -9,7 +9,7 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent
|
||||
public CraftInventoryPlayer(net.minecraft.server.InventoryPlayer inventory) {
|
||||
super(inventory);
|
||||
}
|
||||
|
||||
|
||||
public InventoryPlayer getInventory() {
|
||||
return (InventoryPlayer) inventory;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class CraftItemStack extends ItemStack {
|
||||
if (item != null) {
|
||||
super.setDurability(durability);
|
||||
item.damage = durability;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user