|
19 | 19 | package com.volmit.adapt.content.adaptation.herbalism; |
20 | 20 |
|
21 | 21 | import com.volmit.adapt.api.adaptation.SimpleAdaptation; |
| 22 | +import com.volmit.adapt.api.world.AdaptPlayer; |
22 | 23 | import com.volmit.adapt.util.*; |
23 | 24 | import com.volmit.adapt.util.reflect.registries.Particles; |
24 | 25 | import lombok.NoArgsConstructor; |
@@ -84,32 +85,38 @@ public void onTick() { |
84 | 85 |
|
85 | 86 | for (int i = 0; i < Math.min(Math.min(rad * rad, 256), 3); i++) { |
86 | 87 | 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 | + |
88 | 96 | SoundPlayer spw = SoundPlayer.of(a.getWorld()); |
89 | 97 | if (a.getBlockData() instanceof Ageable) { |
90 | 98 | Ageable ab = (Ageable) a.getBlockData(); |
91 | 99 | int toGrowLeft = ab.getMaximumAge() - ab.getAge(); |
92 | 100 |
|
93 | 101 | if (toGrowLeft > 0) { |
94 | 102 | 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)) { |
96 | 105 | while (add-- > 0) { |
97 | 106 | 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); |
112 | 118 | } |
| 119 | +// xp(p, 1); // JESUS THIS IS FUCKING BUSTED |
113 | 120 | }, RNG.r.i(30, 60)); |
114 | 121 | } |
115 | 122 | } |
@@ -140,6 +147,7 @@ protected static class Config { |
140 | 147 | boolean permanent = false; |
141 | 148 | boolean enabled = true; |
142 | 149 | boolean showParticles = true; |
| 150 | + boolean surfaceOnly = true; |
143 | 151 | int baseCost = 8; |
144 | 152 | int maxLevel = 7; |
145 | 153 | int initialCost = 12; |
|
0 commit comments