BKCommonLib icon indicating copy to clipboard operation
BKCommonLib copied to clipboard

Per player display shared between players

Open BeefDev opened this issue 2 years ago • 2 comments

BkCommonLib version: 1.19.4-v2
Spigot version: 1.19.4

Problem or bug: When spawning a map inside an item frame (with the display set to be non global) the map display is shared between players that view the map when it's spawned. If only one players views the map when it's spawned and the others come near it later, it works as expected and creates a new instance of the map display. (Theres a video)

Code

public final class TestMapDisplay extends MapDisplay {

    private static int COUNTER = 1;

    private final int id;

    public TestMapDisplay() {
        this.id = COUNTER++;
    }

    @Override
    public void onAttached() {
        this.setGlobal(false);
        this.getLayer().fill(MapColorPalette.COLOR_WHITE);
        this.getLayer().next().draw(MapFont.MINECRAFT, 10, 10, MapColorPalette.COLOR_RED, String.valueOf(this.id));
    }
}
ItemFrame frame = (ItemFrame) rayTraceResult.getHitEntity();
frame.setItem(MapDisplay.createMapItem(this, TestMapDisplay.class));

Expected behaviour: A different instance is created for all players near the map

Steps to reproduce: Make a map display which is not global and draws something unique to each instance on the map, then spawn it in an item frame next to multiple players.

BeefDev avatar Jun 10 '23 10:06 BeefDev