85 lines
3.6 KiB
Diff
85 lines
3.6 KiB
Diff
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
|
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
|
@@ -100,6 +100,7 @@
|
|
private float dancingAnimationTicks;
|
|
private float spinningAnimationTicks;
|
|
private float spinningAnimationTicks0;
|
|
+ public boolean forceDancing = false; // CraftBukkit
|
|
|
|
public Allay(EntityTypes<? extends Allay> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
@@ -111,6 +112,12 @@
|
|
this.dynamicJukeboxListener = new DynamicGameEventListener<Allay.a>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()));
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public void setCanDuplicate(boolean canDuplicate) {
|
|
+ this.entityData.set(Allay.DATA_CAN_DUPLICATE, canDuplicate);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
@Override
|
|
protected BehaviorController.b<Allay> brainProvider() {
|
|
return BehaviorController.<Allay>provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
|
|
@@ -123,7 +130,7 @@
|
|
|
|
@Override
|
|
public BehaviorController<Allay> getBrain() {
|
|
- return super.getBrain();
|
|
+ return (BehaviorController<Allay>) super.getBrain(); // CraftBukkit - decompile error
|
|
}
|
|
|
|
public static AttributeProvider.Builder createAttributes() {
|
|
@@ -228,7 +235,7 @@
|
|
public void aiStep() {
|
|
super.aiStep();
|
|
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
|
|
- this.heal(1.0F);
|
|
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
|
}
|
|
|
|
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
|
|
@@ -298,7 +305,12 @@
|
|
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
|
|
|
|
if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) {
|
|
- this.duplicateAllay();
|
|
+ // CraftBukkit start - handle cancel duplication
|
|
+ Allay allay = this.duplicateAllay();
|
|
+ if (allay == null) {
|
|
+ return EnumInteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.level().broadcastEntityEvent(this, (byte) 18);
|
|
this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F);
|
|
this.removeInteractionItem(entityhuman, itemstack);
|
|
@@ -407,6 +419,7 @@
|
|
}
|
|
|
|
private boolean shouldStopDancing() {
|
|
+ if (this.forceDancing) {return false;} // CraftBukkit
|
|
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
|
|
}
|
|
|
|
@@ -486,7 +499,7 @@
|
|
this.entityData.set(Allay.DATA_CAN_DUPLICATE, i == 0L);
|
|
}
|
|
|
|
- public void duplicateAllay() {
|
|
+ public Allay duplicateAllay() { // CraftBukkit - return allay
|
|
Allay allay = EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
|
|
|
|
if (allay != null) {
|
|
@@ -494,9 +507,9 @@
|
|
allay.setPersistenceRequired();
|
|
allay.resetDuplicationCooldown();
|
|
this.resetDuplicationCooldown();
|
|
- this.level().addFreshEntity(allay);
|
|
+ this.level().addFreshEntity(allay, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DUPLICATION); // CraftBukkit - reason for duplicated allay
|
|
}
|
|
-
|
|
+ return allay; // CraftBukkit
|
|
}
|
|
|
|
public void resetDuplicationCooldown() {
|