Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Added minecart classes and World.spawn*Minecart(). Minecart.getPassenger() is still a stub that needs to be implemented (due to of a need of a MC entity -> CraftBukkit entity lookup) and StorageMinecart.getInventory() is waiting on the implementation of inventory.
Dieser Commit ist enthalten in:
Ursprung
ca47ccf674
Commit
9d68035410
69
src/main/java/org/bukkit/craftbukkit/CraftMinecart.java
Normale Datei
69
src/main/java/org/bukkit/craftbukkit/CraftMinecart.java
Normale Datei
@ -0,0 +1,69 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.EntityMinecart;
|
||||
import org.bukkit.LivingEntity;
|
||||
import org.bukkit.Minecart;
|
||||
import org.bukkit.Vector;
|
||||
|
||||
/**
|
||||
* A minecart.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
/**
|
||||
* Stores the minecart type ID, which is used by Minecraft to differentiate
|
||||
* minecart types. Here we use subclasses.
|
||||
*/
|
||||
public enum Type {
|
||||
Minecart(0),
|
||||
StorageMinecart(1),
|
||||
PoweredMinecart(2);
|
||||
|
||||
private final int id;
|
||||
|
||||
private Type(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
protected EntityMinecart minecart;
|
||||
|
||||
public CraftMinecart(CraftServer server, EntityMinecart entity) {
|
||||
super(server, entity);
|
||||
minecart = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return new Vector(minecart.s, minecart.t, minecart.u);
|
||||
}
|
||||
|
||||
public void setVelocity(Vector vel) {
|
||||
minecart.s = vel.getX();
|
||||
minecart.t = vel.getY();
|
||||
minecart.u = vel.getZ();
|
||||
}
|
||||
|
||||
public LivingEntity getPassenger() {
|
||||
// @TODO: Implement
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return minecart.j == null;
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
minecart.a = damage;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return minecart.a;
|
||||
}
|
||||
|
||||
}
|
17
src/main/java/org/bukkit/craftbukkit/CraftPoweredMinecart.java
Normale Datei
17
src/main/java/org/bukkit/craftbukkit/CraftPoweredMinecart.java
Normale Datei
@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.EntityMinecart;
|
||||
import org.bukkit.PoweredMinecart;
|
||||
|
||||
/**
|
||||
* A powered minecart.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftPoweredMinecart extends CraftMinecart
|
||||
implements PoweredMinecart {
|
||||
public CraftPoweredMinecart(CraftServer server, EntityMinecart entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
}
|
17
src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java
Normale Datei
17
src/main/java/org/bukkit/craftbukkit/CraftStorageMinecart.java
Normale Datei
@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.EntityMinecart;
|
||||
import org.bukkit.StorageMinecart;
|
||||
|
||||
/**
|
||||
* A storage minecart.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftStorageMinecart extends CraftMinecart
|
||||
implements StorageMinecart {
|
||||
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
}
|
16
src/main/java/org/bukkit/craftbukkit/CraftVehicle.java
Normale Datei
16
src/main/java/org/bukkit/craftbukkit/CraftVehicle.java
Normale Datei
@ -0,0 +1,16 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.Entity;
|
||||
|
||||
import org.bukkit.Vehicle;
|
||||
|
||||
/**
|
||||
* A vehicle.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public abstract class CraftVehicle extends CraftEntity implements Vehicle {
|
||||
public CraftVehicle(CraftServer server, Entity entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
}
|
@ -3,15 +3,19 @@ package org.bukkit.craftbukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.EntityMinecart;
|
||||
import java.util.Random;
|
||||
import net.minecraft.server.WorldGenBigTree;
|
||||
import net.minecraft.server.WorldGenTrees;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
import org.bukkit.Arrow;
|
||||
import org.bukkit.Block;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Minecart;
|
||||
import org.bukkit.PoweredMinecart;
|
||||
import org.bukkit.StorageMinecart;
|
||||
import org.bukkit.Vector;
|
||||
import org.bukkit.World;
|
||||
|
||||
@ -88,6 +92,33 @@ public class CraftWorld implements World {
|
||||
return new CraftArrow(world.getServer(), arrow);
|
||||
}
|
||||
|
||||
public Minecart spawnMinecart(Location loc) {
|
||||
EntityMinecart minecart = new EntityMinecart(
|
||||
world,
|
||||
loc.getX(), loc.getY(), loc.getZ(),
|
||||
CraftMinecart.Type.Minecart.getID());
|
||||
world.a(minecart);
|
||||
return new CraftMinecart(world.getServer(), minecart);
|
||||
}
|
||||
|
||||
public StorageMinecart spawnStorageMinecart(Location loc) {
|
||||
EntityMinecart minecart = new EntityMinecart(
|
||||
world,
|
||||
loc.getX(), loc.getY(), loc.getZ(),
|
||||
CraftMinecart.Type.StorageMinecart.getID());
|
||||
world.a(minecart);
|
||||
return new CraftStorageMinecart(world.getServer(), minecart);
|
||||
}
|
||||
|
||||
public PoweredMinecart spawnPoweredMinecart(Location loc) {
|
||||
EntityMinecart minecart = new EntityMinecart(
|
||||
world,
|
||||
loc.getX(), loc.getY(), loc.getZ(),
|
||||
CraftMinecart.Type.PoweredMinecart.getID());
|
||||
world.a(minecart);
|
||||
return new CraftPoweredMinecart(world.getServer(), minecart);
|
||||
}
|
||||
|
||||
public boolean generateTree(Location loc) {
|
||||
WorldGenTrees treeGen = new WorldGenTrees();
|
||||
return treeGen.a(world, rand,
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren