Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/vehicle/EntityBoat.java
+++ b/net/minecraft/world/entity/vehicle/EntityBoat.java
@@ -48,6 +48,15 @@
@@ -52,6 +52,15 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -15,10 +15,10 @@
+
public class EntityBoat extends Entity {
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b);
@@ -82,6 +91,14 @@
private float aD;
private float aE;
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.INT);
@@ -92,6 +101,14 @@
private float bubbleAngle;
private float bubbleAngleO;
+ // CraftBukkit start
+ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable.
@@ -30,17 +30,17 @@
+
public EntityBoat(EntityTypes<? extends EntityBoat> entitytypes, World world) {
super(entitytypes, world);
this.ah = new float[2];
@@ -152,6 +169,19 @@
this.paddlePositions = new float[2];
@@ -161,6 +178,19 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else if (!this.world.isClientSide && !this.dead) {
} else if (!this.level.isClientSide && !this.isRemoved()) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
+
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
@@ -48,33 +48,33 @@
+ // f = event.getDamage(); // TODO Why don't we do this?
+ // CraftBukkit end
+
this.c(-this.o());
this.c(-this.p());
this.b(10);
this.setDamage(this.getDamage() + f * 10.0F);
@@ -159,6 +189,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
@@ -169,6 +199,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
if (flag || this.getDamage() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ this.level.getServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled()) {
+ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
+ return true;
+ }
+ // CraftBukkit end
if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
this.a((IMaterial) this.g());
if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.a((IMaterial) this.h());
}
@@ -193,9 +232,29 @@
@@ -204,9 +243,29 @@
public void collide(Entity entity) {
if (entity instanceof EntityBoat) {
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
+ // CraftBukkit start
+ if (!this.isSameVehicle(entity)) {
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
@@ -87,7 +87,7 @@
+ // CraftBukkit start
+ if (!this.isSameVehicle(entity)) {
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
@@ -97,23 +97,23 @@
super.collide(entity);
}
@@ -229,6 +288,7 @@
@@ -257,6 +316,7 @@
return this.getDirection().g();
}
+ private Location lastLocation; // CraftBukkit
@Override
public void tick() {
this.ay = this.ax;
@@ -269,6 +329,22 @@
this.setMot(Vec3D.ORIGIN);
this.oldStatus = this.status;
@@ -297,6 +357,22 @@
this.setMot(Vec3D.ZERO);
}
+ // CraftBukkit start
+ org.bukkit.Server server = this.world.getServer();
+ org.bukkit.World bworld = this.world.getWorld();
+ org.bukkit.Server server = this.level.getServer();
+ org.bukkit.World bworld = this.level.getWorld();
+
+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
@@ -125,22 +125,22 @@
+ lastLocation = vehicle.getLocation();
+ // CraftBukkit end
+
this.q();
this.r();
for (int i = 0; i <= 1; ++i) {
@@ -753,6 +829,11 @@
@@ -801,6 +877,11 @@
this.b(this.fallDistance, 1.0F);
if (!this.world.isClientSide && !this.dead) {
this.a(this.fallDistance, 1.0F, DamageSource.FALL);
if (!this.level.isClientSide && !this.isRemoved()) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ this.level.getServer().getPluginManager().callEvent(destroyEvent);
+ if (!destroyEvent.isCancelled()) {
this.die();
if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
this.killEntity();
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
int i;
@@ -766,6 +847,7 @@
@@ -814,6 +895,7 @@
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
@@ -48,6 +48,15 @@
@@ -50,6 +50,15 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -15,19 +15,19 @@
+
public abstract class EntityMinecartAbstract extends Entity {
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b);
@@ -58,7 +67,7 @@
private static final DataWatcherObject<Boolean> g = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.i);
private static final ImmutableMap<EntityPose, ImmutableList<Integer>> ag = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1));
private boolean ah;
- private static final Map<BlockPropertyTrackPosition, Pair<BaseBlockPosition, BaseBlockPosition>> ai = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> {
+ private static final Map<BlockPropertyTrackPosition, Pair<BaseBlockPosition, BaseBlockPosition>> ai = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.INT);
@@ -61,7 +70,7 @@
private static final ImmutableMap<EntityPose, ImmutableList<Integer>> POSE_DISMOUNT_HEIGHTS = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1));
protected static final float WATER_SLOWDOWN_FACTOR = 0.95F;
private boolean flipped;
- private static final Map<BlockPropertyTrackPosition, Pair<BaseBlockPosition, BaseBlockPosition>> EXITS = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> {
+ private static final Map<BlockPropertyTrackPosition, Pair<BaseBlockPosition, BaseBlockPosition>> EXITS = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error
BaseBlockPosition baseblockposition = EnumDirection.WEST.p();
BaseBlockPosition baseblockposition1 = EnumDirection.EAST.p();
BaseBlockPosition baseblockposition2 = EnumDirection.NORTH.p();
@@ -86,6 +95,17 @@
private double an;
private double ao;
@@ -92,6 +101,17 @@
private double lyd;
private double lzd;
+ // CraftBukkit start
+ public boolean slowWhenEmpty = true;
@@ -42,8 +42,8 @@
+
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.i = true;
@@ -213,6 +233,19 @@
this.blocksBuilding = true;
@@ -218,6 +238,19 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else {
@@ -52,7 +52,7 @@
+ org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
+
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
@@ -60,16 +60,16 @@
+
+ f = (float) event.getDamage();
+ // CraftBukkit end
this.d(-this.n());
this.d(-this.o());
this.c(10);
this.velocityChanged();
@@ -220,6 +253,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
@@ -226,6 +259,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
if (flag || this.getDamage() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ this.level.getServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled()) {
+ this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
@@ -79,7 +79,7 @@
this.ejectPassengers();
if (flag && !this.hasCustomName()) {
this.die();
@@ -272,6 +314,14 @@
@@ -285,6 +327,14 @@
@Override
public void tick() {
@@ -87,48 +87,48 @@
+ double prevX = this.locX();
+ double prevY = this.locY();
+ double prevZ = this.locZ();
+ float prevYaw = this.yaw;
+ float prevPitch = this.pitch;
+ float prevYaw = this.getYRot();
+ float prevPitch = this.getXRot();
+ // CraftBukkit end
+
if (this.getType() > 0) {
this.c(this.getType() - 1);
}
@@ -284,7 +334,7 @@
this.an();
@@ -294,7 +344,7 @@
}
this.aj();
- this.doPortalTick();
+ // this.doPortalTick(); // CraftBukkit - handled in postTick
if (this.world.isClientSide) {
if (this.aj > 0) {
double d0 = this.locX() + (this.ak - this.locX()) / (double) this.aj;
@@ -347,6 +397,18 @@
double d0;
if (this.level.isClientSide) {
@@ -360,6 +410,18 @@
}
this.setYawPitch(this.yaw, this.pitch);
this.setYawPitch(this.getYRot(), this.getXRot());
+ // CraftBukkit start
+ org.bukkit.World bworld = this.world.getWorld();
+ org.bukkit.World bworld = this.level.getWorld();
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
+ Location to = new Location(bworld, this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+ this.level.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+
+ if (!from.equals(to)) {
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
+ this.level.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
+ }
+ // CraftBukkit end
if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && c(this.getMot()) > 0.01D) {
List<Entity> list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this));
if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getMot().i() > 0.01D) {
List<Entity> list = this.level.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this));
@@ -355,8 +417,26 @@
@@ -368,8 +430,26 @@
Entity entity = (Entity) list.get(l);
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
+ // CraftBukkit start
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
+ this.level.getServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ continue;
@@ -139,7 +139,7 @@
+ // CraftBukkit start
+ if (!this.isSameVehicle(entity)) {
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
+ this.level.getServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ continue;
@@ -149,13 +149,13 @@
entity.collide(this);
}
}
@@ -368,6 +448,14 @@
@@ -381,6 +461,14 @@
Entity entity1 = (Entity) iterator.next();
if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) {
if (!this.u(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) {
+ // CraftBukkit start
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
+ this.level.getServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ continue;
@@ -164,16 +164,16 @@
entity1.collide(this);
}
}
@@ -384,7 +472,7 @@
@@ -397,7 +485,7 @@
}
protected double getMaxSpeed() {
- return 0.4D;
+ return this.maxSpeed; // CraftBukkit
- return (this.isInWater() ? 4.0D : 8.0D) / 20.0D;
+ return (this.isInWater() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit
}
public void a(int i, int j, int k, boolean flag) {}
@@ -395,12 +483,16 @@
@@ -408,12 +496,16 @@
this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0));
if (this.onGround) {
@@ -192,22 +192,22 @@
}
}
@@ -587,7 +679,7 @@
@@ -604,7 +696,7 @@
}
protected void decelerate() {
- double d0 = this.isVehicle() ? 0.997D : 0.96D;
+ double d0 = this.isVehicle() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty
Vec3D vec3d = this.getMot();
this.setMot(this.getMot().d(d0, 0.0D, d0));
}
@@ -670,6 +762,14 @@
if (!this.world.isClientSide) {
if (!entity.noclip && !this.noclip) {
if (!this.w(entity)) {
vec3d = vec3d.d(d0, 0.0D, d0);
@@ -743,6 +835,14 @@
if (!this.level.isClientSide) {
if (!entity.noPhysics && !this.noPhysics) {
if (!this.u(entity)) {
+ // CraftBukkit start
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
+ this.level.getServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ return;
@@ -216,7 +216,7 @@
double d0 = entity.locX() - this.locX();
double d1 = entity.locZ() - this.locZ();
double d2 = d0 * d0 + d1 * d1;
@@ -805,4 +905,26 @@
@@ -922,4 +1022,26 @@
private EnumMinecartType() {}
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java
@@ -120,5 +120,12 @@
@@ -131,5 +131,12 @@
public CommandListenerWrapper getWrapper() {
return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.bi(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this);
return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.br(), this.e(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.e().getMinecraftServer(), EntityMinecartCommandBlock.this);
}
+
+ // CraftBukkit start

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java
@@ -29,6 +29,14 @@
@@ -31,6 +31,14 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameterSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
@@ -14,8 +14,8 @@
+
public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements IInventory, ITileInventory {
private NonNullList<ItemStack> items;
@@ -37,15 +45,56 @@
private NonNullList<ItemStack> itemStacks;
@@ -38,14 +46,55 @@
public MinecraftKey lootTable;
public long lootTableSeed;
@@ -24,7 +24,7 @@
+ private int maxStack = MAX_STACK;
+
+ public List<ItemStack> getContents() {
+ return this.items;
+ return this.itemStacks;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
@@ -62,15 +62,14 @@
+
protected EntityMinecartContainer(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
- this.items = NonNullList.a(36, ItemStack.b);
+ this.items = NonNullList.a(this.getSize(), ItemStack.b); // CraftBukkit - SPIGOT-3513
this.c = true;
- this.itemStacks = NonNullList.a(36, ItemStack.EMPTY);
+ this.itemStacks = NonNullList.a(this.getSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
}
protected EntityMinecartContainer(EntityTypes<?> entitytypes, double d0, double d1, double d2, World world) {
super(entitytypes, world, d0, d1, d2);
- this.items = NonNullList.a(36, ItemStack.b);
+ this.items = NonNullList.a(this.getSize(), ItemStack.b); // CraftBukkit - SPIGOT-3513
this.c = true;
- this.itemStacks = NonNullList.a(36, ItemStack.EMPTY);
+ this.itemStacks = NonNullList.a(this.getSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
}
@Override