Update to Minecraft 1.18-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-22 09:00:00 +11:00
parent a852b81a69
commit 43702a9e10
700 changed files with 10286 additions and 10098 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
+++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
@@ -22,6 +22,11 @@
@@ -21,6 +21,11 @@
import net.minecraft.world.level.block.BlockFireAbstract;
import net.minecraft.world.level.dimension.end.EnderDragonBattle;
@@ -11,21 +11,21 @@
+
public class EntityEnderCrystal extends Entity {
private static final DataWatcherObject<Optional<BlockPosition>> DATA_BEAM_TARGET = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS);
@@ -57,7 +62,11 @@
BlockPosition blockposition = this.getChunkCoordinates();
private static final DataWatcherObject<Optional<BlockPosition>> DATA_BEAM_TARGET = DataWatcher.defineId(EntityEnderCrystal.class, DataWatcherRegistry.OPTIONAL_BLOCK_POS);
@@ -56,7 +61,11 @@
BlockPosition blockposition = this.blockPosition();
if (((WorldServer) this.level).getDragonBattle() != null && this.level.getType(blockposition).isAir()) {
- this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition));
if (((WorldServer) this.level).dragonFight() != null && this.level.getBlockState(blockposition).isAir()) {
- this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition));
+ // CraftBukkit start
+ if (!CraftEventFactory.callBlockIgniteEvent(this.level, blockposition, this).isCancelled()) {
+ this.level.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.level, blockposition));
+ this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition));
+ }
+ // CraftBukkit end
}
}
@@ -97,9 +106,22 @@
@@ -96,9 +105,22 @@
return false;
} else {
if (!this.isRemoved() && !this.level.isClientSide) {
@@ -34,9 +34,9 @@
+ return false;
+ }
+ // CraftBukkit end
this.a(Entity.RemovalReason.KILLED);
this.remove(Entity.RemovalReason.KILLED);
if (!damagesource.isExplosion()) {
- this.level.explode((Entity) null, this.locX(), this.locY(), this.locZ(), 6.0F, Explosion.Effect.DESTROY);
- this.level.explode((Entity) null, this.getX(), this.getY(), this.getZ(), 6.0F, Explosion.Effect.DESTROY);
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
@@ -44,8 +44,8 @@
+ this.unsetRemoved();
+ return false;
+ }
+ this.level.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY);
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY);
+ // CraftBukkit end
}
this.a(damagesource);
this.onDestroyedBy(damagesource);

View File

@@ -29,13 +29,13 @@
super(EntityTypes.ENDER_DRAGON, world);
@@ -236,7 +249,7 @@
Vec3D vec3d1 = idragoncontroller.g();
Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation();
- if (vec3d1 != null) {
+ if (vec3d1 != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVERING) { // CraftBukkit - Don't move when hovering
d0 = vec3d1.x - this.locX();
d1 = vec3d1.y - this.locY();
d2 = vec3d1.z - this.locZ();
+ if (vec3d1 != null && idragoncontroller.getPhase() != DragonControllerPhase.HOVERING) { // CraftBukkit - Don't move when hovering
d0 = vec3d1.x - this.getX();
d1 = vec3d1.y - this.getY();
d2 = vec3d1.z - this.getZ();
@@ -378,7 +391,14 @@
if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null;
@@ -65,10 +65,10 @@
@@ -462,7 +485,11 @@
if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) {
if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.a((Tag) TagsBlock.DRAGON_IMMUNE)) {
- flag1 = this.level.a(blockposition, false) || flag1;
if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is((Tag) TagsBlock.DRAGON_IMMUNE)) {
- flag1 = this.level.removeBlock(blockposition, false) || flag1;
+ // CraftBukkit start - Add blocks to list rather than destroying them
+ // flag1 = this.level.a(blockposition, false) || flag1;
+ // flag1 = this.level.removeBlock(blockposition, false) || flag1;
+ flag1 = true;
+ destroyedBlocks.add(CraftBlock.at(level, blockposition));
+ // CraftBukkit end
@@ -95,7 +95,7 @@
+ } else if (event.getYield() == 0F) {
+ // Yield zero ==> no drops
+ for (org.bukkit.block.Block block : event.blockList()) {
+ this.level.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false);
+ this.level.removeBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()), false);
+ }
+ } else {
+ for (org.bukkit.block.Block block : event.blockList()) {
@@ -108,18 +108,18 @@
+ BlockPosition blockposition = craftBlock.getPosition();
+
+ Block nmsBlock = craftBlock.getNMS().getBlock();
+ if (nmsBlock.a(explosionSource)) {
+ TileEntity tileentity = craftBlock.getNMS().isTileEntity() ? this.level.getTileEntity(blockposition) : null;
+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).a(this.level.random).set(LootContextParameters.ORIGIN, Vec3D.a(blockposition)).set(LootContextParameters.TOOL, ItemStack.EMPTY).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity);
+ if (nmsBlock.dropFromExplosion(explosionSource)) {
+ TileEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null;
+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity);
+
+ craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> {
+ Block.a(level, blockposition, itemstack);
+ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> {
+ Block.popResource(level, blockposition, itemstack);
+ });
+ craftBlock.getNMS().dropNaturally((WorldServer) level, blockposition, ItemStack.EMPTY);
+ craftBlock.getNMS().spawnAfterBreak((WorldServer) level, blockposition, ItemStack.EMPTY);
+ }
+ nmsBlock.wasExploded(level, blockposition, explosionSource);
+
+ this.level.a(blockposition, false);
+ this.level.removeBlock(blockposition, false);
+ }
+ }
+ // CraftBukkit end

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.java
+++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerManager.java
@@ -4,6 +4,11 @@
@@ -5,6 +5,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -12,14 +12,14 @@
public class DragonControllerManager {
private static final Logger LOGGER = LogManager.getLogger();
@@ -22,6 +27,19 @@
this.currentPhase.e();
@@ -24,6 +29,19 @@
this.currentPhase.end();
}
+ // CraftBukkit start - Call EnderDragonChangePhaseEvent
+ EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent(
+ (CraftEnderDragon) this.dragon.getBukkitEntity(),
+ (this.currentPhase == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentPhase.getControllerPhase()),
+ (this.currentPhase == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()),
+ CraftEnderDragon.getBukkitPhase(dragoncontrollerphase)
+ );
+ this.dragon.level.getCraftServer().getPluginManager().callEvent(event);
@@ -29,11 +29,11 @@
+ dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
+ // CraftBukkit end
+
this.currentPhase = this.b(dragoncontrollerphase);
this.currentPhase = this.getPhase(dragoncontrollerphase);
if (!this.dragon.level.isClientSide) {
this.dragon.getDataWatcher().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.b());
@@ -43,6 +61,6 @@
this.phases[i] = dragoncontrollerphase.a(this.dragon);
this.dragon.getEntityData().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.getId());
@@ -45,6 +63,6 @@
this.phases[i] = dragoncontrollerphase.createInstance(this.dragon);
}
- return this.phases[i];

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/wither/EntityWither.java
+++ b/net/minecraft/world/entity/boss/wither/EntityWither.java
@@ -54,6 +54,17 @@
@@ -56,6 +56,17 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
@@ -17,72 +17,72 @@
+
public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity {
private static final DataWatcherObject<Integer> DATA_TARGET_A = DataWatcher.a(EntityWither.class, DataWatcherRegistry.INT);
@@ -238,16 +249,40 @@
private static final DataWatcherObject<Integer> DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT);
@@ -250,16 +261,40 @@
this.bossEvent.setProgress(1.0F - (float) i / 220.0F);
if (i <= 0) {
Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
+ // CraftBukkit start
+ // this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
+ // this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion_effect);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
+ this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), explosion_effect);
+ }
+ // CraftBukkit end
- this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
- this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, explosion_effect);
if (!this.isSilent()) {
- this.level.b(1023, this.getChunkCoordinates(), 0);
- this.level.globalLevelEvent(1023, this.blockPosition(), 0);
+ // CraftBukkit start - Use relative location for far away sounds
+ // this.world.b(1023, new BlockPosition(this), 0);
+ // this.world.globalLevelEvent(1023, new BlockPosition(this), 0);
+ int viewDistance = ((WorldServer) this.level).getCraftServer().getViewDistance() * 16;
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
+ double deltaX = this.locX() - player.locX();
+ double deltaZ = this.locZ() - player.locZ();
+ double deltaX = this.getX() - player.getX();
+ double deltaZ = this.getZ() - player.getZ();
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
+ if (distanceSquared > viewDistance * viewDistance) {
+ double deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance;
+ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true));
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance;
+ player.connection.send(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true));
+ } else {
+ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true));
+ player.connection.send(new PacketPlayOutWorldEvent(1023, this.blockPosition(), 0, true));
+ }
+ }
+ // CraftBukkit end
}
}
this.setInvul(i);
this.setInvulnerableTicks(i);
if (this.tickCount % 10 == 0) {
- this.heal(10.0F);
+ this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
}
} else {
@@ -292,6 +327,7 @@
@@ -304,6 +339,7 @@
if (!list.isEmpty()) {
EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size()));
+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving1, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit
this.setHeadTarget(i, entityliving1.getId());
this.setAlternativeTarget(i, entityliving1.getId());
}
}
@@ -322,6 +358,11 @@
IBlockData iblockdata = this.level.getType(blockposition);
@@ -334,6 +370,11 @@
IBlockData iblockdata = this.level.getBlockState(blockposition);
if (c(iblockdata)) {
if (canDestroy(iblockdata)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
flag = this.level.a(blockposition, true, this) || flag;
flag = this.level.destroyBlock(blockposition, true, this) || flag;
}
}
@@ -335,7 +376,7 @@
@@ -347,7 +388,7 @@
}
if (this.tickCount % 20 == 0) {