SteamWar/BauSystem2.0
Archiviert
12
0

Hotfix CreatingLaufState and BlockBoundingBox
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-12-27 19:50:14 +01:00
Ursprung 675d0d616e
Commit 4a55af680d
2 geänderte Dateien mit 23 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.bausystem.features.slaves.laufbau;
import com.sk89q.worldedit.blocks.SkullBlock;
import com.sk89q.worldedit.world.block.BaseBlock;
import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.core.Core;
@ -28,6 +30,7 @@ import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
@ -47,14 +50,21 @@ import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCu
@Getter
public class BlockBoundingBox {
private static List<UUID> randomPlayerHead = new ArrayList<>();
private static List<String> randomPlayerHead = new ArrayList<>();
private static Random random = new Random();
static {
randomPlayerHead.add("zOnlyKroks");
randomPlayerHead.add("YoyoNow");
randomPlayerHead.add("Konstruktix");
randomPlayerHead.add("Merling03");
randomPlayerHead.add("Lord_Loading");
/*
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"));
randomPlayerHead.add(UUID.fromString("f395ce89-096d-48e9-b796-a2d88722c22b"));
randomPlayerHead.add(UUID.fromString("db516394-d999-4b77-8d13-73cceec77dfe"));
*/
}
public static List<BlockBoundingBox> elements = new ArrayList<>();
@ -64,7 +74,7 @@ public class BlockBoundingBox {
private double volume;
public SWItem swItem;
public Consumer<Block> blockConsumer = null;
public Consumer<BaseBlock> blockConsumer = null;
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem) {
this.blockData = blockData;
@ -74,7 +84,7 @@ public class BlockBoundingBox {
elements.add(this);
}
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem, Consumer<Block> blockConsumer) {
public BlockBoundingBox(BlockData blockData, List<Cuboid> cuboidList, SWItem swItem, Consumer<BaseBlock> blockConsumer) {
this.blockData = blockData;
this.cuboidList = cuboidList;
this.swItem = swItem;
@ -272,14 +282,15 @@ public class BlockBoundingBox {
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) {
private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem, Consumer<BaseBlock> 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();
@SuppressWarnings("deprecation")
private static void randomPlayerHead(BaseBlock block) {
if (block instanceof SkullBlock) {
SkullBlock skullBlock = (SkullBlock) block;
skullBlock.setOwner(randomPlayerHead.get(random.nextInt(randomPlayerHead.size())).toString());
}
}
}

Datei anzeigen

@ -29,7 +29,6 @@ import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.bausystem.region.Point;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -145,9 +144,9 @@ public class CreatingLaufState implements LaufbauState {
return;
}
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());
BaseBlock block = BukkitAdapter.adapt(highest.blockData).toBaseBlock();
if (highest.blockConsumer != null) highest.blockConsumer.accept(block);
editSession.setBlock(BukkitAdapter.asBlockVector(location), block);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
// ignored