Skip to content

Commit

Permalink
Added ghost block processor (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
XIII-MC committed Oct 18, 2024
1 parent 312c02c commit da62c0c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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());
}
Expand Down Expand Up @@ -242,6 +245,10 @@ private void processPlayerData() {
this.lastFrictionFactor = this.frictionFactor;
}

// Ghost blocks

this.ghostBlockProcessor.process();

// Setbacks

if (this.nearGroundTicks > 1) this.setbackProcessor.process();
Expand Down
Original file line number Diff line number Diff line change
@@ -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());

});
}
}
}
}

0 comments on commit da62c0c

Please sign in to comment.