SteamWar/BauSystem2.0
Archiviert
12
0

Update stuff
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-02-08 17:32:38 +01:00
Ursprung 6f0a2c8c4e
Commit c9cc03be87
2 geänderte Dateien mit 47 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -22,17 +22,20 @@ package de.steamwar.bausystem.features.slaves.laufbau;
import de.steamwar.inventory.SWItem;
import lombok.Getter;
import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.function.Consumer;
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
@ -41,6 +44,14 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCu
@Getter
public class BlockBoundingBox {
private static List<UUID> randomPlayerHead = new ArrayList<>();
private static Random random = new Random();
static {
randomPlayerHead.add(UUID.fromString("1623d4b1-b21c-41d3-93c2-eee2845b8497"));
randomPlayerHead.add(UUID.fromString("f75632be-e3ec-4069-9bec-d13ac6891177"));
randomPlayerHead.add(UUID.fromString("80382970-424b-4299-9296-d956beab9e7b"));
}
public static List<BlockBoundingBox> elements = new ArrayList<>();
public BlockData blockData;
@ -48,6 +59,8 @@ public class BlockBoundingBox {
private double volume;
public SWItem swItem;
public Consumer<Block> blockConsumer = null;
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem) {
this.blockData = blockData;
this.cuboidList = cuboidList;
@ -56,6 +69,15 @@ public class BlockBoundingBox {
elements.add(this);
}
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem, Consumer<Block> blockConsumer) {
this.blockData = blockData;
this.cuboidList = cuboidList;
this.swItem = swItem;
volume = cuboidList.stream().mapToDouble(Cuboid::volume).sum();
elements.add(this);
this.blockConsumer = blockConsumer;
}
public double volume() {
return volume;
}
@ -105,19 +127,19 @@ public class BlockBoundingBox {
Directional headNorth = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
headNorth.setFacing(BlockFace.NORTH);
addPixel(headNorth, 4, 4, 8, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_NORTH"));
addPixel(headNorth, 4, 4, 8, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_NORTH"), BlockBoundingBox::randomPlayerHead);
Directional headSouth = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
headSouth.setFacing(BlockFace.SOUTH);
addPixel(headSouth, 4, 4, 0, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_SOUTH"));
addPixel(headSouth, 4, 4, 0, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_SOUTH"), BlockBoundingBox::randomPlayerHead);
Directional headWest = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
headWest.setFacing(BlockFace.WEST);
addPixel(headWest, 8, 4, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_WEST"));
addPixel(headWest, 8, 4, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_WEST"), BlockBoundingBox::randomPlayerHead);
Directional headEast = (Directional) Material.PLAYER_WALL_HEAD.createBlockData();
headEast.setFacing(BlockFace.EAST);
addPixel(headEast, 0, 4, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_EAST"));
addPixel(headEast, 0, 4, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_WALL_HEAD", Material.PLAYER_HEAD, "LAUFBAU_FACING_EAST"), BlockBoundingBox::randomPlayerHead);
Snow snowLayers7 = (Snow) Material.SNOW.createBlockData();
snowLayers7.setLayers(7);
@ -129,7 +151,7 @@ public class BlockBoundingBox {
addPixel(Material.STONECUTTER.createBlockData(), 0, 0, 0, 16, 9, 16, createItem("LAUFBAU_BLOCK_STONECUTTER", Material.STONECUTTER));
addPixel(Material.PLAYER_HEAD.createBlockData(), 4, 0, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_HEAD", Material.PLAYER_HEAD));
addPixel(Material.PLAYER_HEAD.createBlockData(), 4, 0, 4, 8, 8, 8, createItem("LAUFBAU_BLOCK_PLAYER_HEAD", Material.PLAYER_HEAD), BlockBoundingBox::randomPlayerHead);
addPixel(Material.CAKE.createBlockData(), 1, 0, 1, 14, 8, 14, createItem("LAUFBAU_BLOCK_CAKE", Material.CAKE));
@ -227,4 +249,15 @@ public class BlockBoundingBox {
private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem) {
new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem);
}
private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem, Consumer<Block> blockConsumer) {
new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem, blockConsumer);
}
private static void randomPlayerHead(Block block) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(randomPlayerHead.get(random.nextInt(randomPlayerHead.size())));
Skull skull = (Skull) block.getState();
skull.setOwningPlayer(offlinePlayer);
skull.update();
}
}

Datei anzeigen

@ -28,10 +28,11 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.bausystem.region.Point;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class CreatingInnerBlocksState implements LaufbauState {
@ -100,6 +101,9 @@ public class CreatingInnerBlocksState implements LaufbauState {
try {
editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highest.blockData));
location.getBlock().setBlockData(highest.blockData, false);
if (highest.blockConsumer != null) {
highest.blockConsumer.accept(location.getBlock());
}
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
// ignored