Update to Minecraft 1.20.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-09-22 02:40:00 +10:00
parent 193398c0ff
commit 8a3c8cfcd4
238 changed files with 2448 additions and 2344 deletions

View File

@@ -1,11 +1,10 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -124,8 +124,66 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
@@ -125,8 +125,65 @@
import org.joml.Vector3f;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.core.Position;
+import net.minecraft.world.level.dimension.WorldDimension;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
@@ -67,7 +66,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -240,6 +298,25 @@
@@ -241,6 +298,25 @@
public boolean hasVisualFire;
@Nullable
private IBlockData feetBlockState;
@@ -93,7 +92,7 @@
public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -373,6 +450,12 @@
@@ -374,6 +450,12 @@
public void onClientRemoval() {}
public void setPose(EntityPose entitypose) {
@@ -106,7 +105,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose);
}
@@ -397,6 +480,33 @@
@@ -398,6 +480,33 @@
}
protected void setRot(float f, float f1) {
@@ -140,7 +139,7 @@
this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F);
}
@@ -438,6 +548,15 @@
@@ -439,6 +548,15 @@
this.baseTick();
}
@@ -156,7 +155,7 @@
public void baseTick() {
this.level().getProfiler().push("entityBaseTick");
this.feetBlockState = null;
@@ -452,7 +571,7 @@
@@ -453,7 +571,7 @@
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@@ -165,7 +164,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -487,6 +606,10 @@
@@ -488,6 +606,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@@ -176,7 +175,7 @@
}
this.checkBelowWorld();
@@ -538,15 +661,48 @@
@@ -539,15 +661,48 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@@ -226,7 +225,7 @@
int j = i * 20;
if (this instanceof EntityLiving) {
@@ -697,6 +853,28 @@
@@ -698,6 +853,28 @@
block.updateEntityAfterFallOn(this.level(), this);
}
@@ -255,7 +254,7 @@
if (this.onGround()) {
block.stepOn(this.level(), blockposition, iblockdata, this);
}
@@ -1024,6 +1202,20 @@
@@ -1025,6 +1202,20 @@
return SoundEffects.GENERIC_SPLASH;
}
@@ -276,7 +275,7 @@
protected void checkInsideBlocks() {
AxisAlignedBB axisalignedbb = this.getBoundingBox();
BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D);
@@ -1430,6 +1622,7 @@
@@ -1439,6 +1630,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@@ -284,7 +283,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1624,6 +1817,12 @@
@@ -1633,6 +1825,12 @@
return false;
}
@@ -297,7 +296,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1657,7 +1856,7 @@
@@ -1666,7 +1864,7 @@
} else {
String s = this.getEncodeId();
@@ -306,7 +305,7 @@
return false;
} else {
nbttagcompound.putString("id", s);
@@ -1682,6 +1881,18 @@
@@ -1691,6 +1889,18 @@
Vec3D vec3d = this.getDeltaMovement();
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
@@ -325,7 +324,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1690,6 +1901,25 @@
@@ -1699,6 +1909,25 @@
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
nbttagcompound.putUUID("UUID", this.getUUID());
@@ -351,7 +350,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1757,6 +1987,11 @@
@@ -1766,6 +1995,11 @@
}
}
@@ -363,7 +362,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1840,6 +2075,45 @@
@@ -1849,6 +2083,45 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@@ -409,7 +408,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1915,9 +2189,22 @@
@@ -1924,9 +2197,22 @@
} else if (this.level().isClientSide) {
return null;
} else {
@@ -432,7 +431,7 @@
this.level().addFreshEntity(entityitem);
return entityitem;
}
@@ -2007,6 +2294,18 @@
@@ -2024,6 +2310,18 @@
if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@@ -451,7 +450,7 @@
if (this.isPassenger()) {
this.stopRiding();
}
@@ -2044,7 +2343,7 @@
@@ -2057,7 +2355,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@@ -460,7 +459,7 @@
}
}
@@ -2075,10 +2374,29 @@
@@ -2088,10 +2386,29 @@
}
}
@@ -491,7 +490,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -2090,6 +2408,7 @@
@@ -2103,6 +2420,7 @@
entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
}
@@ -499,7 +498,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2156,14 +2475,20 @@
@@ -2189,14 +2507,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@@ -523,7 +522,7 @@
this.level().getProfiler().pop();
}
@@ -2283,6 +2608,13 @@
@@ -2320,6 +2644,13 @@
}
public void setSwimming(boolean flag) {
@@ -537,7 +536,7 @@
this.setSharedFlag(4, flag);
}
@@ -2332,8 +2664,12 @@
@@ -2369,8 +2700,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@@ -551,7 +550,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2352,7 +2688,7 @@
@@ -2389,7 +2724,7 @@
}
public int getMaxAirSupply() {
@@ -560,7 +559,7 @@
}
public int getAirSupply() {
@@ -2360,7 +2696,18 @@
@@ -2397,7 +2732,18 @@
}
public void setAirSupply(int i) {
@@ -580,7 +579,7 @@
}
public int getTicksFrozen() {
@@ -2387,11 +2734,41 @@
@@ -2424,11 +2770,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@@ -624,7 +623,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2556,15 +2933,38 @@
@@ -2593,15 +2969,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@@ -633,7 +632,7 @@
+ }
+
+ @Nullable
+ public Entity teleportTo(WorldServer worldserver, Position location) {
+ public Entity teleportTo(WorldServer worldserver, Vec3D location) {
+ // CraftBukkit end
if (this.level() instanceof WorldServer && !this.isRemoved()) {
this.level().getProfiler().push("changeDimension");
@@ -665,7 +664,7 @@
this.level().getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2573,9 +2973,17 @@
@@ -2610,9 +3009,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@@ -685,7 +684,7 @@
}
this.removeAfterChangingDimensions();
@@ -2596,20 +3004,34 @@
@@ -2633,20 +3040,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@@ -711,7 +710,7 @@
double d0 = DimensionManager.getTeleportationScale(this.level().dimensionType(), worldserver.dimensionType());
BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
+ // CraftBukkit start
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Vec3D(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
+ if (event == null) {
+ return null;
+ }
@@ -725,7 +724,7 @@
IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2626,8 +3048,8 @@
@@ -2663,8 +3084,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@@ -736,12 +735,12 @@
}
} else {
BlockPosition blockposition1;
@@ -2637,8 +3059,14 @@
@@ -2674,8 +3095,14 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
+ // CraftBukkit start
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Vec3D(blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
+ if (event == null) {
+ return null;
+ }
@@ -752,14 +751,14 @@
}
}
@@ -2646,8 +3074,23 @@
@@ -2683,8 +3110,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) {
- return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder);
+ // CraftBukkit start
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
+ Location enter = bukkitEntity.getLocation();
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld());
@@ -778,7 +777,7 @@
}
public boolean canChangeDimensions() {
@@ -2767,6 +3210,12 @@
@@ -2804,6 +3246,12 @@
}
}
@@ -791,7 +790,7 @@
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
@@ -2901,7 +3350,26 @@
@@ -2929,7 +3377,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@@ -819,7 +818,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -3212,6 +3680,11 @@
@@ -3240,6 +3707,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}