mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-12 15:08:27 +02:00
Rearchitect PortalCreateEvent to provide more information about the portal
This commit is contained in:
parent
e8c929356e
commit
78616513e8
@ -1,11 +1,12 @@
|
||||
--- a/net/minecraft/server/BlockPortal.java
|
||||
+++ b/net/minecraft/server/BlockPortal.java
|
||||
@@ -4,6 +4,12 @@
|
||||
@@ -4,6 +4,13 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
+import org.bukkit.event.world.PortalCreateEvent;
|
||||
+// CraftBukkit end
|
||||
@ -13,7 +14,7 @@
|
||||
public class BlockPortal extends Block {
|
||||
|
||||
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.D;
|
||||
@@ -34,7 +40,8 @@
|
||||
@@ -34,7 +41,8 @@
|
||||
}
|
||||
|
||||
if (world.getType(blockposition).a((IBlockAccess) world, blockposition, EntityTypes.ZOMBIE_PIGMAN)) {
|
||||
@ -23,7 +24,7 @@
|
||||
|
||||
if (entity != null) {
|
||||
entity.portalCooldown = entity.aW();
|
||||
@@ -48,8 +55,10 @@
|
||||
@@ -48,8 +56,10 @@
|
||||
BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition);
|
||||
|
||||
if (blockportal_shape != null) {
|
||||
@ -36,7 +37,7 @@
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -85,6 +94,10 @@
|
||||
@@ -85,6 +95,10 @@
|
||||
@Override
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
|
||||
@ -47,15 +48,15 @@
|
||||
entity.c(blockposition);
|
||||
}
|
||||
|
||||
@@ -177,6 +190,7 @@
|
||||
@@ -177,6 +191,7 @@
|
||||
private BlockPosition position;
|
||||
private int height;
|
||||
private int width;
|
||||
+ java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit - add field
|
||||
+ java.util.List<org.bukkit.block.BlockState> blocks = new java.util.ArrayList<org.bukkit.block.BlockState>(); // CraftBukkit - add field
|
||||
|
||||
public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
|
||||
this.a = generatoraccess;
|
||||
@@ -235,6 +249,9 @@
|
||||
@@ -235,6 +250,9 @@
|
||||
}
|
||||
|
||||
protected int c() {
|
||||
@ -65,14 +66,14 @@
|
||||
int i;
|
||||
|
||||
label56:
|
||||
@@ -257,11 +274,21 @@
|
||||
@@ -257,11 +275,21 @@
|
||||
block = this.a.getType(blockposition.shift(this.d)).getBlock();
|
||||
if (block != Blocks.OBSIDIAN) {
|
||||
break label56;
|
||||
+ // CraftBukkit start - add the block to our list
|
||||
+ } else {
|
||||
+ BlockPosition pos = blockposition.shift(this.d);
|
||||
+ blocks.add(CraftBlock.at(this.a, pos));
|
||||
+ blocks.add(CraftBlock.at(this.a, pos).getState());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else if (i == this.width - 1) {
|
||||
@ -82,24 +83,24 @@
|
||||
+ // CraftBukkit start - add the block to our list
|
||||
+ } else {
|
||||
+ BlockPosition pos = blockposition.shift(this.c);
|
||||
+ blocks.add(CraftBlock.at(this.a, pos));
|
||||
+ blocks.add(CraftBlock.at(this.a, pos).getState());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,6 +298,11 @@
|
||||
@@ -271,6 +299,11 @@
|
||||
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
|
||||
this.height = 0;
|
||||
break;
|
||||
+ // CraftBukkit start - add the block to our list
|
||||
+ } else {
|
||||
+ BlockPosition pos = this.position.shift(this.c, i).up(this.height);
|
||||
+ blocks.add(CraftBlock.at(this.a, pos));
|
||||
+ blocks.add(CraftBlock.at(this.a, pos).getState());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +326,27 @@
|
||||
@@ -294,7 +327,29 @@
|
||||
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
|
||||
}
|
||||
|
||||
@ -114,7 +115,9 @@
|
||||
+
|
||||
+ for (int j = 0; j < this.height; ++j) {
|
||||
+ BlockPosition pos = blockposition.up(j);
|
||||
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
||||
+ CraftBlockState state = CraftBlockState.getBlockState(this.a.getMinecraftWorld(), pos, 18);
|
||||
+ state.setData((IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.b));
|
||||
+ blocks.add(state);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -128,7 +131,7 @@
|
||||
for (int i = 0; i < this.width; ++i) {
|
||||
BlockPosition blockposition = this.position.shift(this.c, i);
|
||||
|
||||
@@ -303,6 +355,7 @@
|
||||
@@ -303,6 +358,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,10 +292,23 @@
|
||||
@@ -291,10 +292,19 @@
|
||||
for (i3 = 0; i3 < 2; ++i3) {
|
||||
for (l2 = 0; l2 < 3; ++l2) {
|
||||
blockposition_mutableblockposition.d(i5 + i3 * k5, j5 + l2, j2 + i3 * l5);
|
||||
@ -37,12 +37,8 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.World bworld = this.world.getWorld();
|
||||
+ java.util.List<org.bukkit.block.Block> bukkitBlocks = com.google.common.collect.Lists.newArrayList();
|
||||
+ for (BlockPosition cpos : blockList.getBlocks()) {
|
||||
+ bukkitBlocks.add(bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()));
|
||||
+ }
|
||||
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blockList.getList(), bworld, org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR);
|
||||
+
|
||||
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent(bukkitBlocks, bworld, org.bukkit.event.world.PortalCreateEvent.CreateReason.OBC_DESTINATION);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ blockList.updateList();
|
||||
|
Loading…
Reference in New Issue
Block a user