diff --git a/src/main/java/net/gteam/wave/playerdata/data/impl/MovementData.java b/src/main/java/net/gteam/wave/playerdata/data/impl/MovementData.java index 23225ed..542570e 100644 --- a/src/main/java/net/gteam/wave/playerdata/data/impl/MovementData.java +++ b/src/main/java/net/gteam/wave/playerdata/data/impl/MovementData.java @@ -7,6 +7,7 @@ import net.gteam.wave.managers.profile.Profile; import net.gteam.wave.nms.NMSInstance; import net.gteam.wave.playerdata.data.Data; +import net.gteam.wave.playerdata.processors.impl.GhostBlockProcessor; import net.gteam.wave.playerdata.processors.impl.PredictionProcessor; import net.gteam.wave.playerdata.processors.impl.SetbackProcessor; import net.gteam.wave.processors.ClientPlayPacket; @@ -32,6 +33,7 @@ public class MovementData implements Data { private final SetbackProcessor setbackProcessor; private final PredictionProcessor predictionProcessor; + private final GhostBlockProcessor ghostBlockProcessor; private double deltaX, lastDeltaX, deltaZ, lastDeltaZ, deltaY, lastDeltaY, deltaXZ, lastDeltaXZ, accelXZ, lastAccelXZ, accelY, lastAccelY; @@ -57,6 +59,7 @@ public MovementData(final Profile profile) { this.equipment = new Equipment(); this.setbackProcessor = new SetbackProcessor(profile); this.predictionProcessor = new PredictionProcessor(profile); + this.ghostBlockProcessor = new GhostBlockProcessor(profile); this.location = this.lastLocation = new CustomLocation(profile.getPlayer().getLocation()); } @@ -242,6 +245,10 @@ private void processPlayerData() { this.lastFrictionFactor = this.frictionFactor; } + // Ghost blocks + + this.ghostBlockProcessor.process(); + // Setbacks if (this.nearGroundTicks > 1) this.setbackProcessor.process(); diff --git a/src/main/java/net/gteam/wave/playerdata/processors/impl/GhostBlockProcessor.java b/src/main/java/net/gteam/wave/playerdata/processors/impl/GhostBlockProcessor.java new file mode 100644 index 0000000..317cd2c --- /dev/null +++ b/src/main/java/net/gteam/wave/playerdata/processors/impl/GhostBlockProcessor.java @@ -0,0 +1,44 @@ +package net.gteam.wave.playerdata.processors.impl; + +import net.gteam.wave.managers.profile.Profile; +import net.gteam.wave.playerdata.data.impl.MovementData; +import net.gteam.wave.playerdata.processors.Processor; +import net.gteam.wave.utils.TaskUtils; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class GhostBlockProcessor implements Processor { + + private final Profile profile; + + public GhostBlockProcessor(final Profile profile) { + this.profile = profile; + } + + @Override + public void process() { + + final MovementData movementData = profile.getMovementData(); + + if (movementData.isOnGround() && movementData.isServerGround()) { + + if (movementData.getNearGroundTicks() >= 2) { + + final Player player = profile.getPlayer(); + + TaskUtils.task(() -> { + + player.getLocation().subtract(0, 1, 0).getBlock().setType(Material.STONE); + + player.sendBlockChange(player.getLocation().subtract(0, 1, 0), player.getLocation().subtract(0, 1, 0).getBlock().getBlockData()); + + Bukkit.broadcastMessage("Ghost block processed for " + player.getName()); + + }); + } + } + } +}