changed placeholder

This commit is contained in:
Elias Müller 2024-10-05 22:24:27 +02:00
parent 156b7e6b61
commit 154c1cf936

View File

@ -11,6 +11,7 @@ import org.bukkit.*;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Transformation;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@ -29,9 +30,8 @@ public class PixelBlock {
public List<Pixel> pixels = new ArrayList<>();
public Interaction hitbox;
public ItemDisplay barrier;
public List<ItemDisplay> placeholderIcon = new ArrayList<>();
public long lastEntryTime;
public Location lastEntryLocation;
public UUID ownerUUID;
public UUID blockUUID;
@ -97,7 +97,6 @@ public class PixelBlock {
getBlockTaskChain()
.async(() -> {
this.lastEntryLocation = player.getLocation();
this.lastEntryTime = System.currentTimeMillis();
Main.database.savePixelBlock(this);
})
.sync(() -> player.teleport(this.pixelWorld.getSpawnLocation()))
@ -205,11 +204,29 @@ public class PixelBlock {
newPixel.place(this.pixelBlockLocation);
Location itemDisplayLocation = this.pixelBlockLocation.clone().add(0.5, 0.5, 0.5);
this.barrier = (ItemDisplay) this.pixelBlockLocation.getWorld().spawnEntity(
for(int i = 0; i <= 90; i += 90) {
ItemDisplay verticalEntity = (ItemDisplay) this.pixelBlockLocation.getWorld().spawnEntity(
itemDisplayLocation,
EntityType.ITEM_DISPLAY
);
verticalEntity.setRotation(i, 0);
this.placeholderIcon.add(verticalEntity);
}
ItemDisplay horizontalEntity = (ItemDisplay) this.pixelBlockLocation.getWorld().spawnEntity(
itemDisplayLocation,
EntityType.ITEM_DISPLAY
);
this.barrier.setItemStack(ItemStack.of(Material.BARRIER));
horizontalEntity.setRotation(0, 90);
this.placeholderIcon.add(horizontalEntity);
this.placeholderIcon.forEach(itemDisplay -> {
itemDisplay.setItemStack(ItemStack.of(Material.END_CRYSTAL));
Transformation transform = itemDisplay.getTransformation();
transform.getScale().set(0.5);
itemDisplay.setTransformation(transform);
});
spawnInteraction(true);
} else {
@ -276,9 +293,9 @@ public class PixelBlock {
this.hitbox = null;
}
if(barrier != null) {
this.barrier.remove();
this.barrier = null;
if(!placeholderIcon.isEmpty()) {
this.placeholderIcon.forEach(Entity::remove);
this.placeholderIcon.clear();
}
this.pixelBlockLocation.getWorld().getEntities().stream()