3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Implemented World.spawnBoat(), added CraftMappable interface that defines a method to get an org.bukkit.craftbukkit.CraftEntity from implementing net.minecart.server.Entity entities, changed CraftWorld.toCraftEntity() to use this new interface for boats and minecarts.

Dieser Commit ist enthalten in:
sk89q 2011-01-07 14:01:37 -08:00
Ursprung eb2cc2da4a
Commit 6d6668aaeb
4 geänderte Dateien mit 44 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,8 @@ import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.CraftBoat; import org.bukkit.craftbukkit.CraftBoat;
import org.bukkit.craftbukkit.CraftEntity;
import org.bukkit.craftbukkit.CraftMappable;
import org.bukkit.craftbukkit.CraftMinecart; import org.bukkit.craftbukkit.CraftMinecart;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
@ -13,9 +15,9 @@ import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleMoveEvent;
public class EntityBoat extends Entity { public class EntityBoat extends Entity implements CraftMappable {
public CraftBoat boat; private CraftBoat boat;
public int a; public int a;
public int b; public int b;
@ -27,6 +29,10 @@ public class EntityBoat extends Entity {
private double ak; private double ak;
private double al; private double al;
public CraftEntity getCraftEntity() {
return boat;
}
public EntityBoat(World world) { public EntityBoat(World world) {
super(world); super(world);
a = 0; a = 0;

Datei anzeigen

@ -4,15 +4,17 @@ import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Vector; import org.bukkit.Vector;
import org.bukkit.craftbukkit.CraftEntity;
import org.bukkit.craftbukkit.CraftMappable;
import org.bukkit.craftbukkit.CraftMinecart; import org.bukkit.craftbukkit.CraftMinecart;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.vehicle.*; import org.bukkit.event.vehicle.*;
public class EntityMinecart extends Entity public class EntityMinecart extends Entity
implements IInventory { implements IInventory, CraftMappable {
public CraftMinecart minecart; private CraftMinecart minecart;
private ItemStack ak[]; private ItemStack ak[];
public int a; public int a;
@ -101,6 +103,10 @@ public class EntityMinecart extends Entity
private double flyingY = 0.94999998807907104; private double flyingY = 0.94999998807907104;
private double flyingZ = 0.94999998807907104; private double flyingZ = 0.94999998807907104;
public CraftEntity getCraftEntity() {
return minecart;
}
public EntityMinecart(World world) { public EntityMinecart(World world) {
super(world); super(world);
ak = new ItemStack[36]; ak = new ItemStack[36];

Datei anzeigen

@ -0,0 +1,16 @@
package org.bukkit.craftbukkit;
/**
* Indicates that an object has a method to get its CraftBukkit-equivalent
* CraftEntity object from its Minecraft net.minecraft.server.Entity object.
*
* @author sk89q
*/
public interface CraftMappable {
/**
* Gets the CraftEntity version.
*
* @return
*/
public CraftEntity getCraftEntity();
}

Datei anzeigen

@ -7,6 +7,7 @@ import java.util.Map;
import net.minecraft.server.EntityMinecart; import net.minecraft.server.EntityMinecart;
import java.util.Random; import java.util.Random;
import net.minecraft.server.EntityBoat;
import net.minecraft.server.EntityEgg; import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityPlayerMP; import net.minecraft.server.EntityPlayerMP;
@ -18,6 +19,7 @@ import net.minecraft.server.WorldServer;
import net.minecraft.server.WorldGenTrees; import net.minecraft.server.WorldGenTrees;
import org.bukkit.Arrow; import org.bukkit.Arrow;
import org.bukkit.Block; import org.bukkit.Block;
import org.bukkit.Boat;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Minecart; import org.bukkit.Minecart;
@ -144,6 +146,13 @@ public class CraftWorld implements World {
return new CraftPoweredMinecart(world.getServer(), minecart); return new CraftPoweredMinecart(world.getServer(), minecart);
} }
public Boat spawnBoat(Location loc) {
EntityBoat boat =
new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ());
world.a(boat);
return new CraftBoat(world.getServer(), boat);
}
public boolean generateTree(Location loc) { public boolean generateTree(Location loc) {
WorldGenTrees treeGen = new WorldGenTrees(); WorldGenTrees treeGen = new WorldGenTrees();
return treeGen.a(world, rand, return treeGen.a(world, rand,
@ -165,18 +174,12 @@ public class CraftWorld implements World {
return new CraftPlayer(world.getServer(), (EntityPlayerMP)entity); return new CraftPlayer(world.getServer(), (EntityPlayerMP)entity);
} else if (entity instanceof EntitySnowball) { } else if (entity instanceof EntitySnowball) {
return new CraftSnowball(world.getServer(), (EntitySnowball)entity); return new CraftSnowball(world.getServer(), (EntitySnowball)entity);
} else if (entity instanceof EntityMinecart) {
EntityMinecart minecart = (EntityMinecart)entity;
if (minecart.minecart != null) {
return minecart.minecart;
}
return CraftMinecart.getCraftMinecart(world.getServer(),
(EntityMinecart)entity);
} else if (entity instanceof EntityPlayer) { } else if (entity instanceof EntityPlayer) {
return new CraftHumanEntity(world.getServer(), (EntityPlayer)entity); return new CraftHumanEntity(world.getServer(), (EntityPlayer)entity);
} else if (entity instanceof EntityLiving) { } else if (entity instanceof EntityLiving) {
return new CraftLivingEntity(world.getServer(), (EntityLiving)entity); return new CraftLivingEntity(world.getServer(), (EntityLiving)entity);
} else if (entity instanceof CraftMappable) {
return ((CraftMappable)entity).getCraftEntity();
} else { } else {
return null; return null;
} }