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/animal/EntityAnimal.java
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
@@ -28,11 +28,18 @@
@@ -31,12 +31,19 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.pathfinder.PathType;
@@ -14,12 +14,13 @@
static final int PARENT_AGE_AFTER_BREEDING = 6000;
public int inLove;
@Nullable
public UUID loveCause;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@@ -69,6 +76,9 @@
@@ -73,6 +80,9 @@
}
@@ -27,20 +28,20 @@
+ // Function disabled as it has no special function anymore after
+ // setSitting is disabled.
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable(damagesource)) {
@@ -78,6 +88,7 @@
return super.damageEntity(damagesource, f);
public boolean hurt(DamageSource damagesource, float f) {
if (this.isInvulnerableTo(damagesource)) {
@@ -82,6 +92,7 @@
return super.hurt(damagesource, f);
}
}
+ // CraftBukkit end */
@Override
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
@@ -170,10 +181,17 @@
public float getWalkTargetValue(BlockPosition blockposition, IWorldReader iworldreader) {
@@ -178,10 +189,17 @@
}
public void g(@Nullable EntityHuman entityhuman) {
public void setInLove(@Nullable EntityHuman entityhuman) {
- this.inLove = 600;
+ // CraftBukkit start
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600);
@@ -50,29 +51,29 @@
+ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
+ // CraftBukkit end
if (entityhuman != null) {
this.loveCause = entityhuman.getUniqueID();
this.loveCause = entityhuman.getUUID();
}
+ this.breedItem = entityhuman.getInventory().getItemInHand(); // CraftBukkit
+ this.breedItem = entityhuman.getInventory().getSelected(); // CraftBukkit
this.level.broadcastEntityEffect(this, (byte) 18);
this.level.broadcastEntityEvent(this, (byte) 18);
}
@@ -213,11 +231,26 @@
EntityAgeable entityageable = this.createChild(worldserver, entityanimal);
@@ -221,11 +239,26 @@
EntityAgeable entityageable = this.getBreedOffspring(worldserver, entityanimal);
if (entityageable != null) {
+ // CraftBukkit start - set persistence for tame animals
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) {
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTame()) {
+ entityageable.setPersistenceRequired(true);
+ }
+ // CraftBukkit end
EntityPlayer entityplayer = this.getBreedCause();
EntityPlayer entityplayer = this.getLoveCause();
if (entityplayer == null && entityanimal.getBreedCause() != null) {
entityplayer = entityanimal.getBreedCause();
if (entityplayer == null && entityanimal.getLoveCause() != null) {
entityplayer = entityanimal.getLoveCause();
}
+ // CraftBukkit start - call EntityBreedEvent
+ entityageable.setBaby(true);
+ entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
+ entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
+ int experience = this.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, entityplayer, this.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
@@ -82,21 +83,21 @@
+ // CraftBukkit end
if (entityplayer != null) {
entityplayer.a(StatisticList.ANIMALS_BRED);
@@ -228,12 +261,14 @@
entityanimal.setAgeRaw(6000);
entityplayer.awardStat(StatisticList.ANIMALS_BRED);
@@ -236,12 +269,14 @@
entityanimal.setAge(6000);
this.resetLove();
entityanimal.resetLove();
- entityageable.setBaby(true);
- entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
- worldserver.addAllEntities(entityageable);
+ worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
worldserver.broadcastEntityEffect(this, (byte) 18);
- entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
- worldserver.addFreshEntityWithPassengers(entityageable);
+ worldserver.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
worldserver.broadcastEntityEvent(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1));
- worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), experience));
+ worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
+ }
+ // CraftBukkit end
}