Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playerside sign update #697

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
import net.countercraft.movecraft.util.hitboxes.HitBox;
import net.countercraft.movecraft.util.hitboxes.SetHitBox;
import net.countercraft.movecraft.util.hitboxes.SolidHitBox;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -233,24 +230,28 @@ public boolean equals(String[] a, String[] b) {
// TODO: This is implemented only to fix client caching
// ideally we wouldn't do the update and would instead fake it out to the player
for (MovecraftLocation location : entry.getValue()) {
Block block = location.toBukkit(craft.getWorld()).getBlock();
Location mcLocation = location.toBukkit(craft.getWorld());
Block block = mcLocation.getBlock();
BlockState state = block.getState();
BlockData data = block.getBlockData();
if (!(state instanceof Sign)) {
continue;
}

Sign sign = signStates.get(location);
if (event.isUpdated()) {
for (int i = 0; i < 4; i++) {
sign.setLine(i, entry.getKey()[i]);
}
if (!event.isUpdated())
continue;

for (Player player : mcLocation.getNearbyPlayers(64)) {
updateSign(player, mcLocation, entry.getKey(), sign);
}
sign.update(false, false);
block.setBlockData(data);
}
}
}

private void updateSign(Player player, Location location, String[] lines, Sign sign) {
player.sendBlockChange(location, sign.getBlockData());
}

@NotNull
public Craft getCraft() {
return craft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@
import net.countercraft.movecraft.util.hitboxes.HitBox;
import net.countercraft.movecraft.util.hitboxes.SetHitBox;
import net.countercraft.movecraft.util.hitboxes.SolidHitBox;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayDeque;
Expand Down Expand Up @@ -339,20 +336,28 @@ public boolean equals(String[] a, String[] b) {
// TODO: This is implemented only to fix client caching
// ideally we wouldn't do the update and would instead fake it out to the player
Intybyte marked this conversation as resolved.
Show resolved Hide resolved
for(MovecraftLocation location : entry.getValue()){
Block block = location.toBukkit(craft.getWorld()).getBlock();
Location mcLocation = location.toBukkit(craft.getWorld());
Block block = mcLocation.getBlock();
BlockState state = block.getState();
if (!(state instanceof Sign)) {
continue;
}

Sign sign = signStates.get(location);
for(int i = 0; i<4; i++){
sign.setLine(i, entry.getKey()[i]);
if (!event.isUpdated())
continue;

for (Player player : mcLocation.getNearbyPlayers(64)) {
updateSign(player, mcLocation, entry.getKey(), sign);
}
sign.update(false, false);
}
}
}

private void updateSign(Player player, Location location, String[] lines, Sign sign) {
player.sendBlockChange(location, sign.getBlockData());
}

@NotNull
public Craft getCraft(){
return craft;
Expand Down