Skip to content

Commit e32d11a

Browse files
committed
Fix regen attributes not working
1 parent 696d121 commit e32d11a

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

papyrus-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,28 @@
9090
}
9191

9292
this.tickEffects();
93-
+ getBukkitLivingEntity().tick(); // Papyrus - Spellbook tick
93+
+ spellbookTick(); // Papyrus - Spellbook
9494
this.yHeadRotO = this.yHeadRot;
9595
this.yBodyRotO = this.yBodyRot;
9696
this.yRotO = this.getYRot();
97+
@@ -520,6 +_,17 @@
98+
profilerFiller.pop();
99+
}
100+
101+
+ // Papyrus start
102+
+ private void spellbookTick() {
103+
+ if (tickCount % 20 == 0) {
104+
+ double energyRegen = getAttribute(Attributes.STAT_ENERGY_REGEN).getValue();
105+
+ double healthRegen = getAttribute(Attributes.STAT_HEALTH_REGEN).getValue();
106+
+ getBukkitLivingEntity().addEnergy((int) energyRegen);
107+
+ heal((float) healthRegen);
108+
+ }
109+
+ }
110+
+ // Papyrus end
111+
+
112+
protected boolean shouldTakeDrowningDamage() {
113+
return this.getAirSupply() <= -20;
114+
}
97115
@@ -1410,8 +_,93 @@
98116
return this.getHealth() <= 0.0F;
99117
}

papyrus-server/minecraft-patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,25 @@
6363
// CraftBukkit start
6464
// SPIGOT-7045: Give ocelot babies back their special spawn reason. Note: This is the only modification required as ocelots count as monsters which means they only spawn during normal chunk ticking and do not spawn during chunk generation as starter mobs.
6565
level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
66-
@@ -427,9 +_,12 @@
66+
@@ -433,9 +_,14 @@
6767
private static WeightedList<MobSpawnSettings.SpawnerData> mobsAt(
68-
ServerLevel level, StructureManager structureManager, ChunkGenerator generator, MobCategory cetagory, BlockPos pos, @Nullable Holder<Biome> biome
68+
ServerLevel level, StructureManager structureManager, ChunkGenerator generator, MobCategory category, BlockPos pos, @Nullable Holder<Biome> biome
6969
) {
70-
- return isInNetherFortressBounds(pos, level, cetagory, structureManager)
71-
+ WeightedList<MobSpawnSettings.SpawnerData> spawnerData = isInNetherFortressBounds(pos, level, cetagory, structureManager)
72-
? NetherFortressStructure.FORTRESS_ENEMIES
73-
: generator.getMobsAt(biome != null ? biome : level.getBiome(pos), structureManager, cetagory, pos);
74-
+ MobSpawnForBiomeEvent mobSpawnForBiomeEvent = new MobSpawnForBiomeEvent(level, structureManager, generator, cetagory, pos, biome, spawnerData);
70+
- return isInNetherFortressBounds(pos, level, category, structureManager)
71+
- ? NetherFortressStructure.FORTRESS_ENEMIES
72+
- : generator.getMobsAt(biome != null ? biome : level.getBiome(pos), structureManager, category, pos);
73+
+ // Papyrus start - mob spawn event
74+
+ WeightedList<MobSpawnSettings.SpawnerData> spawnerData = isInNetherFortressBounds(pos, level, category, structureManager)
75+
+ ? NetherFortressStructure.FORTRESS_ENEMIES
76+
+ : generator.getMobsAt(biome != null ? biome : level.getBiome(pos), structureManager, category, pos);
77+
+ MobSpawnForBiomeEvent mobSpawnForBiomeEvent = new MobSpawnForBiomeEvent(level, structureManager, generator, category, pos, biome, spawnerData);
7578
+ mobSpawnForBiomeEvent.callEvent();
7679
+ return mobSpawnForBiomeEvent.getSpawnerData();
80+
+ // Papyrus end
7781
}
7882

7983
public static boolean isInNetherFortressBounds(BlockPos pos, ServerLevel level, MobCategory category, StructureManager structureManager) {
80-
@@ -626,7 +_,11 @@
84+
@@ -632,7 +_,11 @@
8185
}
8286

8387
this.spawnPotential.addCharge(blockPos, d);

0 commit comments

Comments
 (0)