Update to Minecraft 1.19

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2022-06-08 02:00:00 +10:00
parent 91d9aa9a89
commit 25f3b50f6b
332 changed files with 3628 additions and 2559 deletions

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/entity/ai/attributes/AttributeRanged.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeRanged.java
@@ -30,6 +30,8 @@
@Override
public double sanitizeValue(double d0) {
+ if (d0 != d0) return getDefaultValue(); // CraftBukkit
+
d0 = MathHelper.clamp(d0, this.minValue, this.maxValue);
return d0;
}

View File

@@ -13,7 +13,7 @@
public class BehaviorAttackTargetForget<E extends EntityInsentient> extends Behavior<E> {
private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200;
@@ -77,6 +83,17 @@
@@ -83,6 +89,17 @@
}
protected void clearAttackTarget(E e0) {
@@ -28,6 +28,6 @@
+ return;
+ }
+ // CraftBukkit end
this.onTargetErased.accept(e0);
this.onTargetErased.accept(e0, this.getAttackTarget(e0));
e0.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET);
}

View File

@@ -14,17 +14,17 @@
public class BehaviorAttackTargetSet<E extends EntityInsentient> extends Behavior<E> {
private final Predicate<E> canAttackPredicate;
@@ -38,13 +45,21 @@
@@ -42,13 +49,21 @@
}
protected void start(WorldServer worldserver, E e0, long i) {
- ((Optional) this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> {
+ (this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error
this.setAttackTarget(e0, entityliving);
setAttackTarget(e0, entityliving);
});
}
private void setAttackTarget(E e0, EntityLiving entityliving) {
public static <E extends EntityInsentient> void setAttackTarget(E e0, EntityLiving entityliving) {
- e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving);
+ // CraftBukkit start
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, entityliving, (entityliving instanceof EntityPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY);

View File

@@ -23,7 +23,7 @@
if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) {
MinecraftServer minecraftserver = worldserver.getServer();
@@ -40,7 +46,14 @@
return villagerprofession.getJobPoiType() == villageplacetype;
return villagerprofession.heldJobSite().test(holder);
}).findFirst();
}).ifPresent((villagerprofession) -> {
- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -79,8 +79,8 @@
@@ -80,8 +80,8 @@
protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) {
if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) {
@@ -11,7 +11,7 @@
}
}
@@ -100,7 +100,11 @@
@@ -101,7 +101,11 @@
Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock();
if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) {
@@ -24,40 +24,45 @@
}
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) {
@@ -111,19 +115,28 @@
boolean flag = false;
@@ -114,27 +118,30 @@
if (!itemstack.isEmpty()) {
IBlockData iblockdata1;
+ // CraftBukkit start
+ Block planted = null;
if (itemstack.is(Items.WHEAT_SEEDS)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.WHEAT.defaultBlockState(), 3);
+ planted = Blocks.WHEAT;
iblockdata1 = Blocks.WHEAT.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.POTATO)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.POTATOES.defaultBlockState(), 3);
+ planted = Blocks.POTATOES;
iblockdata1 = Blocks.POTATOES.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.CARROT)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.CARROTS.defaultBlockState(), 3);
+ planted = Blocks.CARROTS;
iblockdata1 = Blocks.CARROTS.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.BEETROOT_SEEDS)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.BEETROOTS.defaultBlockState(), 3);
+ planted = Blocks.BEETROOTS;
flag = true;
}
iblockdata1 = Blocks.BEETROOTS.defaultBlockState();
+ flag = true;
+ } else {
+ iblockdata1 = null;
+ }
+
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, planted.defaultBlockState()).isCancelled()) {
+ worldserver.setBlock(this.aboveFarmlandPos, planted.defaultBlockState(), 3);
+ if (iblockdata1 != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1).isCancelled()) {
worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
- flag = true;
+ } else {
+ flag = false;
+ }
}
+ // CraftBukkit end
}
if (flag) {
@@ -142,8 +155,8 @@
@@ -153,8 +160,8 @@
this.aboveFarmlandPos = this.getValidFarmland(worldserver);
if (this.aboveFarmlandPos != null) {
this.nextOkStartTime = i + 20L;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
@@ -112,11 +112,16 @@
@@ -116,11 +116,16 @@
if (entityvillager2 == null) {
return Optional.empty();
} else {
@@ -20,7 +20,7 @@
worldserver.broadcastEntityEvent(entityvillager2, (byte) 12);
return Optional.of(entityvillager2);
}
@@ -125,6 +130,6 @@
@@ -129,6 +134,6 @@
private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition);

View File

@@ -9,33 +9,28 @@
}
private static void setWalkAndLookTargetMemoriesToEachOther(EntityLiving entityliving, EntityLiving entityliving1, float f) {
@@ -74,18 +74,19 @@
public static void setWalkAndLookTargetMemories(EntityLiving entityliving, Entity entity, float f, int i) {
MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entity, false), f, i);
@@ -82,8 +82,8 @@
public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BehaviorPosition behaviorposition, float f, int i) {
MemoryTarget memorytarget = new MemoryTarget(behaviorposition, f, i);
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entity, true)));
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) behaviorposition);
- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entity, true))); // CraftBukkit - decompile error
+ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
}
public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BlockPosition blockposition, float f, int i) {
MemoryTarget memorytarget = new MemoryTarget(new BehaviorTarget(blockposition), f, i);
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(blockposition)));
- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(blockposition))); // CraftBukkit - decompile error
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, behaviorposition); // CraftBukkit - decompile error
+ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
}
public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) {
@@ -93,6 +93,7 @@
}
public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d, Vec3D vec3d1, float f) {
+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot
double d0 = entityliving.getEyeY() - 0.30000001192092896D;
double d0 = entityliving.getEyeY() - (double) f;
EntityItem entityitem = new EntityItem(entityliving.level, entityliving.getX(), d0, entityliving.getZ(), itemstack);
float f = 0.3F;
@@ -94,12 +95,19 @@
vec3d1 = vec3d1.normalize().scale(0.30000001192092896D);
entityitem.setDeltaMovement(vec3d1);
@@ -102,12 +103,19 @@
vec3d2 = vec3d2.normalize().multiply(vec3d1.x, vec3d1.y, vec3d1.z);
entityitem.setDeltaMovement(vec3d2);
entityitem.setDefaultPickUpDelay();
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entityliving.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
@@ -12,6 +12,10 @@
@@ -11,6 +11,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -11,7 +11,7 @@
public class PathfinderGoalEatTile extends PathfinderGoal {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -65,7 +69,8 @@
@@ -64,7 +68,8 @@
BlockPosition blockposition = this.mob.blockPosition();
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) {
@@ -21,7 +21,7 @@
this.level.destroyBlock(blockposition, false);
}
@@ -75,7 +80,8 @@
@@ -73,7 +78,8 @@
BlockPosition blockposition1 = blockposition.below();
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {