Commits
Doc authored and md_5 committed 051fcced11d
1 + | --- a/net/minecraft/world/entity/animal/allay/Allay.java |
2 + | +++ b/net/minecraft/world/entity/animal/allay/Allay.java |
3 + | |
4 + | private final DynamicGameEventListener<Allay.b> dynamicJukeboxListener; |
5 + | private final InventorySubcontainer inventory = new InventorySubcontainer(1); |
6 + | @Nullable |
7 + | - private BlockPosition jukeboxPos; |
8 + | - private long duplicationCooldown; |
9 + | + public BlockPosition jukeboxPos; // PAIL private -> public |
10 + | + public long duplicationCooldown; // PAIL private -> public |
11 + | private float holdingItemAnimationTicks; |
12 + | private float holdingItemAnimationTicks0; |
13 + | private float dancingAnimationTicks; |
14 + | private float spinningAnimationTicks; |
15 + | private float spinningAnimationTicks0; |
16 + | + public boolean forceDancing = false; // CraftBukkit |
17 + | |
18 + | public Allay(EntityTypes<? extends Allay> entitytypes, World world) { |
19 + | super(entitytypes, world); |
20 + | |
21 + | this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.b(entitypositionsource, GameEvent.JUKEBOX_PLAY.getNotificationRadius())); |
22 + | } |
23 + | |
24 + | + // CraftBukkit start |
25 + | + public void setCanDuplicate(boolean canDuplicate) { |
26 + | + this.entityData.set(Allay.DATA_CAN_DUPLICATE, canDuplicate); |
27 + | + } |
28 + | + // CraftBukkit end |
29 + | + |
30 + | @Override |
31 + | protected BehaviorController.b<Allay> brainProvider() { |
32 + | return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES); |
33 + | |
34 + | |
35 + | @Override |
36 + | public BehaviorController<Allay> getBrain() { |
37 + | - return super.getBrain(); |
38 + | + return (BehaviorController<Allay>) super.getBrain(); // CraftBukkit - decompile error |
39 + | } |
40 + | |
41 + | public static AttributeProvider.Builder createAttributes() { |
42 + | |
43 + | public void aiStep() { |
44 + | super.aiStep(); |
45 + | if (!this.level.isClientSide && this.isAlive() && this.tickCount % 10 == 0) { |
46 + | - this.heal(1.0F); |
47 + | + this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit |
48 + | } |
49 + | |
50 + | if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { |
51 + | |
52 + | ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND); |
53 + | |
54 + | if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) { |
55 + | - this.duplicateAllay(); |
56 + | + // CraftBukkit start - handle cancel duplication |
57 + | + Allay allay = this.duplicateAllay(); |
58 + | + if (allay == null) { |
59 + | + return EnumInteractionResult.SUCCESS; |
60 + | + } |
61 + | + // CraftBukkit end |
62 + | this.level.broadcastEntityEvent(this, (byte) 18); |
63 + | this.level.playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F); |
64 + | this.removeInteractionItem(entityhuman, itemstack); |
65 + | |
66 + | this.setItemInHand(EnumHand.MAIN_HAND, itemstack2); |
67 + | this.removeInteractionItem(entityhuman, itemstack); |
68 + | this.level.playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F); |
69 + | - this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, (Object) entityhuman.getUUID()); |
70 + | + this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, entityhuman.getUUID()); // CraftBukkit - decompile error |
71 + | return EnumInteractionResult.SUCCESS; |
72 + | } else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) { |
73 + | this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY); |
74 + | |
75 + | } |
76 + | |
77 + | private boolean shouldStopDancing() { |
78 + | + if (this.forceDancing) {return false;} // CraftBukkit |
79 + | return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) GameEvent.JUKEBOX_PLAY.getNotificationRadius()) || !this.level.getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); |
80 + | } |
81 + | |
82 + | |
83 + | public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { |
84 + | super.addAdditionalSaveData(nbttagcompound); |
85 + | nbttagcompound.put("Inventory", this.inventory.createTag()); |
86 + | - DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).encodeStart(DynamicOpsNBT.INSTANCE, (VibrationListener) this.dynamicVibrationListener.getListener()); |
87 + | + DataResult<net.minecraft.nbt.NBTBase> dataresult = VibrationListener.codec(this.vibrationListenerConfig).encodeStart(DynamicOpsNBT.INSTANCE, (VibrationListener) this.dynamicVibrationListener.getListener()); // CraftBukkit - decompile error |
88 + | Logger logger = Allay.LOGGER; |
89 + | |
90 + | Objects.requireNonNull(logger); |
91 + | |
92 + | super.readAdditionalSaveData(nbttagcompound); |
93 + | this.inventory.fromTag(nbttagcompound.getList("Inventory", 10)); |
94 + | if (nbttagcompound.contains("listener", 10)) { |
95 + | - DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); |
96 + | + DataResult<VibrationListener> dataresult = VibrationListener.codec(this.vibrationListenerConfig).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); // CraftBukkit - decompile error |
97 + | Logger logger = Allay.LOGGER; |
98 + | |
99 + | Objects.requireNonNull(logger); |
100 + | |
101 + | return Allay.DUPLICATION_ITEM.test(itemstack); |
102 + | } |
103 + | |
104 + | - private void duplicateAllay() { |
105 + | + public Allay duplicateAllay() { // CraftBukkit - return allay and private -> public |
106 + | Allay allay = (Allay) EntityTypes.ALLAY.create(this.level); |
107 + | |
108 + | if (allay != null) { |
109 + | |
110 + | allay.setPersistenceRequired(); |
111 + | allay.resetDuplicationCooldown(); |
112 + | this.resetDuplicationCooldown(); |
113 + | - this.level.addFreshEntity(allay); |
114 + | + this.level.addFreshEntity(allay, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DUPLICATION); // CraftBukkit - reason for duplicated allay |
115 + | } |
116 + | - |
117 + | + return allay; // CraftBukkit |
118 + | } |
119 + | |
120 + | - private void resetDuplicationCooldown() { |
121 + | + public void resetDuplicationCooldown() { // PAIL private -> public |
122 + | this.duplicationCooldown = 6000L; |
123 + | this.entityData.set(Allay.DATA_CAN_DUPLICATE, false); |
124 + | } |
125 + | |
126 + | - private boolean canDuplicate() { |
127 + | + public boolean canDuplicate() { // PAIL private -> public |
128 + | return (Boolean) this.entityData.get(Allay.DATA_CAN_DUPLICATE); |
129 + | } |
130 + |