Skip to content

Commit 04e04fa

Browse files
Merge pull request #531 from VolmitSoftware/Development
1.16.3
2 parents f4eb501 + b41864e commit 04e04fa

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

src/main/java/com/volmit/adapt/content/adaptation/herbalism/HerbalismGrowthAura.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package com.volmit.adapt.content.adaptation.herbalism;
2020

2121
import com.volmit.adapt.api.adaptation.SimpleAdaptation;
22+
import com.volmit.adapt.api.world.AdaptPlayer;
2223
import com.volmit.adapt.util.*;
2324
import com.volmit.adapt.util.reflect.registries.Particles;
2425
import lombok.NoArgsConstructor;
@@ -84,32 +85,38 @@ public void onTick() {
8485

8586
for (int i = 0; i < Math.min(Math.min(rad * rad, 256), 3); i++) {
8687
Location m = p.getLocation().clone().add(new Vector(Math.sin(angle), RNG.r.i(-1, 1), Math.cos(angle)).multiply(Math.random() * rad));
87-
Block a = m.getWorld().getHighestBlockAt(m).getRelative(BlockFace.UP);
88+
Block a = m.getBlock();
89+
if (getConfig().surfaceOnly) {
90+
int max = a.getWorld().getHighestBlockYAt(m);
91+
92+
if (max + 1 != a.getY())
93+
continue;
94+
}
95+
8896
SoundPlayer spw = SoundPlayer.of(a.getWorld());
8997
if (a.getBlockData() instanceof Ageable) {
9098
Ageable ab = (Ageable) a.getBlockData();
9199
int toGrowLeft = ab.getMaximumAge() - ab.getAge();
92100

93101
if (toGrowLeft > 0) {
94102
int add = (int) Math.max(1, Math.min(strength, toGrowLeft));
95-
if (ab.getMaximumAge() > ab.getAge() && getPlayer(p).canConsumeFood(foodCost, 10)) {
103+
AdaptPlayer player = getPlayer(p);
104+
if (ab.getMaximumAge() > ab.getAge() && player.canConsumeFood(foodCost, 10)) {
96105
while (add-- > 0) {
97106
J.s(() -> {
98-
if (getPlayer(p).consumeFood(foodCost, 10)) {
99-
if (a.getBlockData() instanceof Ageable) {
100-
Ageable aab = (Ageable) a.getBlockData();
101-
102-
if (aab.getAge() < aab.getMaximumAge()) {
103-
aab.setAge(aab.getAge() + 1);
104-
a.setBlockData(aab, true);
105-
spw.play(a.getLocation(), Sound.BLOCK_CHORUS_FLOWER_DEATH, 0.25f, RNG.r.f(0.3f, 0.7f));
106-
if (getConfig().showParticles) {
107-
p.spawnParticle(Particles.VILLAGER_HAPPY, a.getLocation().clone().add(0.5, 0.5, 0.5), 3, 0.3, 0.3, 0.3, 0.9);
108-
}
109-
// xp(p, 1); // JESUS THIS IS FUCKING BUSTED
110-
}
111-
}
107+
if (!p.isOnline()
108+
|| !player.consumeFood(foodCost, 10)
109+
|| !(a.getBlockData() instanceof Ageable aab)
110+
|| aab.getAge() == aab.getMaximumAge())
111+
return;
112+
113+
aab.setAge(aab.getAge() + 1);
114+
a.setBlockData(aab, true);
115+
spw.play(a.getLocation(), Sound.BLOCK_CHORUS_FLOWER_DEATH, 0.25f, RNG.r.f(0.3f, 0.7f));
116+
if (getConfig().showParticles) {
117+
p.spawnParticle(Particles.VILLAGER_HAPPY, a.getLocation().clone().add(0.5, 0.5, 0.5), 3, 0.3, 0.3, 0.3, 0.9);
112118
}
119+
// xp(p, 1); // JESUS THIS IS FUCKING BUSTED
113120
}, RNG.r.i(30, 60));
114121
}
115122
}
@@ -140,6 +147,7 @@ protected static class Config {
140147
boolean permanent = false;
141148
boolean enabled = true;
142149
boolean showParticles = true;
150+
boolean surfaceOnly = true;
143151
int baseCost = 8;
144152
int maxLevel = 7;
145153
int initialCost = 12;

0 commit comments

Comments
 (0)