mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 03:25:15 +01:00
Handle the newly refactored minecarts.
This commit is contained in:
parent
b2c72b968e
commit
2cb9cbf05c
@ -1,52 +1,54 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.*;
|
||||
import org.bukkit.craftbukkit.metadata.BlockMetadataStore;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.world.SpawnChangeEvent;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.entity.*;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.craftbukkit.metadata.BlockMetadataStore;
|
||||
import org.bukkit.craftbukkit.util.LongHash;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.entity.minecart.HopperMinecart;
|
||||
import org.bukkit.entity.minecart.PoweredMinecart;
|
||||
import org.bukkit.entity.minecart.SpawnerMinecart;
|
||||
import org.bukkit.entity.minecart.StorageMinecart;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.world.SpawnChangeEvent;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftWorld implements World {
|
||||
public static final int CUSTOM_DIMENSION_OFFSET = 10;
|
||||
@ -252,7 +254,6 @@ public class CraftWorld implements World {
|
||||
return chunk != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int x, int z) {
|
||||
if (chunk != null) {
|
||||
world.chunkProviderServer.chunks.put(LongHash.toLong(x, z), chunk);
|
||||
@ -864,13 +865,13 @@ public class CraftWorld implements World {
|
||||
entity = new EntityMinecartFurnace(world, x, y, z);
|
||||
} else if (StorageMinecart.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityMinecartChest(world, x, y, z);
|
||||
} else if (MinecartTNT.class.isAssignableFrom(clazz)) {
|
||||
} else if (ExplosiveMinecart.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityMinecartTNT(world, x, y, z);
|
||||
} else if (MinecartHopper.class.isAssignableFrom(clazz)) {
|
||||
} else if (HopperMinecart.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityMinecartHopper(world, x, y, z);
|
||||
} else if (MinecartMobSpawner.class.isAssignableFrom(clazz)) {
|
||||
} else if (SpawnerMinecart.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityMinecartMobSpawner(world, x, y, z);
|
||||
} else {
|
||||
} else { // Default to rideable minecart for pre-rideable compatibility
|
||||
entity = new EntityMinecartRideable(world, x, y, z);
|
||||
}
|
||||
} else if (EnderSignal.class.isAssignableFrom(clazz)) {
|
||||
|
@ -137,12 +137,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else { return new CraftWeather(server, (EntityWeather) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityMinecartAbstract) {
|
||||
if (entity instanceof EntityMinecartFurnace) { return new CraftPoweredMinecart(server, (EntityMinecartFurnace) entity); }
|
||||
else if (entity instanceof EntityMinecartChest) { return new CraftStorageMinecart(server, (EntityMinecartChest) entity); }
|
||||
if (entity instanceof EntityMinecartFurnace) { return new CraftMinecartFurnace(server, (EntityMinecartFurnace) entity); }
|
||||
else if (entity instanceof EntityMinecartChest) { return new CraftMinecartChest(server, (EntityMinecartChest) entity); }
|
||||
else if (entity instanceof EntityMinecartTNT) { return new CraftMinecartTNT(server, (EntityMinecartTNT) entity); }
|
||||
else if (entity instanceof EntityMinecartHopper) { return new CraftMinecartHopper(server, (EntityMinecartHopper) entity); }
|
||||
else if (entity instanceof EntityMinecartMobSpawner) { return new CraftMinecartMobSpawner(server, (EntityMinecartMobSpawner) entity); }
|
||||
else { return new CraftMinecart(server, (EntityMinecartRideable) entity); }
|
||||
else if (entity instanceof EntityMinecartRideable) { return new CraftMinecartRideable(server, (EntityMinecartRideable) entity); }
|
||||
} else if (entity instanceof EntityHanging) {
|
||||
if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); }
|
||||
else if (entity instanceof EntityItemFrame) { return new CraftItemFrame(server, (EntityItemFrame) entity); }
|
||||
@ -151,7 +151,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); }
|
||||
else if (entity instanceof EntityFireworks) { return new CraftFirework(server, (EntityFireworks) entity); }
|
||||
|
||||
throw new IllegalArgumentException("Unknown entity");
|
||||
throw new AssertionError("Unknown entity " + entity == null ? null : entity.getClass());
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityMinecartAbstract;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
public CraftMinecart(CraftServer server, EntityMinecartAbstract entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
@ -57,13 +57,4 @@ public class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
public EntityMinecartAbstract getHandle() {
|
||||
return (EntityMinecartAbstract) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftMinecart";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART;
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.StorageMinecart;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart {
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CraftMinecartChest extends CraftMinecart implements StorageMinecart {
|
||||
private final CraftInventory inventory;
|
||||
|
||||
public CraftStorageMinecart(CraftServer server, EntityMinecartChest entity) {
|
||||
public CraftMinecartChest(CraftServer server, EntityMinecartChest entity) {
|
||||
super(server, entity);
|
||||
inventory = new CraftInventory(entity);
|
||||
}
|
||||
@ -22,7 +23,7 @@ public class CraftStorageMinecart extends CraftMinecart implements StorageMineca
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftStorageMinecart{" + "inventory=" + inventory + '}';
|
||||
return "CraftMinecartChest{" + "inventory=" + inventory + '}';
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
@ -1,19 +1,20 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftMinecart;
|
||||
import net.minecraft.server.EntityMinecartFurnace;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.PoweredMinecart;
|
||||
|
||||
public class CraftPoweredMinecart extends CraftMinecart implements PoweredMinecart {
|
||||
public CraftPoweredMinecart(CraftServer server, EntityMinecartFurnace entity) {
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CraftMinecartFurnace extends CraftMinecart implements PoweredMinecart {
|
||||
public CraftMinecartFurnace(CraftServer server, EntityMinecartFurnace entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftPoweredMinecart";
|
||||
return "CraftMinecartFurnace";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
@ -1,15 +1,21 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityMinecartHopper;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.MinecartHopper;
|
||||
import org.bukkit.entity.minecart.HopperMinecart;
|
||||
|
||||
final class CraftMinecartHopper extends CraftMinecart implements MinecartHopper {
|
||||
final class CraftMinecartHopper extends CraftMinecart implements HopperMinecart {
|
||||
CraftMinecartHopper(CraftServer server, EntityMinecartHopper entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftMinecartHopper";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_HOPPER;
|
||||
}
|
||||
|
@ -1,15 +1,21 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityMinecartMobSpawner;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.MinecartMobSpawner;
|
||||
import org.bukkit.entity.minecart.SpawnerMinecart;
|
||||
|
||||
final class CraftMinecartMobSpawner extends CraftMinecart implements MinecartMobSpawner {
|
||||
final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMinecart {
|
||||
CraftMinecartMobSpawner(CraftServer server, EntityMinecartMobSpawner entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftMinecartMobSpawner";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_MOB_SPAWNER;
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityMinecartAbstract;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.minecart.RideableMinecart;
|
||||
|
||||
public class CraftMinecartRideable extends CraftMinecart implements RideableMinecart {
|
||||
public CraftMinecartRideable(CraftServer server, EntityMinecartAbstract entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftMinecartRideable";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART;
|
||||
}
|
||||
}
|
@ -1,11 +1,22 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityMinecartTNT;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.MinecartTNT;
|
||||
|
||||
final class CraftMinecartTNT extends CraftMinecart implements MinecartTNT {
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
|
||||
final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart {
|
||||
CraftMinecartTNT(CraftServer server, EntityMinecartTNT entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftMinecartTNT";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_TNT;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user