mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 19:55:52 -07:00
Rearchitect PortalCreateEvent to provide more information about the portal
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
||||
super((World) worldserver, gameprofile);
|
||||
playerinteractmanager.player = this;
|
||||
@@ -62,7 +96,49 @@
|
||||
@@ -62,8 +96,50 @@
|
||||
this.advancementDataPlayer = minecraftserver.getPlayerList().f(this);
|
||||
this.K = 1.0F;
|
||||
this.a(worldserver);
|
||||
@@ -62,8 +62,8 @@
|
||||
+ this.displayName = this.getName();
|
||||
+ this.canPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
|
||||
+ // If this is an issue, PRs are welcome
|
||||
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
|
||||
@@ -98,11 +98,12 @@
|
||||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
private void a(WorldServer worldserver) {
|
||||
BlockPosition blockposition = worldserver.getSpawn();
|
||||
|
||||
@@ -131,6 +207,7 @@
|
||||
if (nbttagcompound.hasKeyOfType("recipeBook", 10)) {
|
||||
this.recipeBook.a(nbttagcompound.getCompound("recipeBook"));
|
||||
@@ -133,13 +134,13 @@
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -166,8 +256,34 @@
|
||||
@@ -166,7 +256,33 @@
|
||||
}
|
||||
|
||||
nbttagcompound.set("recipeBook", this.recipeBook.save());
|
||||
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
|
||||
+ public void spawnIn(World world) {
|
||||
+ super.spawnIn(world);
|
||||
@@ -162,12 +163,11 @@
|
||||
+ }
|
||||
+ this.dimension = ((WorldServer) this.world).dimension;
|
||||
+ this.playerInteractManager.a((WorldServer) world);
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public void a(int i) {
|
||||
float f = (float) this.getExpToLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -221,6 +337,11 @@
|
||||
|
||||
@Override
|
||||
@@ -434,7 +434,7 @@
|
||||
|
||||
for (int l = -2; l <= 2; ++l) {
|
||||
for (int i1 = -2; i1 <= 2; ++i1) {
|
||||
@@ -581,11 +823,24 @@
|
||||
@@ -581,11 +823,20 @@
|
||||
int i2 = k + i1 * 0 - l * 1;
|
||||
boolean flag2 = j1 < 0;
|
||||
|
||||
@@ -446,12 +446,8 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.World bworld = worldserver1.getWorld();
|
||||
+ List<org.bukkit.block.Block> bukkitBlocks = Lists.newArrayList();
|
||||
+ for (BlockPosition cpos : blockList.getBlocks()) {
|
||||
+ bukkitBlocks.add(bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()));
|
||||
+ }
|
||||
+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), bworld, org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
|
||||
+
|
||||
+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent(bukkitBlocks, bworld, org.bukkit.event.world.PortalCreateEvent.CreateReason.OBC_DESTINATION);
|
||||
+ this.world.getServer().getPluginManager().callEvent(portalEvent);
|
||||
+ if (!portalEvent.isCancelled()) {
|
||||
+ blockList.updateList();
|
||||
@@ -460,7 +456,7 @@
|
||||
this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F);
|
||||
this.setMot(Vec3D.a);
|
||||
} else if (!worldserver1.getTravelAgent().a(this, f2)) {
|
||||
@@ -618,7 +873,7 @@
|
||||
@@ -618,7 +869,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +465,7 @@
|
||||
DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager();
|
||||
DimensionManager dimensionmanager1 = this.world.worldProvider.getDimensionManager();
|
||||
|
||||
@@ -655,9 +910,16 @@
|
||||
@@ -655,9 +906,16 @@
|
||||
this.activeContainer.c();
|
||||
}
|
||||
|
||||
@@ -488,7 +484,7 @@
|
||||
this.a(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.q.a(this);
|
||||
});
|
||||
@@ -665,6 +927,7 @@
|
||||
@@ -665,6 +923,7 @@
|
||||
|
||||
@Override
|
||||
public void wakeup(boolean flag, boolean flag1, boolean flag2) {
|
||||
@@ -496,7 +492,7 @@
|
||||
if (this.isSleeping()) {
|
||||
this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2));
|
||||
}
|
||||
@@ -752,8 +1015,9 @@
|
||||
@@ -752,8 +1011,9 @@
|
||||
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
||||
}
|
||||
|
||||
@@ -507,7 +503,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -768,6 +1032,17 @@
|
||||
@@ -768,6 +1028,17 @@
|
||||
this.nextContainerCounter();
|
||||
Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this);
|
||||
|
||||
@@ -525,7 +521,7 @@
|
||||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
|
||||
@@ -775,9 +1050,11 @@
|
||||
@@ -775,9 +1046,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -539,7 +535,7 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -790,13 +1067,21 @@
|
||||
@@ -790,13 +1063,21 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
@@ -563,7 +559,7 @@
|
||||
this.activeContainer.addSlotListener(this);
|
||||
}
|
||||
|
||||
@@ -841,6 +1126,11 @@
|
||||
@@ -841,6 +1122,11 @@
|
||||
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
|
||||
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
|
||||
@@ -575,7 +571,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -850,6 +1140,7 @@
|
||||
@@ -850,6 +1136,7 @@
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
@@ -583,7 +579,7 @@
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
|
||||
this.m();
|
||||
}
|
||||
@@ -884,7 +1175,7 @@
|
||||
@@ -884,7 +1171,7 @@
|
||||
@Override
|
||||
public void a(Statistic<?> statistic, int i) {
|
||||
this.serverStatisticManager.b(this, statistic, i);
|
||||
@@ -592,7 +588,7 @@
|
||||
scoreboardscore.addScore(i);
|
||||
});
|
||||
}
|
||||
@@ -892,7 +1183,7 @@
|
||||
@@ -892,7 +1179,7 @@
|
||||
@Override
|
||||
public void a(Statistic<?> statistic) {
|
||||
this.serverStatisticManager.setStatistic(this, statistic, 0);
|
||||
@@ -601,24 +597,25 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -941,7 +1232,16 @@
|
||||
@@ -941,8 +1228,17 @@
|
||||
|
||||
public void triggerHealthUpdate() {
|
||||
this.lastHealthSent = -1.0E8F;
|
||||
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Support multi-line messages
|
||||
+ public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
|
||||
+ for (IChatBaseComponent component : ichatbasecomponent) {
|
||||
+ this.sendMessage(component);
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
@@ -996,12 +1296,14 @@
|
||||
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT));
|
||||
@@ -996,12 +1292,14 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastHealthSent = -1.0F;
|
||||
this.lastFoodSent = -1;
|
||||
@@ -634,7 +631,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1063,6 +1365,18 @@
|
||||
@@ -1063,6 +1361,18 @@
|
||||
|
||||
@Override
|
||||
public void a(EnumGamemode enumgamemode) {
|
||||
@@ -653,7 +650,7 @@
|
||||
this.playerInteractManager.setGameMode(enumgamemode);
|
||||
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
|
||||
if (enumgamemode == EnumGamemode.SPECTATOR) {
|
||||
@@ -1113,6 +1427,17 @@
|
||||
@@ -1113,6 +1423,17 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInSettings packetplayinsettings) {
|
||||
@@ -671,7 +668,7 @@
|
||||
this.locale = packetplayinsettings.b();
|
||||
this.ck = packetplayinsettings.d();
|
||||
this.cl = packetplayinsettings.e();
|
||||
@@ -1149,13 +1474,13 @@
|
||||
@@ -1149,13 +1470,13 @@
|
||||
if (entity instanceof EntityHuman) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] { entity.getId()}));
|
||||
} else {
|
||||
@@ -687,7 +684,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1179,7 +1504,7 @@
|
||||
@@ -1179,7 +1500,7 @@
|
||||
this.spectatedEntity = (Entity) (entity == null ? this : entity);
|
||||
if (entity1 != this.spectatedEntity) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
|
||||
@@ -696,7 +693,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1208,7 +1533,7 @@
|
||||
@@ -1208,7 +1529,7 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getPlayerListName() {
|
||||
@@ -705,7 +702,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1226,21 +1551,33 @@
|
||||
@@ -1226,21 +1547,33 @@
|
||||
}
|
||||
|
||||
public void J() {
|
||||
@@ -739,7 +736,7 @@
|
||||
if (worldserver == this.world) {
|
||||
this.playerConnection.a(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
@@ -1263,6 +1600,9 @@
|
||||
@@ -1263,6 +1596,9 @@
|
||||
this.server.getPlayerList().a(this, worldserver);
|
||||
this.server.getPlayerList().updateClient(this);
|
||||
}
|
||||
@@ -749,7 +746,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1314,4 +1654,144 @@
|
||||
@@ -1314,4 +1650,144 @@
|
||||
return entityitem;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user