|
19 | 19 | import org.bukkit.Location; |
20 | 20 | import org.bukkit.Material; |
21 | 21 | import org.bukkit.block.Block; |
| 22 | +import org.bukkit.block.BlockFace; |
22 | 23 | import org.bukkit.configuration.ConfigurationSection; |
23 | 24 | import org.bukkit.entity.Entity; |
24 | 25 | import org.bukkit.entity.LivingEntity; |
@@ -225,28 +226,21 @@ public void progress() { |
225 | 226 | Vector push = new Vector(x1 - x0, 0.34999999999999998D, z1 - z0); |
226 | 227 | if (location.distance(sourceblock.getLocation()) < range) { |
227 | 228 | Material cloneType = location.getBlock().getType(); |
228 | | - Location locationYUP = location.clone().add(0.0D, 0.1D, 0.0D); |
| 229 | + Location locationYUP = location.getBlock().getLocation().clone().add(0.5, 0.1, 0.5); |
229 | 230 |
|
230 | 231 | playEarthbendingSound(location); |
231 | 232 |
|
232 | 233 | new RegenTempBlock(location.getBlock(), Material.AIR, Material.AIR.createBlockData(), 700L); |
233 | 234 |
|
234 | | - new TempFallingBlock(locationYUP, cloneType.createBlockData(), push, this); |
| 235 | + new TempFallingBlock(locationYUP, cloneType.createBlockData(), new Vector(0.0, 0.35, 0.0), this); |
235 | 236 |
|
236 | 237 | location.add(looking.normalize()); |
237 | | - if (!ElementalAbility.isAir(location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType()) && !isTransparent(location.clone().add(0.0D, 1.0D, 0.0D).getBlock())) { |
238 | | - location.add(0.0D, 1.0D, 0.0D); |
239 | | - if (!isEarthbendable(player, location.getBlock()) || !ElementalAbility.isAir(location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType()) && !isTransparent(location.clone().add(0.0D, 1.0D, 0.0D).getBlock())) { |
240 | | - remove(); |
241 | | - return; |
242 | | - } |
243 | | - } else if ((ElementalAbility.isAir(location.clone().getBlock().getType()) || isTransparent(location.clone().add(0.0D, 1.0D, 0.0D).getBlock())) && !ElementalAbility.isAir(location.clone().add(0.0D, -1D, 0.0D).getBlock().getType())) { |
244 | | - location.add(0.0D, -1D, 0.0D); |
245 | | - if (!isEarthbendable(player, location.clone().getBlock()) || ElementalAbility.isAir(location.clone().add(0.0D, -1D, 0.0D).getBlock().getType())) { |
246 | | - remove(); |
247 | | - return; |
248 | | - } |
| 238 | + |
| 239 | + if (!climb()) { |
| 240 | + remove(); |
| 241 | + return; |
249 | 242 | } |
| 243 | + |
250 | 244 | if (hitted) { |
251 | 245 | if (goOnAfterHit != 0) { |
252 | 246 | goOnAfterHit--; |
@@ -276,6 +270,27 @@ public void progress() { |
276 | 270 | } |
277 | 271 | return; |
278 | 272 | } |
| 273 | + |
| 274 | + private boolean climb() { |
| 275 | + Block above = location.getBlock().getRelative(BlockFace.UP); |
| 276 | + |
| 277 | + if (!isTransparent(above)) { |
| 278 | + // Attempt to climb since the current location has a block above it. |
| 279 | + location.add(0, 1, 0); |
| 280 | + above = location.getBlock().getRelative(BlockFace.UP); |
| 281 | + |
| 282 | + // The new location must be earthbendable and have something transparent above it. |
| 283 | + return isEarthbendable(location.getBlock()) && isTransparent(above); |
| 284 | + } else if (isTransparent(location.getBlock()) ) { |
| 285 | + // Attempt to fall since the current location is transparent and the above block was transparent. |
| 286 | + location.add(0, -1, 0); |
| 287 | + |
| 288 | + // The new location must be earthbendable and we already know the block above it is transparent. |
| 289 | + return isEarthbendable(location.getBlock()); |
| 290 | + } |
| 291 | + |
| 292 | + return true; |
| 293 | + } |
279 | 294 |
|
280 | 295 | @Override |
281 | 296 | public long getCooldown() { |
|
0 commit comments