Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2b803aca6 | |||
| 701964c2f2 | |||
| 6cbfc94e6d | |||
| c0ff123279 | |||
| 5511a1f08e | |||
| 8c8da355bb | |||
| 7326ed4aa0 | |||
| 2d59eb81c7 | |||
| 711920464a | |||
| 117dbd08ae | |||
| b36464e69e | |||
| f5ac006c0c | |||
| 414bfbfe3c | |||
| c362a3e1f0 | |||
| 2b43af8851 | |||
| 1590f8f0ee | |||
| 932732737d | |||
| 2bc164c1b0 | |||
| aa66b3dc83 | |||
| f5d9c6e175 | |||
| 36b31fac77 | |||
| 641cefad01 | |||
| eb866125ea | |||
| 961331f029 | |||
| 786257ad0e | |||
| e176b3bca8 | |||
| f81f05c3d0 | |||
| 0afb6ce06a | |||
| a938abde3f | |||
| ec9b0387c5 | |||
| 03c3d49659 | |||
| 8d9a77ab67 | |||
| fc2997e011 | |||
| 8eb5f5ddf2 | |||
| aa807060f4 | |||
| 9bbbab9d4b | |||
| 7cca4ada10 | |||
| 725e6df047 | |||
| f3ce124a23 | |||
| e83f72a53e | |||
| def0c19e43 | |||
| 3810ccd63d | |||
| a018af1c8a | |||
| fd8f942014 | |||
| eab8826583 | |||
| bc0177df43 | |||
| 1dc78b8eb8 | |||
| a9fb982143 | |||
| 5b8d881e01 | |||
| eb55f4b395 | |||
| 273db91d06 | |||
| 983ad544c1 | |||
| a6a34b2221 | |||
| 6c6bd19038 | |||
| 89e05cd109 | |||
| ea9d7ac584 | |||
| 17e1cf53b0 | |||
| f64f337f17 | |||
| c5f5be7d58 | |||
| 9f18644763 | |||
| 1de17d27f4 | |||
| 3cd0db9bdf | |||
| 9711b48f2f | |||
|
9934b8bbb2
|
|||
| 6447265b90 | |||
| 71258318db | |||
| 52e95e2649 | |||
| de6ac2cf20 | |||
| 628001e693 | |||
| 47c148d64a | |||
| 78617d5a98 | |||
| 69b924ded6 | |||
| 002f7e5542 | |||
| 5d70f75ac9 | |||
| 7f21a31ec9 | |||
| 23b5ab3e82 | |||
| 4f9fe07951 | |||
| 3bcff4c5ce | |||
| 1810cb7546 | |||
| e55ca911c4 | |||
| 793f2de6c3 | |||
| 54fa47bd99 | |||
| 14a770b207 | |||
| 7b3a04f4eb | |||
| f2a06057a8 | |||
| e11f3f7cbc | |||
| ebc10c1ce4 | |||
| d682e35159 | |||
| 7d74eb0c09 | |||
| 7e18207b87 | |||
| 72b23ad116 | |||
| c508627d92 | |||
| 93ff982649 | |||
| e49cfa9495 |
@@ -51,6 +51,7 @@ jobs:
|
||||
rm -rf deploy
|
||||
mkdir -p deploy
|
||||
|
||||
cp "AccessWidener/build/libs/AccessWidener-all.jar" "deploy/AccessWidener.jar"
|
||||
cp "BauSystem/build/libs/BauSystem-all.jar" "deploy/BauSystem.jar"
|
||||
cp "FightSystem/build/libs/FightSystem-all.jar" "deploy/FightSystem.jar"
|
||||
cp "KotlinCore/build/libs/KotlinCore-all.jar" "deploy/KotlinCore.jar"
|
||||
|
||||
+22
-11
@@ -17,18 +17,29 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
plugins {
|
||||
`java-library`
|
||||
alias(libs.plugins.shadow)
|
||||
}
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.contents.PlainTextContents;
|
||||
dependencies {
|
||||
implementation("org.ow2.asm:asm:9.7")
|
||||
implementation("org.ow2.asm:asm-commons:9.7")
|
||||
}
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@UtilityClass
|
||||
public class FlatteningWrapper {
|
||||
|
||||
public Object formatDisplayName(String displayName) {
|
||||
return displayName != null ? Optional.of((Object) MutableComponent.create(PlainTextContents.create(displayName))) : Optional.empty();
|
||||
tasks.shadowJar {
|
||||
manifest {
|
||||
attributes(
|
||||
"Manifest-Version" to "1.0",
|
||||
"Build-Jdk-Spec" to "21",
|
||||
"Main-Class" to "de.steamwar.Main",
|
||||
"Premain-Class" to "de.steamwar.Agent",
|
||||
"Can-Retransform-Classes" to "true",
|
||||
"Can-Redefine-Classes" to "true",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
dependsOn(tasks.shadowJar)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
/**
|
||||
* A single parsed line from a .accesswidener file.
|
||||
* <p>
|
||||
* Examples:
|
||||
* accessible class net/minecraft/server/level/ServerPlayer
|
||||
* accessible method net/minecraft/server/level/ServerPlayer getStats ()V
|
||||
* mutable field net/minecraft/world/entity/Entity id I
|
||||
* extendable class net/minecraft/world/level/chunk/LevelChunk
|
||||
*/
|
||||
public record AccessWidenerEntry(
|
||||
/** accessible | mutable | extendable (may have "transitive-" prefix) */
|
||||
String directive,
|
||||
/** class | method | field */
|
||||
String memberType,
|
||||
/** Internal class name, e.g. net/minecraft/server/level/ServerPlayer */
|
||||
String target,
|
||||
/** Method/field name, null for class entries */
|
||||
String name,
|
||||
/** Descriptor, null for class entries */
|
||||
String descriptor) {
|
||||
/**
|
||||
* Returns true if this entry targets the class with the given internal name.
|
||||
*/
|
||||
public boolean targets(String internalName) {
|
||||
return target.equals(internalName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parses Fabric-compatible .accesswidener files.
|
||||
* <p>
|
||||
* Supported format:
|
||||
* <pre>
|
||||
* accessWidener v2 named
|
||||
*
|
||||
* # comments are supported
|
||||
* accessible class net/minecraft/Foo
|
||||
* accessible method net/minecraft/Foo someMethod ()V
|
||||
* accessible field net/minecraft/Foo someField I
|
||||
* mutable field net/minecraft/Foo someField I
|
||||
* extendable class net/minecraft/Foo
|
||||
* extendable method net/minecraft/Foo someMethod ()V
|
||||
*
|
||||
* # transitive variants (expose widening to dependents)
|
||||
* transitive-accessible class net/minecraft/Foo
|
||||
* </pre>
|
||||
*/
|
||||
public final class AccessWidenerParser {
|
||||
|
||||
private AccessWidenerParser() {
|
||||
}
|
||||
|
||||
public static List<AccessWidenerEntry> parse(InputStream in) throws IOException {
|
||||
List<AccessWidenerEntry> entries = new ArrayList<>();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
|
||||
|
||||
String line;
|
||||
boolean headerSeen = false;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
// Strip inline comments
|
||||
int commentIdx = line.indexOf('#');
|
||||
if (commentIdx >= 0) line = line.substring(0, commentIdx);
|
||||
line = line.strip();
|
||||
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
if (!headerSeen) {
|
||||
// First non-blank, non-comment line must be the header
|
||||
if (!line.startsWith("accessWidener")) {
|
||||
throw new IOException("Missing accessWidener header, got: " + line);
|
||||
}
|
||||
headerSeen = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
AccessWidenerEntry entry = parseLine(line);
|
||||
if (entry != null) entries.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static AccessWidenerEntry parseLine(String line) {
|
||||
String[] parts = line.split("\\s+");
|
||||
if (parts.length < 3) return null;
|
||||
|
||||
String directive = parts[0]; // accessible / mutable / extendable / transitive-*
|
||||
String memberType = parts[1]; // class / method / field
|
||||
String target = parts[2]; // internal class name
|
||||
|
||||
return switch (memberType) {
|
||||
case "class" -> new AccessWidenerEntry(directive, "class", target, null, null);
|
||||
case "method", "field" -> {
|
||||
if (parts.length < 5) yield null;
|
||||
yield new AccessWidenerEntry(directive, memberType, target, parts[3], parts[4]);
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Java agent entry point.
|
||||
* <p>
|
||||
* At JVM startup: java -javaagent:paper-access-widener-agent.jar -jar server.jar
|
||||
* <p>
|
||||
* On attach the agent:
|
||||
* <ol>
|
||||
* <li>Find all .jar files inside the plugins folder</li>
|
||||
* <li>Scan all found jars for *.accesswidener resources</li>
|
||||
* <li>Transform any class during loading</li>
|
||||
* </ol>
|
||||
*/
|
||||
public class Agent {
|
||||
private Agent() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
private static final Logger LOG = Logger.getLogger("AccessWidenerAgent");
|
||||
|
||||
// -javaagent: startup
|
||||
public static void premain(String args, Instrumentation inst) {
|
||||
init(inst);
|
||||
}
|
||||
|
||||
private static void init(Instrumentation inst) {
|
||||
LOG.info("[AccessWidener] Agent initialising.");
|
||||
|
||||
List<AccessWidenerEntry> entries = new ArrayList<>();
|
||||
File file = new File(new File(".").getAbsoluteFile(), "plugins/");
|
||||
File[] files = file.listFiles();
|
||||
if (files == null) files = new File[0];
|
||||
for (File jarFile : files) {
|
||||
if (!jarFile.isFile()) continue;
|
||||
if (!jarFile.getName().endsWith(".jar")) continue;
|
||||
try {
|
||||
entries.addAll(Utils.findAndParseAccessWideners(jarFile.toPath()));
|
||||
} catch (IOException e) {
|
||||
LOG.warning("Failed to parse access wideners from " + jarFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
LOG.info("[AccessWidener] Loaded " + entries.size() + " access wideners.");
|
||||
|
||||
inst.addTransformer(new WideningTransformer(entries), false);
|
||||
LOG.info("[AccessWidener] Agent ready.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Uses ASM to patch class bytecode according to a list of access widener entries.
|
||||
*
|
||||
* Returns {@code null} if the class is not targeted by any entry (no-op signal
|
||||
* to the caller so it can skip the write).
|
||||
*/
|
||||
public class ClassPatcher {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger("ClassPatcher");
|
||||
|
||||
private final List<AccessWidenerEntry> entries;
|
||||
|
||||
/** Pre-computed set of targeted internal names for fast filtering. */
|
||||
private final Set<String> targets;
|
||||
|
||||
private final Set<String> targetsPublicConstructor;
|
||||
|
||||
public ClassPatcher(List<AccessWidenerEntry> entries) {
|
||||
this.entries = entries;
|
||||
this.targets = entries.stream()
|
||||
.map(AccessWidenerEntry::target)
|
||||
.flatMap(s -> {
|
||||
if (!s.contains("$")) return Stream.of(s);
|
||||
int index = s.lastIndexOf('$');
|
||||
return Stream.of(s, s.substring(0, index));
|
||||
})
|
||||
.collect(Collectors.toSet());
|
||||
this.targetsPublicConstructor = entries.stream()
|
||||
.filter(entry -> entry.directive().equals("transitive-extendable"))
|
||||
.map(AccessWidenerEntry::target)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches {@code classBytes} if {@code className} is targeted.
|
||||
*
|
||||
* @return patched bytes, or {@code null} if no changes were needed
|
||||
*/
|
||||
public byte[] patch(String className, byte[] classBytes) {
|
||||
if (!targets.contains(className)) return null;
|
||||
|
||||
try {
|
||||
ClassReader cr = new ClassReader(classBytes);
|
||||
ClassWriter cw = new ClassWriter(cr, 0);
|
||||
cr.accept(new ClassTransformer(cw, className, entries, targetsPublicConstructor.contains(className)), ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
return cw.toByteArray();
|
||||
} catch (Exception e) {
|
||||
LOG.warning("[AccessWidener] Failed to transform " + className + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClassTransformer extends ClassVisitor {
|
||||
|
||||
private final String internalName;
|
||||
private final List<AccessWidenerEntry> entries;
|
||||
private final boolean appendPublicConstructor;
|
||||
|
||||
public ClassTransformer(ClassVisitor cv, String internalName, List<AccessWidenerEntry> entries, boolean appendPublicConstructor) {
|
||||
super(Opcodes.ASM9, cv);
|
||||
this.internalName = internalName;
|
||||
this.entries = entries;
|
||||
this.appendPublicConstructor = appendPublicConstructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
int newAccess = access;
|
||||
for (AccessWidenerEntry e : entries) {
|
||||
if (!e.targets(internalName) || !"class".equals(e.memberType())) continue;
|
||||
newAccess = applyDirective(e.directive(), newAccess, false);
|
||||
}
|
||||
if (appendPublicConstructor) {
|
||||
MethodVisitor methodVisitor = visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
methodVisitor.visitCode();
|
||||
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
methodVisitor.visitMethodInsn(
|
||||
Opcodes.INVOKESPECIAL,
|
||||
"java/lang/Object",
|
||||
"<init>",
|
||||
"()V",
|
||||
false
|
||||
);
|
||||
methodVisitor.visitInsn(Opcodes.RETURN);
|
||||
methodVisitor.visitMaxs(1, 1);
|
||||
methodVisitor.visitEnd();
|
||||
}
|
||||
super.visit(version, newAccess, name, signature, superName, interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInnerClass(String name, String outerName, String innerName, int access) {
|
||||
int newAccess = access;
|
||||
for (AccessWidenerEntry e : entries) {
|
||||
if (!e.target().equals(name) || !"class".equals(e.memberType())) continue;
|
||||
newAccess = applyDirective(e.directive(), newAccess, false);
|
||||
}
|
||||
super.visitInnerClass(name, outerName, innerName, newAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
int newAccess = access;
|
||||
for (AccessWidenerEntry e : entries) {
|
||||
if (!e.targets(internalName) || !"method".equals(e.memberType())) continue;
|
||||
if (!name.equals(e.name()) || !descriptor.equals(e.descriptor())) continue;
|
||||
newAccess = applyDirective(e.directive(), newAccess, false);
|
||||
}
|
||||
return super.visitMethod(newAccess, name, descriptor, signature, exceptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
|
||||
int newAccess = access;
|
||||
for (AccessWidenerEntry e : entries) {
|
||||
if (!e.targets(internalName) || !"field".equals(e.memberType())) continue;
|
||||
if (!name.equals(e.name())) continue;
|
||||
newAccess = applyDirective(e.directive(), newAccess, true);
|
||||
}
|
||||
return super.visitField(newAccess, name, descriptor, signature, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a directive to an access bitmask.
|
||||
*
|
||||
* @param directive accessible / mutable / extendable (with optional "transitive-" prefix)
|
||||
* @param access current access flags
|
||||
* @param isField true when processing a field (mutable removes final)
|
||||
*/
|
||||
private static int applyDirective(String directive, int access, boolean isField) {
|
||||
// Strip transitive- prefix — the widening itself is the same
|
||||
String effective = directive.startsWith("transitive-") ? directive.substring("transitive-".length()) : directive;
|
||||
|
||||
return switch (effective) {
|
||||
case "accessible" -> makePublic(access);
|
||||
case "extendable" -> makePublic(removeFinal(access));
|
||||
case "mutable" -> isField ? removeFinal(access) : access;
|
||||
default -> access;
|
||||
};
|
||||
}
|
||||
|
||||
private static int makePublic(int access) {
|
||||
return (access & ~(Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) | Opcodes.ACC_PUBLIC;
|
||||
}
|
||||
|
||||
private static int removeFinal(int access) {
|
||||
return access & ~Opcodes.ACC_FINAL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Command-line tool that produces a widened copy of a JAR for use as a
|
||||
* compile-time stub in IntelliJ / Gradle.
|
||||
*
|
||||
* Usage:
|
||||
* java -jar jar-widener.jar <input.jar> <output.jar> [file.accesswidener ...]
|
||||
*
|
||||
* The output JAR is identical to the input JAR except that every class
|
||||
* targeted by the access widener entries has its access flags patched:
|
||||
* accessible → public
|
||||
* extendable → public + non-final
|
||||
* mutable → non-final field
|
||||
*
|
||||
* Intended for use as a Gradle task so IntelliJ sees the already-widened
|
||||
* class when you Ctrl+click NMS code, and javac compiles without complaints.
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
System.err.println("Usage: jar-widener <input.jar> <output.jar> [*.accesswidener ...]");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
Path inputJar = Path.of(args[0]);
|
||||
Path outputJar = Path.of(args[1]);
|
||||
|
||||
if (!Files.exists(inputJar)) {
|
||||
System.err.println("Input JAR not found: " + inputJar);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// --- Collect all access widener entries ---
|
||||
List<AccessWidenerEntry> entries = new ArrayList<>();
|
||||
|
||||
if (args.length > 2) {
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
Path awFile = Path.of(args[i]);
|
||||
if (!Files.exists(awFile)) {
|
||||
System.err.println("Warning: access widener file not found, skipping: " + awFile);
|
||||
continue;
|
||||
}
|
||||
try (InputStream in = Files.newInputStream(awFile)) {
|
||||
List<AccessWidenerEntry> parsed = AccessWidenerParser.parse(in);
|
||||
System.out.println("Loaded " + parsed.size() + " entries from " + awFile.getFileName());
|
||||
entries.addAll(parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entries.isEmpty()) {
|
||||
System.out.println("No access widener entries found — copying JAR unchanged.");
|
||||
Files.createDirectories(outputJar.getParent());
|
||||
Files.copy(inputJar, outputJar, StandardCopyOption.REPLACE_EXISTING);
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Widening " + inputJar.getFileName()
|
||||
+ " with " + entries.size() + " total entr"
|
||||
+ (entries.size() == 1 ? "y" : "ies") + "...");
|
||||
|
||||
// --- Copy input → output, transforming .class files in place ---
|
||||
Files.createDirectories(outputJar.getParent());
|
||||
Files.copy(inputJar, outputJar, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
ClassPatcher patcher = new ClassPatcher(entries);
|
||||
|
||||
try (FileSystem fs = FileSystems.newFileSystem(outputJar)) {
|
||||
// Walk every .class entry in the JAR
|
||||
try (var stream = Files.walk(fs.getPath("/"))) {
|
||||
stream.filter(p -> p.toString().endsWith(".class"))
|
||||
.forEach(classPath -> patchClass(fs, classPath, patcher));
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Done. Widened JAR written to " + outputJar);
|
||||
}
|
||||
|
||||
private static void patchClass(FileSystem fs, Path classPath, ClassPatcher patcher) {
|
||||
// Derive internal class name from path e.g. /net/minecraft/Foo.class → net/minecraft/Foo
|
||||
String internalName = classPath.toString()
|
||||
.replaceFirst("^/", "")
|
||||
.replace(".class", "");
|
||||
|
||||
try {
|
||||
byte[] original = Files.readAllBytes(classPath);
|
||||
byte[] patched = patcher.patch(internalName, original);
|
||||
|
||||
if (patched != null) {
|
||||
Files.write(classPath, patched);
|
||||
System.out.println(" Widened: " + internalName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(" Warning: failed to patch " + internalName + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger("AccessWidenerAgent");
|
||||
|
||||
private Utils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static List<AccessWidenerEntry> findAndParseAccessWideners(Path jarPath) throws IOException {
|
||||
List<AccessWidenerEntry> results = new ArrayList<>();
|
||||
|
||||
try (ZipFile zip = new ZipFile(jarPath.toFile())) {
|
||||
Enumeration<? extends ZipEntry> entries = zip.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
if (entry.isDirectory() || !entry.getName().endsWith(".accesswidener")) continue;
|
||||
|
||||
try (InputStream in = zip.getInputStream(entry)) {
|
||||
results.addAll(AccessWidenerParser.parse(in));
|
||||
} catch (IOException e) {
|
||||
LOG.warning("[AccessWidener] Failed to parse " + entry.getName()
|
||||
+ " in " + jarPath.getFileName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Transforms class bytecode to apply access widening rules.
|
||||
* <p>
|
||||
* Also monitors for new plugin ClassLoaders appearing (when plugins load after
|
||||
* the agent attaches) and automatically picks up their .accesswidener files.
|
||||
*/
|
||||
public class WideningTransformer implements ClassFileTransformer {
|
||||
|
||||
private final ClassPatcher patcher;
|
||||
|
||||
public WideningTransformer(List<AccessWidenerEntry> entries) {
|
||||
patcher = new ClassPatcher(entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
|
||||
return patcher.patch(className, classfileBuffer);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
plugins {
|
||||
steamwar.java
|
||||
widener
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
@@ -47,3 +48,7 @@ dependencies {
|
||||
implementation(libs.luaj)
|
||||
implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar"))
|
||||
}
|
||||
|
||||
widener {
|
||||
fromCatalog(libs.nms)
|
||||
}
|
||||
|
||||
@@ -834,6 +834,10 @@ SKIN_NO_REGION = §7You are not in a region with a changealbe skin
|
||||
SKIN_ALREADY_EXISTS = §cThis skin already exists like this
|
||||
SKIN_MESSAGE = §7Skin created
|
||||
SKIN_MESSAGE_HOVER = §eClick to copy for YoyoNow and send
|
||||
# Blast Resistance
|
||||
BLASTRESISTANCE_HELP = §8/§eblastresistance §8-§7 Calculate min/max and average blast resistance of current clipboard
|
||||
BLASTRESISTANCE_NO_CLIPBOARD = §cYou currently do not have a clipboard to be used.
|
||||
BLASTRESISTANCE_RESULT = §7BlastResistance §8>>§7 Min§8: §e{0}§7 Max§8: §e{1}§7 Avg§8: §e{2}
|
||||
# Panzern
|
||||
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Armor your WorldEdit selection
|
||||
PANZERN_PREPARE1 = §71. Check, if barrels reach until border of armor.
|
||||
|
||||
@@ -772,6 +772,10 @@ SKIN_NO_REGION = §7Du steht in keiner Region, welche mit einem Skin versehen we
|
||||
SKIN_ALREADY_EXISTS = §cDieser Skin existiert in der Form bereits
|
||||
SKIN_MESSAGE = §7Skin erstellt
|
||||
SKIN_MESSAGE_HOVER = §eKlicken zum kopieren für YoyoNow und an diesen senden
|
||||
# Blast Resistance
|
||||
BLASTRESISTANCE_HELP = §8/§eblastresistance §8-§7 Minimal-, Maximal- und durchschnittliche Sprengfestigkeit des aktuellen Inhalts der Zwischenablage berechnen
|
||||
BLASTRESISTANCE_NO_CLIPBOARD = §cDerzeit steht Ihnen keine Zwischenablage zur Verfügung.
|
||||
BLASTRESISTANCE_RESULT = §7BlastResistance §8>>§7 Min§8: §e{0}§7 Max§8: §e{1}§7 Avg§8: §e{2}
|
||||
# Panzern
|
||||
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Panzer deine WorldEdit Auswahl
|
||||
PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze führen.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
accessWidener v2 named
|
||||
|
||||
# For NoClipCommand
|
||||
accessible field net/minecraft/server/level/ServerPlayerGameMode gameModeForPlayer Lnet/minecraft/world/level/GameType;
|
||||
|
||||
# For PlaceItemUtils
|
||||
accessible field org/bukkit/craftbukkit/block/CraftBlockState position Lnet/minecraft/core/BlockPos;
|
||||
mutable field org/bukkit/craftbukkit/block/CraftBlockState position Lnet/minecraft/core/BlockPos;
|
||||
accessible field org/bukkit/craftbukkit/block/CraftBlockState world Lorg/bukkit/craftbukkit/CraftWorld;
|
||||
mutable field org/bukkit/craftbukkit/block/CraftBlockState world Lorg/bukkit/craftbukkit/CraftWorld;
|
||||
|
||||
# For TickManager
|
||||
accessible field net/minecraft/server/ServerTickRateManager remainingSprintTicks J
|
||||
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.configplayer.ConfigConverter;
|
||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||
import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin;
|
||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
@@ -112,9 +111,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
if (any instanceof ConfigConverter) {
|
||||
Config.addConfigConverter((ConfigConverter) any);
|
||||
}
|
||||
if (any instanceof BoundingBoxLoader) {
|
||||
((BoundingBoxLoader) any).load();
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
|
||||
+15
-14
@@ -21,9 +21,7 @@ package de.steamwar.bausystem.features.design.endstone;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.entity.*;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -59,15 +57,15 @@ public class DesignEndStone {
|
||||
.filter(material -> material.getBlastResistance() > region.getGameModeConfig().Schematic.MaxDesignBlastResistance)
|
||||
.collect(Collectors.toSet());
|
||||
calculateFromBottom = region.getGameModeConfig().Arena.NoFloor;
|
||||
}
|
||||
|
||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||
Location location = new Location(WORLD, rEntity.getX(), rEntity.getY(), rEntity.getZ());
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
location.getBlock().breakNaturally();
|
||||
calc();
|
||||
}, 1);
|
||||
});
|
||||
private void interact(Player player, RInteraction entity, REntityAction action) {
|
||||
if (action != REntityAction.ATTACK) return;
|
||||
Location location = new Location(WORLD, entity.getX(), entity.getY(), entity.getZ());
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
location.getBlock().breakNaturally();
|
||||
calc();
|
||||
}, 1);
|
||||
}
|
||||
|
||||
public void calc() {
|
||||
@@ -110,12 +108,15 @@ public class DesignEndStone {
|
||||
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
||||
|
||||
if (material != Material.WATER && material != Material.LAVA && limited.contains(material)) {
|
||||
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
||||
Location location = new Location(WORLD, cx, cy, cz);
|
||||
if (!locations.add(location)) break;
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
||||
entity.setNoGravity(true);
|
||||
RBlockDisplay entity = new RBlockDisplay(entityServer, location);
|
||||
entity.setBlock(Material.RED_STAINED_GLASS.createBlockData());
|
||||
entity.setGlowing(true);
|
||||
entities.add(entity);
|
||||
RInteraction interaction = new RInteraction(entityServer, location);
|
||||
interaction.setCallback(this::interact);
|
||||
entities.add(interaction);
|
||||
break;
|
||||
} else if (!material.isAir() && material != Material.WATER && material != Material.LAVA) {
|
||||
break;
|
||||
|
||||
+10
-9
@@ -26,8 +26,9 @@ import de.steamwar.bausystem.features.autostart.AutostartListener;
|
||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.entity.RBlockDisplay;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.entity.RInteraction;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@@ -58,10 +59,6 @@ public class Detonator {
|
||||
@Override
|
||||
public void onMount(SWPlayer player) {
|
||||
entities.addPlayer(player.getPlayer());
|
||||
entities.setCallback((player1, entity, action) -> {
|
||||
Vector vector = new Vector(entity.getX(), entity.getY(), entity.getZ());
|
||||
DetonatorListener.addLocationToDetonator(vector.toLocation(player.getWorld()).getBlock().getLocation(), player1);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,8 +67,6 @@ public class Detonator {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Vector HALF = new Vector(0.5, 0, 0.5);
|
||||
|
||||
public static boolean isDetonator(ItemStack itemStack) {
|
||||
return ItemStorage.isDetonator(itemStack);
|
||||
}
|
||||
@@ -79,8 +74,14 @@ public class Detonator {
|
||||
public static void showDetonator(Player p, List<Location> locs) {
|
||||
DetonatorComponent detonatorComponent = SWPlayer.of(p).getComponentOrDefault(DetonatorComponent.class, DetonatorComponent::new);
|
||||
locs.forEach(location -> {
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(detonatorComponent.entities, location.clone().add(HALF), Material.RED_STAINED_GLASS);
|
||||
entity.setNoGravity(true);
|
||||
RBlockDisplay blockDisplay = new RBlockDisplay(detonatorComponent.entities, location);
|
||||
blockDisplay.setBlock(Material.RED_STAINED_GLASS.createBlockData());
|
||||
|
||||
RInteraction interaction = new RInteraction(detonatorComponent.entities, location);
|
||||
interaction.setCallback((player, entity, action) -> {
|
||||
Vector vector = new Vector(entity.getX(), entity.getY(), entity.getZ());
|
||||
DetonatorListener.addLocationToDetonator(vector.toLocation(player.getWorld()).getBlock().getLocation(), player);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+8
-13
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -17,20 +17,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
package de.steamwar.bausystem.features.experimental;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
|
||||
public class TickEndEvent extends Event {
|
||||
@Linked
|
||||
public class ExperimentalCommand extends SWCommand {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
public ExperimentalCommand() {
|
||||
super("experimental", "experiment");
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.experimental.redstone_engine;
|
||||
|
||||
import de.steamwar.bausystem.features.experimental.ExperimentalCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import io.papermc.paper.configuration.WorldConfiguration;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.title.TitlePart;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@AbstractSWCommand.PartOf(ExperimentalCommand.class)
|
||||
@Linked
|
||||
public class RedstoneEngine extends SWCommand implements Listener, ScoreboardElement {
|
||||
|
||||
public RedstoneEngine() {
|
||||
super("");
|
||||
}
|
||||
|
||||
private WorldConfiguration.Misc getConfig() {
|
||||
return ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().paperConfig().misc;
|
||||
}
|
||||
|
||||
@Register("redstone")
|
||||
@Register("redstoneengine")
|
||||
public void setRedstoneEngine(Player player, @StaticValue("alternate_current") String __, WorldConfiguration.Misc.AlternateCurrentUpdateOrder updateOrder) {
|
||||
WorldConfiguration.Misc misc = getConfig();
|
||||
misc.redstoneImplementation = WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT;
|
||||
misc.alternateCurrentUpdateOrder = updateOrder;
|
||||
broadcastTitle(Bukkit.getOnlinePlayers());
|
||||
}
|
||||
|
||||
@Register("redstone")
|
||||
@Register("redstoneengine")
|
||||
public void setRedstoneEngine(Player player, WorldConfiguration.Misc.RedstoneImplementation implementation) {
|
||||
getConfig().redstoneImplementation = implementation;
|
||||
broadcastTitle(Bukkit.getOnlinePlayers());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
WorldConfiguration.Misc misc = getConfig();
|
||||
if (misc.redstoneImplementation != WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) {
|
||||
broadcastTitle(List.of(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastTitle(Collection<? extends Player> players) {
|
||||
WorldConfiguration.Misc misc = getConfig();
|
||||
Component title = switch (misc.redstoneImplementation) {
|
||||
case VANILLA -> Component.text("⚠").color(NamedTextColor.RED).append(Component.text(" Redstone: Vanilla ").color(NamedTextColor.WHITE)).append(Component.text("⚠").color(NamedTextColor.RED));
|
||||
case EIGENCRAFT -> Component.text("Redstone: Eigencraft");
|
||||
case ALTERNATE_CURRENT -> Component.text("⚠").color(NamedTextColor.RED).append(Component.text(" Redstone: AC ").color(NamedTextColor.WHITE)).append(Component.text("⚠").color(NamedTextColor.RED));
|
||||
};
|
||||
Component subtitle;
|
||||
if (misc.redstoneImplementation != WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||
subtitle = Component.text().build();
|
||||
} else {
|
||||
subtitle = switch (misc.alternateCurrentUpdateOrder) {
|
||||
case VERTICAL_FIRST_INWARD -> Component.text("Y first inwards"); // Y before XZ
|
||||
case VERTICAL_FIRST_OUTWARD -> Component.text("Y first outwards"); // XZ before Y
|
||||
case HORIZONTAL_FIRST_INWARD -> Component.text("XZ first inwards"); // Y before XZ
|
||||
case HORIZONTAL_FIRST_OUTWARD -> Component.text("XZ first outwards"); // XZ before Y
|
||||
};
|
||||
}
|
||||
players.forEach(player -> {
|
||||
player.sendTitlePart(TitlePart.TITLE, title);
|
||||
player.sendTitlePart(TitlePart.SUBTITLE, subtitle);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.FOOTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
WorldConfiguration.Misc misc = getConfig();
|
||||
switch (misc.redstoneImplementation) {
|
||||
case ALTERNATE_CURRENT:
|
||||
switch (misc.alternateCurrentUpdateOrder) {
|
||||
case VERTICAL_FIRST_INWARD:
|
||||
return "§eRedstone§8: §cAC §8(§7Y in§8)";
|
||||
case VERTICAL_FIRST_OUTWARD:
|
||||
return "§eRedstone§8: §cAC §8(§7Y out§8)";
|
||||
case HORIZONTAL_FIRST_INWARD:
|
||||
return "§eRedstone§8: §cAC §8(§7XZ in§8)";
|
||||
case HORIZONTAL_FIRST_OUTWARD:
|
||||
return "§eRedstone§8: §cAC §8(§7XZ out§8)";
|
||||
}
|
||||
return "§eRedstone§8: §cAC";
|
||||
case EIGENCRAFT:
|
||||
return null;
|
||||
case VANILLA:
|
||||
default:
|
||||
return "§eRedstone§8: §cVanilla";
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -24,9 +24,9 @@ import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.entity.RBlockDisplay;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -290,8 +290,8 @@ public class KillcheckerVisualizer {
|
||||
}
|
||||
rEntities.get(point).die();
|
||||
}
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(outlinePoints.contains(point) ? outline : inner, point.toLocation(WORLD, 0.5, 0, 0.5), MATERIALS[Math.min(count - 1, MATERIALS.length) - 1]);
|
||||
entity.setNoGravity(true);
|
||||
RBlockDisplay entity = new RBlockDisplay(outlinePoints.contains(point) ? outline : inner, point.toLocation(WORLD, 0.5, 0, 0.5));
|
||||
entity.setBlock(MATERIALS[Math.min(count - 1, MATERIALS.length) - 1].createBlockData());
|
||||
rEntities.put(point, entity);
|
||||
if (outlinePoints.contains(point)) outlinePointsCache.add(point);
|
||||
killCount.put(point, count);
|
||||
|
||||
+123
-237
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
@@ -38,77 +37,80 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.cursor.Cursor;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
public class SimulatorCursor implements Listener {
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private static Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||
private static Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
||||
private static final Set<Player> calculating = new HashSet<>();
|
||||
private static final Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||
private static final Map<Player, REntityServer> emptyTargetServers = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||
return ItemUtils.isItem(itemStack, "simulator");
|
||||
}
|
||||
|
||||
public SimulatorCursor() {
|
||||
BiFunction<Player, ServerboundMovePlayerPacket, Object> function = (player, object) -> {
|
||||
calcCursor(player);
|
||||
return object;
|
||||
};
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, function);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Rot.class, function);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, function);
|
||||
private static boolean hasSimulatorItem(Player player) {
|
||||
return isSimulatorItem(player.getInventory().getItemInMainHand()) || isSimulatorItem(player.getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
private static void scheduleCursorUpdate(Player player) {
|
||||
BauSystem.runTaskLater(BauSystem.getInstance(), () -> calcCursor(player), 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
calcCursor(event.getPlayer());
|
||||
}, 0);
|
||||
scheduleCursorUpdate(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
calcCursor(event.getPlayer());
|
||||
scheduleCursorUpdate(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
calcCursor(event.getPlayer());
|
||||
}, 1);
|
||||
scheduleCursorUpdate(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player player)) return;
|
||||
if (!Permission.BUILD.hasPermission(player)) return;
|
||||
scheduleCursorUpdate(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player player)) return;
|
||||
if (!Permission.BUILD.hasPermission(player)) return;
|
||||
scheduleCursorUpdate(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -119,10 +121,7 @@ public class SimulatorCursor implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
cursorType.remove(event.getPlayer());
|
||||
cursors.remove(event.getPlayer());
|
||||
synchronized (calculating) {
|
||||
calculating.remove(event.getPlayer());
|
||||
}
|
||||
removeCursor(event.getPlayer());
|
||||
}
|
||||
|
||||
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||
@@ -138,7 +137,7 @@ public class SimulatorCursor implements Listener {
|
||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||
if (!event.isSneaking()) return;
|
||||
Player player = event.getPlayer();
|
||||
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
||||
if (!hasSimulatorItem(player)) {
|
||||
return;
|
||||
}
|
||||
if (LAST_SNEAKS.containsKey(player)) {
|
||||
@@ -164,17 +163,10 @@ public class SimulatorCursor implements Listener {
|
||||
}
|
||||
|
||||
public static void calcCursor(Player player) {
|
||||
synchronized (calculating) {
|
||||
if (calculating.contains(player)) return;
|
||||
calculating.add(player);
|
||||
}
|
||||
if (!Permission.BUILD.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) {
|
||||
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
|
||||
if (!Permission.BUILD.hasPermission(player) || !hasSimulatorItem(player)) {
|
||||
if (removeCursor(player) | SimulatorWatcher.show(null, player)) {
|
||||
SWUtils.sendToActionbar(player, "");
|
||||
}
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,203 +175,98 @@ public class SimulatorCursor implements Listener {
|
||||
removeCursor(player);
|
||||
SimulatorWatcher.show(null, player);
|
||||
SWUtils.sendToActionbar(player, "§cGenerating Stab");
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SimulatorWatcher.show(simulator, player);
|
||||
List<REntity> entities = SimulatorWatcher.getEntitiesOfSimulator(simulator);
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), entities);
|
||||
if (rayTraceResult == null) {
|
||||
removeCursor(player);
|
||||
if (simulator == null) {
|
||||
SWUtils.sendToActionbar(player, "§eSelect Simulator");
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eOpen Simulator");
|
||||
}
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
return;
|
||||
Cursor cursor = getOrCreateCursor(player, simulator, cursorType.getOrDefault(player, CursorType.TNT));
|
||||
cursor.renderDeduplicated();
|
||||
}
|
||||
|
||||
private static Cursor getOrCreateCursor(Player player, Simulator simulator, CursorType type) {
|
||||
REntityServer targetServer = simulator == null ? emptyTargetServers.computeIfAbsent(player, __ -> new REntityServer()) : SimulatorWatcher.getEntityServerOfSimulator(simulator);
|
||||
SWPlayer swPlayer = SWPlayer.of(player);
|
||||
Optional<Cursor> activeCursor = swPlayer.getComponent(Cursor.class);
|
||||
|
||||
Cursor cursor = activeCursor.orElse(null);
|
||||
if (cursor == null || cursor.getTargetServer() != targetServer) {
|
||||
swPlayer.removeComponent(Cursor.class);
|
||||
cursor = new Cursor(
|
||||
targetServer,
|
||||
player,
|
||||
Material.GLASS,
|
||||
type.material,
|
||||
type.cursorModes,
|
||||
(location, hitEntity, action) -> handlePlayerClick(player, location, hitEntity, action),
|
||||
(location, hitEntity) -> sendCursorActionbar(player, SimulatorStorage.getSimulator(player), location != null, hitEntity.isPresent())
|
||||
);
|
||||
} else {
|
||||
cursor.setCursorMaterial(type.material);
|
||||
cursor.setAllowedCursorModes(type.cursorModes);
|
||||
}
|
||||
|
||||
showCursor(player, rayTraceResult, simulator != null);
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
private static synchronized boolean removeCursor(Player player) {
|
||||
REntityServer entityServer = cursors.get(player);
|
||||
boolean hadCursor = entityServer != null && !entityServer.getEntities().isEmpty();
|
||||
if (entityServer != null) {
|
||||
entityServer.getEntities().forEach(REntity::die);
|
||||
Optional<Cursor> cursor = SWPlayer.of(player).getComponent(Cursor.class);
|
||||
cursor.ifPresent(__ -> SWPlayer.of(player).removeComponent(Cursor.class));
|
||||
REntityServer emptyTargetServer = emptyTargetServers.remove(player);
|
||||
if (emptyTargetServer != null) {
|
||||
emptyTargetServer.close();
|
||||
}
|
||||
return hadCursor;
|
||||
return cursor.isPresent();
|
||||
}
|
||||
|
||||
private static synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
|
||||
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
|
||||
REntityServer rEntityServer = new REntityServer();
|
||||
rEntityServer.addPlayer(player);
|
||||
return rEntityServer;
|
||||
});
|
||||
|
||||
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||
Location location = hitEntity != null ? new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD) :
|
||||
type.position.apply(player, rayTraceResult).toLocation(WORLD);
|
||||
|
||||
Material material = hitEntity != null ? Material.GLASS : type.getMaterial();
|
||||
List<RFallingBlockEntity> entities = entityServer.getEntitiesByType(RFallingBlockEntity.class);
|
||||
entities.removeIf(rFallingBlockEntity -> {
|
||||
if (rFallingBlockEntity.getMaterial() != material) {
|
||||
rFallingBlockEntity.die();
|
||||
return true;
|
||||
}
|
||||
rFallingBlockEntity.move(location);
|
||||
return false;
|
||||
});
|
||||
if (entities.isEmpty()) {
|
||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, location, material);
|
||||
rFallingBlockEntity.setNoGravity(true);
|
||||
if (material == Material.GLASS) {
|
||||
rFallingBlockEntity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSimulatorSelected) {
|
||||
if (hitEntity != null) {
|
||||
SWUtils.sendToActionbar(player, "§eEdit Position");
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eAdd new " + type.name);
|
||||
}
|
||||
} else {
|
||||
private static void sendCursorActionbar(Player player, Simulator simulator, boolean hasCursorLocation, boolean hasHitEntity) {
|
||||
if (!hasCursorLocation) {
|
||||
SWUtils.sendToActionbar(player, simulator == null ? "§eSelect Simulator" : "§eOpen Simulator");
|
||||
} else if (simulator == null) {
|
||||
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector getPosFree(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||
Vector pos = result.getHitPosition();
|
||||
|
||||
BlockFace face = result.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (face.getModY() == 0 && player.isSneaking()) {
|
||||
pos.setY(pos.getY() - 0.49);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (face == null || face.getModY() == 0) {
|
||||
pos.setY(pos.getBlockY() + 0.0);
|
||||
}
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
private static Vector getPosBlockAligned(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||
Vector pos = result.getHitPosition();
|
||||
|
||||
BlockFace face = result.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
|
||||
pos.setY(pos.getBlockY() + 1.0);
|
||||
} else if (hasHitEntity) {
|
||||
SWUtils.sendToActionbar(player, "§eEdit Position");
|
||||
} else {
|
||||
pos.setY(pos.getBlockY());
|
||||
SWUtils.sendToActionbar(player, "§eAdd new " + cursorType.getOrDefault(player, CursorType.TNT).name);
|
||||
}
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CursorType {
|
||||
TNT(Material.TNT, Material.GUNPOWDER, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
||||
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||
OBSERVER(Material.OBSERVER, Material.QUARTZ, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||
TNT(Material.TNT, Material.GUNPOWDER, List.of(Cursor.CursorMode.FREE, Cursor.CursorMode.SURFACE_ALIGNED), "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
||||
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, List.of(Cursor.CursorMode.BLOCK_ALIGNED), "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||
OBSERVER(Material.OBSERVER, Material.QUARTZ, List.of(Cursor.CursorMode.BLOCK_ALIGNED), "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||
;
|
||||
|
||||
public final Material material;
|
||||
public final Material nonSelectedMaterial;
|
||||
public final BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
||||
public final List<Cursor.CursorMode> cursorModes;
|
||||
public final String name;
|
||||
public final Function<Vector, SimulatorElement<?>> elementFunction;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (!ItemUtils.isItem(event.getItem(), "simulator")) {
|
||||
private static void handlePlayerClick(Player player, Location cursorLocation, Optional<REntity> hitEntity, Action action) {
|
||||
if (!Permission.BUILD.hasPermission(player)) return;
|
||||
if (!hasSimulatorItem(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
Player player = event.getPlayer();
|
||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||
if (action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR) {
|
||||
if (simulator == null) {
|
||||
return;
|
||||
}
|
||||
SimulatorExecutor.run(event.getPlayer(), simulator, null);
|
||||
SimulatorExecutor.run(player, simulator, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) {
|
||||
if (action != Action.RIGHT_CLICK_BLOCK && action != Action.RIGHT_CLICK_AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), SimulatorWatcher.getEntitiesOfSimulator(simulator));
|
||||
if (simulator == null) {
|
||||
if (rayTraceResult == null) {
|
||||
if (cursorLocation == null) {
|
||||
SimulatorStorage.openSimulatorSelector(player);
|
||||
} else {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
|
||||
@@ -395,7 +282,7 @@ public class SimulatorCursor implements Listener {
|
||||
}
|
||||
sim = new Simulator(s);
|
||||
SimulatorStorage.addSimulator(s, sim);
|
||||
createElement(player, rayTraceResult, sim);
|
||||
createElement(player, cursorLocation, sim);
|
||||
SimulatorStorage.setSimulator(player, sim);
|
||||
});
|
||||
anvilInv.open();
|
||||
@@ -403,57 +290,56 @@ public class SimulatorCursor implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rayTraceResult == null) {
|
||||
if (cursorLocation == null) {
|
||||
new SimulatorGui(player, simulator).open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (rayTraceResult.getHitEntity() != null) {
|
||||
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
|
||||
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
||||
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
switch (elements.size()) {
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
// Open single element present in Simulator
|
||||
SimulatorElement<?> element = elements.get(0);
|
||||
SimulatorGroup group1 = element.getGroup(simulator);
|
||||
SimulatorBaseGui back = new SimulatorGui(player, simulator);
|
||||
if (group1.getElements().size() > 1) {
|
||||
back = new SimulatorGroupGui(player, simulator, group1, back);
|
||||
}
|
||||
element.open(player, simulator, group1, back);
|
||||
break;
|
||||
default:
|
||||
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||
if (parents.size() == 1) {
|
||||
// Open multi element present in Simulator in existing group
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
|
||||
} else {
|
||||
// Open multi element present in Simulator in implicit group
|
||||
SimulatorGroup group2 = new SimulatorGroup();
|
||||
group2.setMaterial(null);
|
||||
group2.getElements().addAll(elements);
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (hitEntity.isPresent()) {
|
||||
openElement(player, simulator, hitEntity.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Add new Element to current simulator
|
||||
createElement(player, rayTraceResult, simulator);
|
||||
createElement(player, cursorLocation, simulator);
|
||||
}
|
||||
|
||||
private void createElement(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, Simulator simulator) {
|
||||
private static void openElement(Player player, Simulator simulator, REntity hitEntity) {
|
||||
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
|
||||
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
||||
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
switch (elements.size()) {
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
SimulatorElement<?> element = elements.get(0);
|
||||
SimulatorGroup group1 = element.getGroup(simulator);
|
||||
SimulatorBaseGui back = new SimulatorGui(player, simulator);
|
||||
if (group1.getElements().size() > 1) {
|
||||
back = new SimulatorGroupGui(player, simulator, group1, back);
|
||||
}
|
||||
element.open(player, simulator, group1, back);
|
||||
break;
|
||||
default:
|
||||
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||
if (parents.size() == 1) {
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
|
||||
} else {
|
||||
SimulatorGroup group2 = new SimulatorGroup();
|
||||
group2.setMaterial(null);
|
||||
group2.getElements().addAll(elements);
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void createElement(Player player, Location cursorLocation, Simulator simulator) {
|
||||
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||
Vector vector = type.position.apply(player, rayTraceResult);
|
||||
Vector vector = cursorLocation.toVector();
|
||||
if (type == CursorType.REDSTONE_BLOCK) {
|
||||
vector.subtract(new Vector(0.5, 0, 0.5));
|
||||
}
|
||||
|
||||
+7
@@ -124,4 +124,11 @@ public class SimulatorWatcher {
|
||||
}
|
||||
return entityServer.getEntities();
|
||||
}
|
||||
|
||||
synchronized REntityServer getEntityServerOfSimulator(Simulator simulator) {
|
||||
if (simulator == null) {
|
||||
return null;
|
||||
}
|
||||
return entityServers.computeIfAbsent(simulator, __ -> createSim(new REntityServer(), simulator));
|
||||
}
|
||||
}
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.blastresistance;
|
||||
|
||||
import com.google.common.util.concurrent.AtomicDouble;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Linked
|
||||
public class BlastResistanceCommand extends SWCommand {
|
||||
|
||||
public BlastResistanceCommand() {
|
||||
super("blastresistance");
|
||||
}
|
||||
|
||||
@Register(description = "BLASTRESISTANCE_HELP")
|
||||
public void command(@Validator Player player) {
|
||||
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = localSession.getClipboard().getClipboards().getFirst();
|
||||
} catch (WorldEditException e) {
|
||||
BauSystem.MESSAGE.send("BLASTRESISTANCE_NO_CLIPBOARD", player);
|
||||
return;
|
||||
}
|
||||
|
||||
AtomicDouble min = new AtomicDouble(0);
|
||||
AtomicDouble max = new AtomicDouble(0);
|
||||
AtomicDouble sum = new AtomicDouble(0);
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
clipboard.forEach(blockVector3 -> {
|
||||
BlockState blockState = clipboard.getBlock(blockVector3);
|
||||
Material material = BukkitAdapter.adapt(blockState).getMaterial();
|
||||
if (material == Material.WATER || material == Material.LAVA) return;
|
||||
double blastResistance = BukkitAdapter.adapt(blockState).getMaterial().getBlastResistance();
|
||||
min.set(Math.min(min.get(), blastResistance));
|
||||
max.set(Math.max(max.get(), blastResistance));
|
||||
sum.addAndGet(blastResistance);
|
||||
count.getAndIncrement();
|
||||
});
|
||||
|
||||
BauSystem.MESSAGE.send("BLASTRESISTANCE_RESULT", player, min.get(), max.get(), sum.get() / count.get());
|
||||
}
|
||||
}
|
||||
-204
@@ -19,28 +19,17 @@
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
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.Random;
|
||||
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;
|
||||
|
||||
@ToString
|
||||
@Getter
|
||||
public class BlockBoundingBox {
|
||||
@@ -92,197 +81,4 @@ public class BlockBoundingBox {
|
||||
public double volume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
static {
|
||||
addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null);
|
||||
// addPixel(Material.COBWEB.createBlockData(), 0, 0, 0, 0, 0, 0, createItem("LAUFBAU_BLOCK_COBWEB", Material.COBWEB));
|
||||
addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null);
|
||||
|
||||
addPixel(Material.DIRT_PATH.createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", Material.DIRT_PATH));
|
||||
addPixel(Material.MUD.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND));
|
||||
|
||||
Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaNorth.setAge(2);
|
||||
cocoaNorth.setFacing(BlockFace.NORTH);
|
||||
addPixel(cocoaNorth, 4, 3, 1, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_NORTH"));
|
||||
|
||||
Cocoa cocoaSouth = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaSouth.setAge(2);
|
||||
cocoaSouth.setFacing(BlockFace.SOUTH);
|
||||
addPixel(cocoaSouth, 4, 3, 7, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_SOUTH"));
|
||||
|
||||
Cocoa cocoaWest = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaWest.setAge(2);
|
||||
cocoaWest.setFacing(BlockFace.WEST);
|
||||
addPixel(cocoaWest, 1, 3, 4, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_WEST"));
|
||||
|
||||
Cocoa cocoaEast = (Cocoa) Material.COCOA.createBlockData();
|
||||
cocoaEast.setAge(2);
|
||||
cocoaEast.setFacing(BlockFace.EAST);
|
||||
addPixel(cocoaEast, 7, 3, 4, 8, 9, 8, createItem("LAUFBAU_BLOCK_COCOA", Material.COCOA_BEANS, "LAUFBAU_FACING_EAST"));
|
||||
|
||||
TurtleEgg singleTurtleEgg = (TurtleEgg) Material.TURTLE_EGG.createBlockData();
|
||||
singleTurtleEgg.setEggs(1);
|
||||
singleTurtleEgg.setHatch(0);
|
||||
addPixel(singleTurtleEgg, 4, 0, 3, 9, 7, 9, createItem("LAUFBAU_BLOCK_TURTLE_EGG", Material.TURTLE_EGG, "LAUFBAU_COUNT_1"));
|
||||
|
||||
TurtleEgg doubleTurtleEgg = (TurtleEgg) Material.TURTLE_EGG.createBlockData();
|
||||
doubleTurtleEgg.setEggs(2);
|
||||
doubleTurtleEgg.setHatch(0);
|
||||
addPixel(doubleTurtleEgg, 1, 0, 1, 14, 7, 14, createItem("LAUFBAU_BLOCK_TURTLE_EGG", Material.TURTLE_EGG, "LAUFBAU_COUNT_2"));
|
||||
|
||||
addPixel(Material.CHEST.createBlockData(), 1, 0, 1, 14, 14, 14, createItem("LAUFBAU_BLOCK_CHEST", Material.CHEST));
|
||||
|
||||
Snow snowLayers8 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers8.setLayers(8);
|
||||
addPixel(snowLayers8, 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_8"));
|
||||
|
||||
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"), 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"), 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"), 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"), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
Snow snowLayers7 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers7.setLayers(7);
|
||||
addPixel(snowLayers7, 0, 0, 0, 16, 12, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_7"));
|
||||
|
||||
Snow snowLayers6 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers6.setLayers(6);
|
||||
addPixel(snowLayers6, 0, 0, 0, 16, 10, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_6"));
|
||||
|
||||
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), BlockBoundingBox::randomPlayerHead);
|
||||
|
||||
addPixel(Material.CAKE.createBlockData(), 1, 0, 1, 14, 8, 14, createItem("LAUFBAU_BLOCK_CAKE", Material.CAKE));
|
||||
|
||||
Slab bottomSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
||||
bottomSlab.setType(Slab.Type.BOTTOM);
|
||||
addPixel(bottomSlab, 0, 0, 0, 16, 8, 16, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_SLAB", Material.END_STONE_BRICK_SLAB, "LAUFBAU_TYPE_BOTTOM"));
|
||||
|
||||
Slab topSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
||||
topSlab.setType(Slab.Type.TOP);
|
||||
addPixel(topSlab, 0, 8, 0, 16, 8, 16, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_SLAB", Material.END_STONE_BRICK_SLAB, "LAUFBAU_TYPE_TOP"));
|
||||
|
||||
SeaPickle quadSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
quadSeaPickle.setWaterlogged(false);
|
||||
quadSeaPickle.setPickles(4);
|
||||
addPixel(quadSeaPickle, 2, 0, 2, 12, 7, 12, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_4"));
|
||||
|
||||
Campfire campfire = (Campfire) Material.CAMPFIRE.createBlockData();
|
||||
campfire.setSignalFire(false);
|
||||
campfire.setLit(false);
|
||||
addPixel(campfire, 0, 0, 0, 16, 7, 16, createItem("LAUFBAU_BLOCK_CAMPFIRE", Material.CAMPFIRE));
|
||||
|
||||
SeaPickle trippleSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
trippleSeaPickle.setWaterlogged(false);
|
||||
trippleSeaPickle.setPickles(3);
|
||||
addPixel(trippleSeaPickle, 2, 0, 2, 12, 6, 12, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_3"));
|
||||
|
||||
SeaPickle doubleSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
doubleSeaPickle.setWaterlogged(false);
|
||||
doubleSeaPickle.setPickles(2);
|
||||
addPixel(doubleSeaPickle, 3, 0, 3, 10, 6, 10, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_2"));
|
||||
|
||||
SeaPickle singleSeaPickle = (SeaPickle) Material.SEA_PICKLE.createBlockData();
|
||||
singleSeaPickle.setWaterlogged(false);
|
||||
singleSeaPickle.setPickles(1);
|
||||
addPixel(singleSeaPickle, 6, 0, 6, 4, 6, 4, createItem("LAUFBAU_BLOCK_SEA_PICKLE", Material.SEA_PICKLE, "LAUFBAU_COUNT_1"));
|
||||
|
||||
addPixel(Material.FLOWER_POT.createBlockData(), 5, 0, 5, 6, 6, 6, createItem("LAUFBAU_BLOCK_FLOWER_POT", Material.FLOWER_POT));
|
||||
|
||||
Snow snowLayers3 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers3.setLayers(3);
|
||||
addPixel(snowLayers3, 0, 0, 0, 16, 4, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_3"));
|
||||
|
||||
TrapDoor bottomTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
bottomTrapDoor.setHalf(Bisected.Half.BOTTOM);
|
||||
addPixel(bottomTrapDoor, 0, 0, 0, 16, 3, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_HALF_BOTTOM"));
|
||||
|
||||
TrapDoor topTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
topTrapDoor.setHalf(Bisected.Half.TOP);
|
||||
addPixel(topTrapDoor, 0, 13, 0, 16, 3, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_HALF_TOP"));
|
||||
|
||||
Snow snowLayers2 = (Snow) Material.SNOW.createBlockData();
|
||||
snowLayers2.setLayers(2);
|
||||
addPixel(snowLayers2, 0, 0, 0, 16, 2, 16, createItem("LAUFBAU_BLOCK_SNOW", Material.SNOW, "LAUFBAU_LAYERS_2"));
|
||||
|
||||
addPixel(Material.LILY_PAD.createBlockData(), 1, 0, 1, 14, 1.5, 14, createItem("LAUFBAU_BLOCK_LILY_PAD", Material.LILY_PAD));
|
||||
addPixel(Material.WHITE_CARPET.createBlockData(), 0, 0, 0, 16, 1, 16, createItem("LAUFBAU_BLOCK_WHITE_CARPET", Material.WHITE_CARPET));
|
||||
|
||||
Directional endRodBottomTop = (Directional) Material.END_ROD.createBlockData();
|
||||
endRodBottomTop.setFacing(BlockFace.UP);
|
||||
addPixel(endRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
|
||||
|
||||
Directional endRodNorthSouth = (Directional) Material.END_ROD.createBlockData();
|
||||
endRodNorthSouth.setFacing(BlockFace.NORTH);
|
||||
addPixel(endRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
|
||||
Directional endRodEastWest = (Directional) Material.END_ROD.createBlockData();
|
||||
endRodEastWest.setFacing(BlockFace.EAST);
|
||||
addPixel(endRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
|
||||
Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData();
|
||||
lightningRodBottomTop.setFacing(BlockFace.UP);
|
||||
addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
|
||||
|
||||
Directional lightningRodNorthSouth = (Directional) Material.LIGHTNING_ROD.createBlockData();
|
||||
lightningRodNorthSouth.setFacing(BlockFace.NORTH);
|
||||
addPixel(lightningRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
|
||||
Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData();
|
||||
lightningRodEastWest.setFacing(BlockFace.EAST);
|
||||
addPixel(lightningRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
|
||||
Waterlogged conduit = (Waterlogged) Material.CONDUIT.createBlockData();
|
||||
conduit.setWaterlogged(false);
|
||||
addPixel(conduit, 5, 5, 5, 6, 6, 6, createItem("LAUFBAU_BLOCK_CONDUIT", Material.CONDUIT));
|
||||
|
||||
TrapDoor northTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
northTrapDoor.setFacing(BlockFace.NORTH);
|
||||
northTrapDoor.setOpen(true);
|
||||
addPixel(northTrapDoor, 0, 0, 13, 16, 16, 3, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_NORTH", "LAUFBAU_OPEN"));
|
||||
|
||||
TrapDoor southTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
southTrapDoor.setFacing(BlockFace.SOUTH);
|
||||
southTrapDoor.setOpen(true);
|
||||
addPixel(southTrapDoor, 0, 0, 0, 16, 16, 3, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_SOUTH", "LAUFBAU_OPEN"));
|
||||
|
||||
TrapDoor westTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
westTrapDoor.setFacing(BlockFace.WEST);
|
||||
westTrapDoor.setOpen(true);
|
||||
addPixel(westTrapDoor, 13, 0, 0, 3, 16, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_WEST", "LAUFBAU_OPEN"));
|
||||
|
||||
TrapDoor eastTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||
eastTrapDoor.setFacing(BlockFace.EAST);
|
||||
eastTrapDoor.setOpen(true);
|
||||
addPixel(eastTrapDoor, 0, 0, 0, 3, 16, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_EAST", "LAUFBAU_OPEN"));
|
||||
}
|
||||
|
||||
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<BaseBlock> blockConsumer) {
|
||||
new BlockBoundingBox(blockData, Arrays.asList(pixelCuboid(xPixel, yPixel, zPixel, dxPixel, dyPixel, dzPixel)), swItem, blockConsumer);
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -33,6 +34,15 @@ public class Cuboid {
|
||||
private double dy;
|
||||
private double dz;
|
||||
|
||||
public Cuboid(BoundingBox boundingBox) {
|
||||
this.x = boundingBox.getMinX();
|
||||
this.y = boundingBox.getMinY();
|
||||
this.z = boundingBox.getMinZ();
|
||||
this.dx = boundingBox.getWidthX();
|
||||
this.dy = boundingBox.getHeight();
|
||||
this.dz = boundingBox.getWidthZ();
|
||||
}
|
||||
|
||||
public boolean intersects(Cuboid cuboid) {
|
||||
double minx = x - cuboid.dx;
|
||||
double miny = y - cuboid.dy;
|
||||
|
||||
+37
@@ -24,15 +24,52 @@ import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockType;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftVoxelShape;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.VoxelShape;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
public class LaufbauCommand extends SWCommand {
|
||||
|
||||
static {
|
||||
AtomicLong counter = new AtomicLong();
|
||||
AtomicReference<VoxelShape> shape = new AtomicReference<>();
|
||||
long time = System.currentTimeMillis();
|
||||
Registry.BLOCK.forEach(blockType -> {
|
||||
Block block = CraftBlockType.bukkitToMinecraftNew(blockType);
|
||||
block.getStateDefinition().getPossibleStates().forEach(blockState -> {
|
||||
VoxelShape voxelShape = new CraftVoxelShape(blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CollisionContext.empty()));
|
||||
shape.set(voxelShape);
|
||||
Material material = blockType.asMaterial();
|
||||
if (!material.isItem()) return;
|
||||
new BlockBoundingBox(
|
||||
CraftBlockData.createData(blockState),
|
||||
voxelShape.getBoundingBoxes().stream().map(Cuboid::new).collect(Collectors.toList()),
|
||||
new SWItem(material, "Item")
|
||||
);
|
||||
counter.incrementAndGet();
|
||||
});
|
||||
});
|
||||
System.out.println(System.currentTimeMillis() - time + "ms " + shape.get() + " " + counter.get());
|
||||
}
|
||||
|
||||
public LaufbauCommand() {
|
||||
super("laufbau", "laufsklave");
|
||||
}
|
||||
|
||||
-261
@@ -1,261 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.AmethystCluster;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class AmethystBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
floorSmallAmethystBud();
|
||||
ceilingSmallAmethystBud();
|
||||
northSmallAmethystBud();
|
||||
southSmallAmethystBud();
|
||||
eastSmallAmethystBud();
|
||||
westSmallAmethystBud();
|
||||
|
||||
floorMediumAmethystBud();
|
||||
ceilingMediumAmethystBud();
|
||||
northMediumAmethystBud();
|
||||
southMediumAmethystBud();
|
||||
eastMediumAmethystBud();
|
||||
westMediumAmethystBud();
|
||||
|
||||
floorLargeAmethystBud();
|
||||
ceilingLargeAmethystBud();
|
||||
northLargeAmethystBud();
|
||||
southLargeAmethystBud();
|
||||
eastLargeAmethystBud();
|
||||
westLargeAmethystBud();
|
||||
|
||||
floorAmethystCluster();
|
||||
ceilingAmethystCluster();
|
||||
northAmethystCluster();
|
||||
southAmethystCluster();
|
||||
eastAmethystCluster();
|
||||
westAmethystCluster();
|
||||
}
|
||||
|
||||
private void floorSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 4, 8, 3, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 13, 4, 8, 3, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 13, 8, 8, 3));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 0, 8, 8, 3));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 4, 4, 3, 8, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westSmallAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.SMALL_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(13, 4, 4, 3, 8, 8));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_SMALL_AMETHYST_BUD", Material.SMALL_AMETHYST_BUD, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
private void floorMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 4, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 12, 3, 10, 4, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 12, 10, 10, 4));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 4));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 4, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westMediumAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.MEDIUM_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(12, 3, 3, 4, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_MEDIUM_AMETHYST_BUD", Material.MEDIUM_AMETHYST_BUD, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
private void floorLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 5, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 11, 3, 10, 5, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 11, 10, 10, 5));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 5));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 5, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westLargeAmethystBud() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.LARGE_AMETHYST_BUD.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(11, 3, 3, 5, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_LARGE_AMETHYST_BUD", Material.LARGE_AMETHYST_BUD, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
private void floorAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.UP);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 7, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_UP"));
|
||||
}
|
||||
|
||||
private void ceilingAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 9, 3, 10, 7, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 9, 10, 10, 7));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
private void southAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 7));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 7, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
private void westAmethystCluster() {
|
||||
AmethystCluster cluster = (AmethystCluster) Material.AMETHYST_CLUSTER.createBlockData();
|
||||
cluster.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(9, 3, 3, 7, 10, 10));
|
||||
new BlockBoundingBox(cluster, cuboidList, createItem("LAUFBAU_BLOCK_AMETHYST_CLUSTER", Material.AMETHYST_CLUSTER, "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class AzaleaBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BlockData blockData = Material.FLOWERING_AZALEA.createBlockData();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(6, 0, 6, 4, 8, 4));
|
||||
new BlockBoundingBox(blockData, cuboidList, createItem("LAUFBAU_BLOCK_AZALEA", Material.FLOWERING_AZALEA));
|
||||
}
|
||||
}
|
||||
-149
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Bell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class BellBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
ceilingBell();
|
||||
|
||||
floorNorthBell();
|
||||
floorEastBell();
|
||||
|
||||
doubleWallNorthBell();
|
||||
doubleWallEastBell();
|
||||
|
||||
singleWallNorthBell();
|
||||
singleWallSouthBell();
|
||||
singleWallEastBell();
|
||||
singleWallWestBell();
|
||||
}
|
||||
|
||||
public void ceilingBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.CEILING);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 7, 2, 3, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_CEILING"));
|
||||
}
|
||||
|
||||
public void floorNorthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.FLOOR);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 4, 16, 16, 8));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void floorEastBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.FLOOR);
|
||||
bell.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 0, 8, 16, 16));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void doubleWallNorthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.DOUBLE_WALL);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 0, 2, 2, 16));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_DOUBLE_WALL", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void doubleWallEastBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.DOUBLE_WALL);
|
||||
bell.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(0, 13, 7, 16, 2, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_DOUBLE_WALL", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void singleWallNorthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 0, 2, 2, 13));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void singleWallSouthBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(7, 13, 3, 2, 2, 13));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void singleWallEastBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(3, 13, 7, 13, 2, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void singleWallWestBell() {
|
||||
Bell bell = (Bell) Material.BELL.createBlockData();
|
||||
bell.setAttachment(Bell.Attachment.SINGLE_WALL);
|
||||
bell.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 2, 8));
|
||||
cuboidList.add(pixelCuboid(5, 6, 5, 6, 8, 6));
|
||||
cuboidList.add(pixelCuboid(0, 13, 7, 13, 2, 2));
|
||||
new BlockBoundingBox(bell, cuboidList, createItem("LAUFBAU_BLOCK_BELL", Material.BELL, "LAUFBAU_ATTACHMENT_SINGLE_WALL", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.BrewingStand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class BrewingStandBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BrewingStand brewingStand = (BrewingStand) Material.BREWING_STAND.createBlockData();
|
||||
List<Cuboid> cuboids = new ArrayList<>();
|
||||
cuboids.add(pixelCuboid(1, 0, 1, 14, 2, 14));
|
||||
cuboids.add(pixelCuboid(7, 2, 7, 2, 12, 2));
|
||||
new BlockBoundingBox(brewingStand, cuboids, createItem("LAUFBAU_BLOCK_BREWING_STAND", Material.BREWING_STAND));
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Lightable;
|
||||
import org.bukkit.block.data.type.Candle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class CandleBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
caked();
|
||||
|
||||
single();
|
||||
}
|
||||
|
||||
private void caked() {
|
||||
Lightable candleCake = (Lightable) Material.CYAN_CANDLE_CAKE.createBlockData();
|
||||
candleCake.setLit(true);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(7, 8, 7, 2, 6, 2));
|
||||
new BlockBoundingBox(candleCake, cuboidList, createItem("LAUFBAU_BLOCK_CANDLE_CAKE", Material.CAKE));
|
||||
}
|
||||
|
||||
private void single() {
|
||||
Candle candle = (Candle) Material.CYAN_CANDLE.createBlockData();
|
||||
candle.setCandles(1);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(7, 0, 7, 2, 6, 2));
|
||||
new BlockBoundingBox(candle, cuboidList, createItem("LAUFBAU_BLOCK_CANDLE", Material.CYAN_CANDLE, "LAUFBAU_COUNT_1"));
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class ChainBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
bottomTopChain();
|
||||
northSouthChain();
|
||||
eastWestChain();
|
||||
}
|
||||
|
||||
private void bottomTopChain() {
|
||||
Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
|
||||
chainBottomTop.setAxis(Axis.Y);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(6.5, 0, 6.5, 3, 16, 3));
|
||||
new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
|
||||
}
|
||||
|
||||
private void northSouthChain() {
|
||||
Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
|
||||
chainBottomTop.setAxis(Axis.Z);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(6.5, 6.5, 0, 3, 3, 16));
|
||||
new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
private void eastWestChain() {
|
||||
Orientable chainBottomTop = (Orientable) Material.CHAIN.createBlockData();
|
||||
chainBottomTop.setAxis(Axis.X);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 6.5, 6.5, 16, 3, 3));
|
||||
new BlockBoundingBox(chainBottomTop, cuboidList, createItem("LAUFBAU_BLOCK_CHAIN", Material.CHAIN, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class ChorusPlantBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int ny = 0; ny < 2; ny++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int py = 0; py < 2; py++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
MultipleFacing chorusPlant = (MultipleFacing) Material.CHORUS_PLANT.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(3, 3, 3, 10, 10, 10));
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
chorusPlant.setFace(BlockFace.WEST, true);
|
||||
cuboidList.add(pixelCuboid(0, 3, 3, 3, 10, 10));
|
||||
}
|
||||
if (ny == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_DOWN");
|
||||
chorusPlant.setFace(BlockFace.DOWN, true);
|
||||
cuboidList.add(pixelCuboid(3, 0, 3, 10, 3, 10));
|
||||
}
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
chorusPlant.setFace(BlockFace.NORTH, true);
|
||||
cuboidList.add(pixelCuboid(3, 3, 0, 10, 10, 3));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
chorusPlant.setFace(BlockFace.EAST, true);
|
||||
cuboidList.add(pixelCuboid(13, 3, 3, 3, 10, 10));
|
||||
}
|
||||
if (py == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_UP");
|
||||
chorusPlant.setFace(BlockFace.UP, true);
|
||||
cuboidList.add(pixelCuboid(3, 13, 3, 10, 3, 10));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
chorusPlant.setFace(BlockFace.SOUTH, true);
|
||||
cuboidList.add(pixelCuboid(3, 3, 13, 10, 10, 3));
|
||||
}
|
||||
new BlockBoundingBox(chorusPlant, cuboidList, createItem("LAUFBAU_BLOCK_CHORUS_PLANT", Material.CHORUS_PLANT, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class DragonEggBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BlockData blockData = Material.DRAGON_EGG.createBlockData();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(1, 0, 1, 14, 16, 14));
|
||||
new BlockBoundingBox(blockData, cuboidList, createItem("LAUFBAU_BLOCK_DRAGON_EGG", Material.DRAGON_EGG));
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.BigDripleaf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class DripLeafBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
tiltNone();
|
||||
tiltPartial();
|
||||
}
|
||||
|
||||
private void tiltNone() {
|
||||
BigDripleaf bigDripleaf = (BigDripleaf) Material.BIG_DRIPLEAF.createBlockData();
|
||||
bigDripleaf.setTilt(BigDripleaf.Tilt.NONE);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 11, 0, 16, 4, 16));
|
||||
new BlockBoundingBox(bigDripleaf, cuboidList, createItem("LAUFBAU_BLOCK_BIG_DRIP_LEAF", Material.BIG_DRIPLEAF, "LAUFBAU_TILT_NONE"));
|
||||
}
|
||||
|
||||
private void tiltPartial() {
|
||||
BigDripleaf bigDripleaf = (BigDripleaf) Material.BIG_DRIPLEAF.createBlockData();
|
||||
bigDripleaf.setTilt(BigDripleaf.Tilt.PARTIAL);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 11, 0, 16, 2, 16));
|
||||
new BlockBoundingBox(bigDripleaf, cuboidList, createItem("LAUFBAU_BLOCK_BIG_DRIP_LEAF", Material.BIG_DRIPLEAF, "LAUFBAU_TILT_PARTIAL"));
|
||||
}
|
||||
}
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Fence;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class FencesBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
Fence fence = (Fence) Material.NETHER_BRICK_FENCE.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(6, 0, 6, 4, 24, 4));
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
fence.setFace(BlockFace.NORTH, true);
|
||||
cuboidList.add(pixelCuboid(6, 0, 0, 4, 24, 6));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
fence.setFace(BlockFace.SOUTH, true);
|
||||
cuboidList.add(pixelCuboid(6, 0, 10, 4, 24, 6));
|
||||
}
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
fence.setFace(BlockFace.WEST, true);
|
||||
cuboidList.add(pixelCuboid(0, 0, 6, 6, 24, 4));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
fence.setFace(BlockFace.EAST, true);
|
||||
cuboidList.add(pixelCuboid(10, 0, 6, 6, 24, 4));
|
||||
}
|
||||
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_NETHER_BRICK_FENCE", Material.NETHER_BRICK_FENCE, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-157
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.FaceAttachable;
|
||||
import org.bukkit.block.data.type.Grindstone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class GrindstoneBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
floorNorthGrindstone();
|
||||
floorEastGrindstone();
|
||||
|
||||
ceilingNorthGrindstone();
|
||||
ceilingEastGrindstone();
|
||||
|
||||
wallNorthGrindstone();
|
||||
wallSouthGrindstone();
|
||||
wallEastGrindstone();
|
||||
wallWestGrindstone();
|
||||
}
|
||||
|
||||
public void floorNorthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
|
||||
grindstone.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 4, 2, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 0, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(12, 0, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(2, 7, 5, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 7, 5, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void floorEastGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
|
||||
grindstone.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(2, 4, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(6, 0, 2, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(6, 0, 12, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(5, 7, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(5, 7, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_FLOOR", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void ceilingNorthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.CEILING);
|
||||
grindstone.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 2, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 9, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(12, 9, 6, 2, 7, 4));
|
||||
cuboidList.add(pixelCuboid(2, 3, 5, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 3, 5, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_CEILING", "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void ceilingEastGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.CEILING);
|
||||
grindstone.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(2, 0, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(6, 9, 2, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(6, 9, 12, 4, 7, 2));
|
||||
cuboidList.add(pixelCuboid(5, 3, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(5, 3, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_CEILING", "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void wallNorthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 2, 0, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 6, 9, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(12, 6, 9, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(2, 5, 3, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 5, 3, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void wallSouthGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 2, 4, 8, 12, 12));
|
||||
cuboidList.add(pixelCuboid(2, 6, 0, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(12, 6, 0, 2, 4, 7));
|
||||
cuboidList.add(pixelCuboid(2, 5, 7, 2, 6, 6));
|
||||
cuboidList.add(pixelCuboid(12, 5, 7, 2, 6, 6));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void wallEastGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 2, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(0, 6, 2, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(0, 6, 12, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(7, 5, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(7, 5, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void wallWestGrindstone() {
|
||||
Grindstone grindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
|
||||
grindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
|
||||
grindstone.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 2, 4, 12, 12, 8));
|
||||
cuboidList.add(pixelCuboid(9, 6, 2, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(9, 6, 12, 7, 4, 2));
|
||||
cuboidList.add(pixelCuboid(3, 5, 2, 6, 6, 2));
|
||||
cuboidList.add(pixelCuboid(3, 5, 12, 6, 6, 2));
|
||||
new BlockBoundingBox(grindstone, cuboidList, createItem("LAUFBAU_BLOCK_GRINDSTONE", Material.GRINDSTONE, "LAUFBAU_ATTACHMENT_WALL", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Hopper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class HopperBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
downHopper();
|
||||
northHopper();
|
||||
southHopper();
|
||||
eastHopper();
|
||||
westHopper();
|
||||
}
|
||||
|
||||
public void downHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.DOWN);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(6, 0, 6, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_FLOOR"));
|
||||
}
|
||||
|
||||
public void northHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(6, 4, 0, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_NORTH"));
|
||||
}
|
||||
|
||||
public void southHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(6, 4, 12, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_SOUTH"));
|
||||
}
|
||||
|
||||
public void eastHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(12, 4, 6, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_EAST"));
|
||||
}
|
||||
|
||||
public void westHopper() {
|
||||
Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
|
||||
hopper.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 10, 0, 16, 6, 16));
|
||||
cuboidList.add(pixelCuboid(4, 4, 4, 8, 6, 8));
|
||||
cuboidList.add(pixelCuboid(0, 4, 6, 4, 4, 4));
|
||||
new BlockBoundingBox(hopper, cuboidList, createItem("LAUFBAU_BLOCK_HOPPER", Material.HOPPER, "LAUFBAU_CONNECTION_WEST"));
|
||||
}
|
||||
}
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Fence;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class IronBarBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
Fence fence = (Fence) Material.IRON_BARS.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(7, 0, 7, 2, 16, 2));
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
fence.setFace(BlockFace.NORTH, true);
|
||||
cuboidList.add(pixelCuboid(7, 0, 0, 2, 16, 7));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
fence.setFace(BlockFace.SOUTH, true);
|
||||
cuboidList.add(pixelCuboid(7, 0, 9, 2, 16, 7));
|
||||
}
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
fence.setFace(BlockFace.WEST, true);
|
||||
cuboidList.add(pixelCuboid(0, 0, 7, 7, 16, 2));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
fence.setFace(BlockFace.EAST, true);
|
||||
cuboidList.add(pixelCuboid(9, 0, 7, 7, 16, 2));
|
||||
}
|
||||
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_IRON_BARS", Material.IRON_BARS, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.type.Lantern;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class LanternBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
lantern();
|
||||
hangingLantern();
|
||||
}
|
||||
|
||||
public void lantern() {
|
||||
Lantern lantern = (Lantern) Material.LANTERN.createBlockData();
|
||||
lantern.setHanging(false);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(5, 0, 5, 6, 7, 6));
|
||||
cuboidList.add(pixelCuboid(6, 7, 6, 4, 2, 4));
|
||||
new BlockBoundingBox(lantern, cuboidList, createItem("LAUFBAU_BLOCK_LANTERN", Material.LANTERN));
|
||||
}
|
||||
|
||||
public void hangingLantern() {
|
||||
Lantern lantern = (Lantern) Material.LANTERN.createBlockData();
|
||||
lantern.setHanging(true);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(5, 1, 5, 6, 7, 6));
|
||||
cuboidList.add(pixelCuboid(6, 8, 6, 4, 2, 4));
|
||||
new BlockBoundingBox(lantern, cuboidList, createItem("LAUFBAU_BLOCK_LANTERN", Material.LANTERN, "LAUFBAU_HANGING"));
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class LecternBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
BlockData blockData = Material.LECTERN.createBlockData();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 2, 16));
|
||||
cuboidList.add(pixelCuboid(4, 2, 4, 8, 12, 8));
|
||||
new BlockBoundingBox(blockData, cuboidList, createItem("LAUFBAU_BLOCK_LECTERN", Material.LECTERN));
|
||||
}
|
||||
}
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class StairBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
straightBottomNorthStair();
|
||||
straightBottomSouthStair();
|
||||
straightBottomEastStair();
|
||||
straightBottomWestStair();
|
||||
|
||||
straightTopNorthStair();
|
||||
straightTopSouthStair();
|
||||
straightTopEastStair();
|
||||
straightTopWestStair();
|
||||
|
||||
outerLeftBottomNorthStair();
|
||||
outerLeftBottomSouthStair();
|
||||
outerLeftBottomEastStair();
|
||||
outerLeftBottomWestStair();
|
||||
|
||||
outerLeftTopNorthStair();
|
||||
outerLeftTopSouthStair();
|
||||
outerLeftTopEastStair();
|
||||
outerLeftTopWestStair();
|
||||
|
||||
innerLeftBottomNorthStair();
|
||||
innerLeftBottomSouthStair();
|
||||
innerLeftBottomEastStair();
|
||||
innerLeftBottomWestStair();
|
||||
|
||||
innerLeftTopNorthStair();
|
||||
innerLeftTopSouthStair();
|
||||
innerLeftTopEastStair();
|
||||
innerLeftTopWestStair();
|
||||
}
|
||||
|
||||
public void straightBottomNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void straightBottomSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void straightBottomEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 8, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void straightBottomWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void straightTopNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void straightTopSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 16, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void straightTopEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 0, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void straightTopWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.STRAIGHT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 8, 8, 16));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_STRAIGHT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void outerLeftBottomWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void outerLeftTopNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void outerLeftTopSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void outerLeftTopEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(8, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void outerLeftTopWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.OUTER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_OUTER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 8, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void innerLeftBottomWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.BOTTOM);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 8, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_BOTTOM", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
|
||||
public void innerLeftTopNorthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.NORTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_NORTH"));
|
||||
}
|
||||
|
||||
public void innerLeftTopSouthStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.SOUTH);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_SOUTH"));
|
||||
}
|
||||
|
||||
public void innerLeftTopEastStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.EAST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(8, 0, 8, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_EAST"));
|
||||
}
|
||||
|
||||
public void innerLeftTopWestStair() {
|
||||
Stairs stairs = (Stairs) Material.END_STONE_BRICK_STAIRS.createBlockData();
|
||||
stairs.setShape(Stairs.Shape.INNER_LEFT);
|
||||
stairs.setHalf(Stairs.Half.TOP);
|
||||
stairs.setFacing(BlockFace.WEST);
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16));
|
||||
cuboidList.add(pixelCuboid(0, 0, 8, 16, 8, 8));
|
||||
cuboidList.add(pixelCuboid(0, 0, 0, 8, 8, 8));
|
||||
new BlockBoundingBox(stairs, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_STAIRS", Material.END_STONE_BRICK_STAIRS, "LAUFBAU_SHAPE_INNER_LEFT", "LAUFBAU_HALF_TOP", "LAUFBAU_FACING_WEST"));
|
||||
}
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes;
|
||||
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Wall;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem;
|
||||
import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid;
|
||||
|
||||
@Linked
|
||||
public class WallBoundingBox implements BoundingBoxLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
v18();
|
||||
}
|
||||
|
||||
private void v18() {
|
||||
for (int nx = 0; nx < 2; nx++) {
|
||||
for (int nz = 0; nz < 2; nz++) {
|
||||
for (int px = 0; px < 2; px++) {
|
||||
for (int pz = 0; pz < 2; pz++) {
|
||||
Wall fence = (Wall) Material.END_STONE_BRICK_WALL.createBlockData();
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Cuboid> cuboidList = new ArrayList<>();
|
||||
cuboidList.add(pixelCuboid(4, 0, 4, 8, 24, 8));
|
||||
if (nz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_NORTH");
|
||||
fence.setHeight(BlockFace.NORTH, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4));
|
||||
}
|
||||
if (pz == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_SOUTH");
|
||||
fence.setHeight(BlockFace.SOUTH, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4));
|
||||
}
|
||||
if (nx == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_WEST");
|
||||
fence.setHeight(BlockFace.WEST, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6));
|
||||
}
|
||||
if (px == 1) {
|
||||
lore.add("LAUFBAU_CONNECTION_EAST");
|
||||
fence.setHeight(BlockFace.EAST, Wall.Height.LOW);
|
||||
cuboidList.add(pixelCuboid(12, 0, 5, 4, 24, 6));
|
||||
}
|
||||
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_WALL", Material.END_STONE_BRICK_WALL, lore.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -31,6 +31,7 @@ import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.legacy.TechHider;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.linkage.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
@@ -72,7 +72,7 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTickEnd(TickEndEvent event) {
|
||||
public void onTickEnd(ServerTickEndEvent event) {
|
||||
bossbar();
|
||||
}
|
||||
|
||||
|
||||
@@ -143,14 +143,6 @@ public class Trace {
|
||||
} else {
|
||||
entityServer = new REntityServer();
|
||||
entityServer.addPlayer(player);
|
||||
entityServer.setCallback((p, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.INTERACT) {
|
||||
return;
|
||||
}
|
||||
if (rEntity instanceof TraceEntity) {
|
||||
((TraceEntity) rEntity).printIntoChat(p);
|
||||
}
|
||||
});
|
||||
entityServerMap.put(player, entityServer);
|
||||
}
|
||||
render(getRecords(), entityServer, playerTraceShowData);
|
||||
@@ -167,14 +159,6 @@ public class Trace {
|
||||
REntityServer entityServer = entityServerMap.computeIfAbsent(player, k -> {
|
||||
REntityServer newEntityServer = new REntityServer();
|
||||
newEntityServer.addPlayer(k);
|
||||
newEntityServer.setCallback((p, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.INTERACT) {
|
||||
return;
|
||||
}
|
||||
if (rEntity instanceof TraceEntity) {
|
||||
((TraceEntity) rEntity).printIntoChat(p);
|
||||
}
|
||||
});
|
||||
return newEntityServer;
|
||||
});
|
||||
|
||||
|
||||
+36
-4
@@ -24,13 +24,18 @@ import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.entity.RBlockDisplay;
|
||||
import de.steamwar.entity.REntityAction;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.entity.RInteraction;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import yapion.hierarchy.types.YAPIONValue;
|
||||
|
||||
import java.util.List;
|
||||
@@ -41,7 +46,16 @@ import static de.steamwar.bausystem.features.util.TNTClickListener.TNT_CLICK_DET
|
||||
/**
|
||||
* Wrapper for the rendering of a record bundle
|
||||
*/
|
||||
public class TraceEntity extends RFallingBlockEntity {
|
||||
public class TraceEntity extends RBlockDisplay {
|
||||
|
||||
private static final float TNT_VISUAL_SCALE = 0.98F;
|
||||
private static final float TNT_VISUAL_OFFSET = -TNT_VISUAL_SCALE / 2.0F;
|
||||
private static final Transformation TNT_VISUAL_TRANSFORM = new Transformation(
|
||||
new Vector3f(TNT_VISUAL_OFFSET, 0.0F, TNT_VISUAL_OFFSET),
|
||||
new Quaternionf(0, 0, 0, 1),
|
||||
new Vector3f(TNT_VISUAL_SCALE, TNT_VISUAL_SCALE, TNT_VISUAL_SCALE),
|
||||
new Quaternionf(0, 0, 0, 1)
|
||||
);
|
||||
|
||||
/**
|
||||
* The records represented by this REntity
|
||||
@@ -55,13 +69,31 @@ public class TraceEntity extends RFallingBlockEntity {
|
||||
private final String uniqueTntIdsString;
|
||||
|
||||
private final Trace trace;
|
||||
private final RInteraction hitbox;
|
||||
|
||||
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records, Trace trace) {
|
||||
super(server, location, isExplosion ? Material.RED_STAINED_GLASS : Material.TNT);
|
||||
super(server, location);
|
||||
Material material = isExplosion ? Material.RED_STAINED_GLASS : Material.TNT;
|
||||
this.records = records;
|
||||
this.trace = trace;
|
||||
uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" "));
|
||||
setNoGravity(true);
|
||||
hitbox = new RInteraction(server, location);
|
||||
hitbox.setInteractionHeight(TNT_VISUAL_SCALE);
|
||||
hitbox.setInteractionWidth(TNT_VISUAL_SCALE);
|
||||
hitbox.setCallback((player, action) -> {
|
||||
if (action == REntityAction.INTERACT) {
|
||||
printIntoChat(player);
|
||||
}
|
||||
});
|
||||
setTransform(TNT_VISUAL_TRANSFORM);
|
||||
setBlock(material.createBlockData());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
hitbox.die();
|
||||
super.die();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-5
@@ -20,8 +20,8 @@
|
||||
package de.steamwar.bausystem.features.tracer.rendering;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.entity.RBlockDisplay;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -129,8 +129,8 @@ public abstract class ViewFlag {
|
||||
|
||||
Location yLocation = previous.getLocation().clone().add(0, delta.getY(), 0);
|
||||
if (yLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && yLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
|
||||
RFallingBlockEntity y = new RFallingBlockEntity(server, yLocation, Material.WHITE_STAINED_GLASS);
|
||||
y.setNoGravity(true);
|
||||
RBlockDisplay y = new RBlockDisplay(server, yLocation);
|
||||
y.setBlock(Material.WHITE_STAINED_GLASS.createBlockData());
|
||||
}
|
||||
|
||||
Location secoundLocation;
|
||||
@@ -141,8 +141,8 @@ public abstract class ViewFlag {
|
||||
}
|
||||
|
||||
if (secoundLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && secoundLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
|
||||
RFallingBlockEntity second = new RFallingBlockEntity(server, secoundLocation, Material.WHITE_STAINED_GLASS);
|
||||
second.setNoGravity(true);
|
||||
RBlockDisplay second = new RBlockDisplay(server, secoundLocation);
|
||||
second.setBlock(Material.WHITE_STAINED_GLASS.createBlockData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -47,7 +48,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -73,19 +73,7 @@ public class BindCommand extends SWCommand implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static final CommandMap commandMap;
|
||||
|
||||
static {
|
||||
Field knownCommandsField;
|
||||
try {
|
||||
knownCommandsField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
knownCommandsField.setAccessible(true);
|
||||
commandMap = (CommandMap) knownCommandsField.get(Bukkit.getServer());
|
||||
} catch (IllegalAccessException | NoSuchFieldException var2) {
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException("Oh shit. Commands cannot be registered.", var2);
|
||||
}
|
||||
}
|
||||
private static final CommandMap commandMap = ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
|
||||
private static final NamespacedKey KEY = SWUtils.getNamespaceKey("command");
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.util;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
@@ -30,7 +29,6 @@ import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -103,10 +101,8 @@ public class NoClipCommand extends SWCommand implements Listener {
|
||||
TinyProtocol.instance.addFilter(ServerboundSetCreativeModeSlotPacket.class, third);
|
||||
}
|
||||
|
||||
private static final Reflection.Field<GameType> playerGameMode = Reflection.getField(ServerPlayerGameMode.class, GameType.class, 0);
|
||||
|
||||
private void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
playerGameMode.set(((CraftPlayer) player).getHandle().gameMode, GameType.byId(gameMode.getValue()));
|
||||
((CraftPlayer) player).getHandle().gameMode.gameModeForPlayer = GameType.byId(gameMode.getValue());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
|
||||
@@ -28,6 +28,7 @@ import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import io.papermc.paper.event.player.PlayerPickBlockEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
@@ -127,4 +128,11 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClick(PlayerPickBlockEvent event) {
|
||||
if(SPECTATORS.contains(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.techhider.legacy.TechHider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -28,6 +28,7 @@ import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.legacy.TechHider;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@@ -86,9 +85,6 @@ public class PlaceItemUtils {
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static final Reflection.Field<?> positionAccessor = Reflection.getField(CraftBlockState.class, BlockPos.class, 0);
|
||||
private static final Reflection.Field<?> worldAccessor = Reflection.getField(CraftBlockState.class, CraftWorld.class, 0);
|
||||
|
||||
/**
|
||||
* Attempt to place an {@link ItemStack} the {@link Player} is holding against a {@link Block} inside the World.
|
||||
* This can be easily used inside the {@link org.bukkit.event.player.PlayerInteractEvent} to mimik placing a
|
||||
@@ -288,8 +284,9 @@ public class PlaceItemUtils {
|
||||
} else {
|
||||
// If a BlockState is present set the Position and World to the Block you want to place
|
||||
Location blockLocation = block.getLocation();
|
||||
positionAccessor.set(blockState, new BlockPos(blockLocation.getBlockX(), blockLocation.getBlockY(), blockLocation.getBlockZ()));
|
||||
worldAccessor.set(blockState, blockLocation.getWorld());
|
||||
CraftBlockState craftBlockState = (CraftBlockState) blockState;
|
||||
craftBlockState.position = new BlockPos(blockLocation.getBlockX(), blockLocation.getBlockY(), blockLocation.getBlockZ());
|
||||
craftBlockState.world = (CraftWorld) blockLocation.getWorld();
|
||||
}
|
||||
|
||||
if (blockData.getMaterial().isSolid()) {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import net.minecraft.network.protocol.game.ClientboundTickingStatePacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -33,7 +32,6 @@ public class TickManager implements Listener {
|
||||
public static final TickManager impl = new TickManager();
|
||||
|
||||
private static final ServerTickRateManager manager = MinecraftServer.getServer().tickRateManager();
|
||||
private static final Reflection.Field<Long> remainingSprintTicks = Reflection.getField(ServerTickRateManager.class, long.class, 0);
|
||||
|
||||
private boolean blockTpsPacket = true;
|
||||
private int totalSteps;
|
||||
@@ -121,7 +119,7 @@ public class TickManager implements Listener {
|
||||
|
||||
public long getRemainingTicks() {
|
||||
if (isSprinting()) {
|
||||
return remainingSprintTicks.get(manager);
|
||||
return manager.remainingSprintTicks;
|
||||
} else {
|
||||
return manager.frozenTicksToRun();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@@ -32,16 +33,19 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.*;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import de.steamwar.Reflection;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
@@ -91,17 +95,36 @@ public class WorldEditUtils {
|
||||
.getRegionSelector(BukkitAdapter.adapt(player.getWorld()));
|
||||
return new Pair<>(regionSelector.getClass(), regionSelector.getVertices()
|
||||
.stream()
|
||||
.map(blockVector3 -> blockVector3 == null ? null : adapt(player.getWorld(), blockVector3))
|
||||
.map(blockVector3 -> {
|
||||
if (blockVector3 == null) {
|
||||
return null;
|
||||
} else {
|
||||
return BukkitAdapter.adapt(player.getWorld(), blockVector3);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private static final Map<Class<? extends RegionSelector>, Function<World, RegionSelector>> constructors = new HashMap<>();
|
||||
static {
|
||||
constructors.put(CuboidRegionSelector.class, CuboidRegionSelector::new);
|
||||
constructors.put(ExtendingCuboidRegionSelector.class, ExtendingCuboidRegionSelector::new);
|
||||
constructors.put(Polygonal2DRegionSelector.class, Polygonal2DRegionSelector::new);
|
||||
constructors.put(EllipsoidRegionSelector.class, EllipsoidRegionSelector::new);
|
||||
constructors.put(SphereRegionSelector.class, SphereRegionSelector::new);
|
||||
constructors.put(CylinderRegionSelector.class, CylinderRegionSelector::new);
|
||||
constructors.put(ConvexPolyhedralRegionSelector.class, ConvexPolyhedralRegionSelector::new);
|
||||
constructors.put(PolyhedralRegionSelector.class, PolyhedralRegionSelector::new);
|
||||
}
|
||||
|
||||
public void setVertices(Player player, Class<? extends RegionSelector> clazz, List<Location> vertices) {
|
||||
LocalSession localSession = WorldEdit.getInstance()
|
||||
.getSessionManager()
|
||||
.get(BukkitAdapter.adapt(player));
|
||||
|
||||
Reflection.Constructor constructorInvoker = Reflection.getConstructor(clazz, com.sk89q.worldedit.world.World.class);
|
||||
RegionSelector regionSelector = (RegionSelector) constructorInvoker.invoke(BukkitAdapter.adapt(player.getWorld()));
|
||||
Function<World, RegionSelector> constructor = constructors.get(clazz);
|
||||
if (constructor == null) return;
|
||||
RegionSelector regionSelector = constructor.apply(BukkitAdapter.adapt(player.getWorld()));
|
||||
localSession.setRegionSelector(BukkitAdapter.adapt(player.getWorld()), regionSelector);
|
||||
|
||||
if (vertices.isEmpty()) return;
|
||||
@@ -127,13 +150,9 @@ public class WorldEditUtils {
|
||||
try {
|
||||
BlockVector3 min = regionSelector.getRegion().getMinimumPoint();
|
||||
BlockVector3 max = regionSelector.getRegion().getMaximumPoint();
|
||||
return new Pair<>(adapt(player.getWorld(), min), adapt(player.getWorld(), max));
|
||||
return new Pair<>(BukkitAdapter.adapt(player.getWorld(), min), BukkitAdapter.adapt(player.getWorld(), max));
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Location adapt(World world, BlockVector3 blockVector3) {
|
||||
return new Location(world, blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ version: "2.0"
|
||||
depend: [ WorldEdit, SpigotCore ]
|
||||
load: POSTWORLD
|
||||
main: de.steamwar.bausystem.BauSystem
|
||||
api-version: "1.13"
|
||||
api-version: "1.21"
|
||||
website: "https://steamwar.de"
|
||||
description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||
|
||||
|
||||
@@ -37,5 +37,6 @@ tasks.register<DevServer>("DevBau21") {
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
dependsOn(":KotlinCore:shadowJar")
|
||||
template = "Bau21"
|
||||
}
|
||||
|
||||
@@ -152,8 +152,7 @@ class DevCommand : CliktCommand("dev") {
|
||||
)
|
||||
|
||||
val additionalVersions = mapOf(
|
||||
"Tutorial" to 15,
|
||||
"Lobby" to 20
|
||||
"Lobby" to 21
|
||||
)
|
||||
|
||||
fun findVersion(server: String): Int? =
|
||||
|
||||
@@ -32,7 +32,10 @@ import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.HullHider;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.fightsystem.utils.TechHiderWrapper;
|
||||
import de.steamwar.linkage.AbstractLinker;
|
||||
import de.steamwar.linkage.SpigotLinker;
|
||||
import de.steamwar.message.Message;
|
||||
@@ -110,6 +113,7 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
hullHider = new HullHider();
|
||||
techHider = new TechHiderWrapper(hullHider);
|
||||
FightSystem.getHullHider().getHullMap().values().forEach(hull -> hull.fill(true));
|
||||
|
||||
|
||||
FileSource.startReplay();
|
||||
|
||||
-4
@@ -27,12 +27,9 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.utils.SWSound;
|
||||
import de.steamwar.techhider.ProtocolUtils;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnternCountdown extends Countdown {
|
||||
|
||||
private static int calcTime(FightPlayer fp, Countdown countdown) {
|
||||
@@ -47,7 +44,6 @@ public class EnternCountdown extends Countdown {
|
||||
}
|
||||
|
||||
private final FightPlayer fightPlayer;
|
||||
private List<ProtocolUtils.ChunkPos> chunkPos;
|
||||
|
||||
public EnternCountdown(FightPlayer fp, Countdown countdown) {
|
||||
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
|
||||
|
||||
@@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
@@ -88,7 +89,7 @@ public class Fight {
|
||||
}
|
||||
|
||||
public static void playSound(Sound sound, float volume, float pitch) {
|
||||
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
|
||||
GlobalRecorder.getInstance().soundAtPlayer(Registry.SOUNDS.getKey(sound).getKey(), volume, pitch);
|
||||
//volume: max. 100, pitch: max. 2
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch));
|
||||
}
|
||||
|
||||
@@ -158,6 +158,8 @@ public class FightSchematic extends StateDependent {
|
||||
FreezeWorld freezer = new FreezeWorld();
|
||||
|
||||
team.teleportToSpawn();
|
||||
// TODO: Implement hull generation based on clipboard content!
|
||||
FightSystem.getHullHider().fill(team, false);
|
||||
Vector dims = WorldeditWrapper.impl.getDimensions(clipboard);
|
||||
WorldeditWrapper.impl.pasteClipboard(
|
||||
clipboard,
|
||||
|
||||
@@ -35,7 +35,9 @@ import de.steamwar.fightsystem.listener.TeamArea;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||
import de.steamwar.fightsystem.utils.Region;
|
||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||
import de.steamwar.fightsystem.winconditions.Winconditions;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
|
||||
@@ -68,6 +68,13 @@ public class FightWorld extends StateDependent {
|
||||
}
|
||||
|
||||
public static void resetWorld() {
|
||||
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||
assert backup != null;
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.resetChunk(Config.world, backup, x, z);
|
||||
});
|
||||
Bukkit.unloadWorld(backup, false);
|
||||
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
Recording.iterateOverEntities(Objects::nonNull, entity -> {
|
||||
if (entity.getType() != EntityType.PLAYER && (!Config.GameModeConfig.Arena.Leaveable || Config.ArenaRegion.inRegion(entity.getLocation()))) {
|
||||
@@ -77,14 +84,12 @@ public class FightWorld extends StateDependent {
|
||||
entities.forEach(Entity::remove);
|
||||
entities.clear();
|
||||
|
||||
World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld();
|
||||
assert backup != null;
|
||||
FightSystem.getHullHider().getHullMap().values().forEach(hull -> hull.fill(true));
|
||||
|
||||
Config.ArenaRegion.forEachChunk((x, z) -> {
|
||||
CraftbukkitWrapper.impl.resetChunk(Config.world, backup, x, z);
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
de.steamwar.core.CraftbukkitWrapper.sendChunk(p, x, z);
|
||||
}
|
||||
});
|
||||
Bukkit.unloadWorld(backup, false);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public class ArrowStopper {
|
||||
private void run() {
|
||||
Recording.iterateOverEntities(AbstractArrow.class::isInstance, entity -> {
|
||||
Projectile arrow = (Projectile) entity;
|
||||
if(!(arrow.getShooter() instanceof Player)) return;
|
||||
if (invalidEntity(arrow)) return;
|
||||
|
||||
Location prevLocation = arrow.getLocation().toVector().subtract(arrow.getVelocity()).toLocation(arrow.getWorld());
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
@@ -42,7 +43,7 @@ public class ClickAnalyzer {
|
||||
}
|
||||
|
||||
public ClickAnalyzer() {
|
||||
TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace);
|
||||
TinyProtocol.instance.addFilter(ServerboundUseItemPacket.class, this::onBlockPlace);
|
||||
TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, this::onBlockPlace);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@@ -38,11 +39,13 @@ public class EntityDamage implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityDamage(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
if (Config.ArenaRegion.in2dRegion(event.getEntity().getLocation())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
if (Config.ArenaRegion.in2dRegion(event.getEntity().getLocation())) event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
@@ -114,18 +113,18 @@ public class Recording implements Listener {
|
||||
}.register();
|
||||
new StateDependent(ArenaMode.AntiReplay, FightState.Ingame) {
|
||||
private final BiFunction<Player, ServerboundUseItemPacket, Object> place = Recording.this::blockPlace;
|
||||
private final BiFunction<Player, Object, Object> dig = Recording.this::blockDig;
|
||||
private final BiFunction<Player, ServerboundPlayerActionPacket, Object> dig = Recording.this::blockDig;
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
TinyProtocol.instance.addFilter(ServerboundUseItemPacket.class, place);
|
||||
TinyProtocol.instance.addFilter(blockDigPacket, dig);
|
||||
TinyProtocol.instance.addFilter(ServerboundPlayerActionPacket.class, dig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
TinyProtocol.instance.removeFilter(blockPlacePacket, place);
|
||||
TinyProtocol.instance.removeFilter(blockDigPacket, dig);
|
||||
TinyProtocol.instance.removeFilter(ServerboundUseItemPacket.class, place);
|
||||
TinyProtocol.instance.removeFilter(ServerboundPlayerActionPacket.class, dig);
|
||||
}
|
||||
}.register();
|
||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, () -> {
|
||||
@@ -142,20 +141,13 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().entitySpeed(entity);
|
||||
}
|
||||
|
||||
private static final Class<?> blockDigPacket = ServerboundPlayerActionPacket.class;
|
||||
private static final Class<?> playerDigType = blockDigPacket.getDeclaredClasses()[0];
|
||||
private static final Reflection.Field<?> blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0);
|
||||
private static final Object releaseUseItem = playerDigType.getEnumConstants()[5];
|
||||
|
||||
private Object blockDig(Player p, Object packet) {
|
||||
if (!isNotSent(p) && blockDigType.get(packet) == releaseUseItem) {
|
||||
private Object blockDig(Player p, ServerboundPlayerActionPacket packet) {
|
||||
if (!isNotSent(p) && packet.getAction() == ServerboundPlayerActionPacket.Action.RELEASE_USE_ITEM) {
|
||||
GlobalRecorder.getInstance().bowSpan(p, false, false);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static final Class<?> blockPlacePacket = ServerboundUseItemPacket.class;
|
||||
|
||||
private Object blockPlace(Player p, ServerboundUseItemPacket packet) {
|
||||
boolean mainHand = packet.getHand() == InteractionHand.MAIN_HAND;
|
||||
if (!isNotSent(p) && (mainHand ? p.getInventory().getItemInMainHand() : p.getInventory().getItemInOffHand()).getType() == Material.BOW) {
|
||||
|
||||
+11
-5
@@ -34,7 +34,9 @@ import de.steamwar.fightsystem.fight.FightWorld;
|
||||
import de.steamwar.fightsystem.fight.FreezeWorld;
|
||||
import de.steamwar.fightsystem.listener.FightScoreboard;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.utils.*;
|
||||
import de.steamwar.fightsystem.utils.FightUI;
|
||||
import de.steamwar.fightsystem.utils.Message;
|
||||
import de.steamwar.fightsystem.utils.TechHiderWrapper;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
@@ -510,11 +512,13 @@ public class PacketProcessor implements Listener {
|
||||
float volume = source.readFloat();
|
||||
float pitch = source.readFloat();
|
||||
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
Sound sound = Registry.SOUNDS.get(NamespacedKey.minecraft(soundName));
|
||||
if (sound == null) sound = Sound.valueOf(soundName); // TODO: Remove in 26.x because of no longer needed backwards compatibility
|
||||
Sound finalSound = sound;
|
||||
|
||||
execSync(() -> {
|
||||
Location location = new Location(Config.world, x, y, z);
|
||||
location.getWorld().playSound(location, sound, SoundCategory.valueOf(soundCategory), volume, pitch);
|
||||
location.getWorld().playSound(location, finalSound, SoundCategory.valueOf(soundCategory), volume, pitch);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -524,9 +528,11 @@ public class PacketProcessor implements Listener {
|
||||
float volume = source.readFloat();
|
||||
float pitch = source.readFloat();
|
||||
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
Sound sound = Registry.SOUNDS.get(NamespacedKey.minecraft(soundName));
|
||||
if (sound == null) sound = Sound.valueOf(soundName); // TODO: Remove in 26.x because of no longer needed backwards compatibility
|
||||
Sound finalSound = sound;
|
||||
|
||||
execSync(() -> Fight.playSound(sound, volume, pitch));
|
||||
execSync(() -> Fight.playSound(finalSound, volume, pitch));
|
||||
}
|
||||
|
||||
private void pasteSchem(FightTeam team) throws IOException {
|
||||
|
||||
@@ -33,6 +33,7 @@ import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -238,7 +239,7 @@ public interface Recorder {
|
||||
}
|
||||
|
||||
default void sound(int x, int y, int z, SWSound soundType, String soundCategory, float volume, float pitch) {
|
||||
write(0x32, x, y, z, soundType.getSound().name(), soundCategory, volume, pitch);
|
||||
write(0x32, x, y, z, Registry.SOUNDS.getKey(soundType.getSound()).getKey(), soundCategory, volume, pitch);
|
||||
}
|
||||
|
||||
default void soundAtPlayer(String soundType, float volume, float pitch) {
|
||||
|
||||
@@ -165,6 +165,15 @@ public class Hull {
|
||||
rentities.remove(entity);
|
||||
}
|
||||
|
||||
public void fill(boolean visible) {
|
||||
visibility.set(0, visibility.size(), visible);
|
||||
occluding.set(0, occluding.size(), !visible);
|
||||
uncoveredSurface.clear();
|
||||
for (BitSet directionalVisibility : visibilityDirections.values()) {
|
||||
directionalVisibility.set(0, directionalVisibility.size(), visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
visibility.clear();
|
||||
occluding.clear();
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
@@ -28,17 +26,9 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.listener.Recording;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.states.StateDependentTask;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelEventPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -54,8 +44,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class HullHider implements Listener {
|
||||
|
||||
@@ -79,10 +67,13 @@ public class HullHider implements Listener {
|
||||
|
||||
public void initialize(FightTeam team) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
hullMap.get(team).initialize();
|
||||
}
|
||||
|
||||
public void fill(FightTeam team, boolean visible) {
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
hullMap.get(team).fill(visible);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
|
||||
+72
-42
@@ -19,10 +19,8 @@
|
||||
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.events.BoardingEvent;
|
||||
import de.steamwar.fightsystem.events.TeamLeaveEvent;
|
||||
import de.steamwar.fightsystem.events.TeamSpawnEvent;
|
||||
@@ -31,6 +29,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependent;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.techhider.AccessPrivilegeProvider;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -38,6 +37,11 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -45,10 +49,12 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
@@ -56,30 +62,40 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
@Getter
|
||||
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
||||
private final TechHider techHider;
|
||||
|
||||
private final HullHider hullHider;
|
||||
|
||||
public TechHiderWrapper(HullHider hullHider) {
|
||||
super(ENABLED, FightState.Schem);
|
||||
super(ENABLED, FightState.All);
|
||||
|
||||
this.hullHider = hullHider;
|
||||
|
||||
new StateDependentListener(ENABLED, FightState.All, this);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
Set<BlockState> blockStatesToObfuscate = getBlockStatesToHideFromMaterials(Config.GameModeConfig.Techhider.HiddenBlocks);
|
||||
|
||||
Set<Block> blocksToObfuscate = Config.GameModeConfig.Techhider.HiddenBlocks.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
Object blockEntityType;
|
||||
try {
|
||||
blockEntityType = BuiltInRegistries.class.getDeclaredField("BLOCK_ENTITY_TYPE").get(null);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
Reflection.Method method = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.core.Registry"), "get", Optional.class, ResourceLocation.class);
|
||||
Set<BlockEntityType<?>> blockEntityTypeToObfuscate = Config.GameModeConfig.Techhider.HiddenBlockEntities.stream()
|
||||
.map((id) -> {
|
||||
Set<BlockEntityType<?>> blockEntityTypeToObfuscate = Config.GameModeConfig.Techhider.HiddenBlockEntities.stream()
|
||||
.map(id -> {
|
||||
ResourceLocation loc = ResourceLocation.parse(id);
|
||||
return ((Optional<Holder.Reference<BlockEntityType<?>>>) method.invoke(blockEntityType, loc)).get().value();
|
||||
return BuiltInRegistries.BLOCK_ENTITY_TYPE.get(loc).orElse(null);
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.map(Holder.Reference::value)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
techHider = new TechHider(CraftMagicNumbers.getBlock(Config.GameModeConfig.Techhider.ObfuscateWith)) {
|
||||
new TechHider(CraftMagicNumbers.getBlock(Config.GameModeConfig.Techhider.ObfuscateWith), new AccessPrivilegeProvider() {
|
||||
@Override
|
||||
public boolean isEveryonePrivilegedToAccessAllDataWithinChunk(int chunkX, int chunkZ) {
|
||||
return Fight.teams().stream().map(FightTeam::getExtendRegion).allMatch(region -> region.chunkOutside(chunkX, chunkZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessPosition(Player p, int blockX, int blockY, int blockZ) {
|
||||
return !hullHider.isBlockHidden(p, blockX, blockY, blockZ);
|
||||
@@ -87,41 +103,36 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlock(Player p, int blockX, int blockY, int blockZ, Block block) {
|
||||
Region hiddenRegion = getHiddenRegion(p);
|
||||
return !hiddenRegion.inRegion(blockX, blockY, blockZ) || !blocksToObfuscate.contains(block);
|
||||
return !getHiddenRegion(p).inRegion(blockX, blockY, blockZ) || !blocksToObfuscate.contains(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlockState(Player p, int blockX, int blockY, int blockZ, BlockState blockState) {
|
||||
return !getHiddenRegion(p).inRegion(blockX, blockY, blockZ) || !blockStatesToObfuscate.contains(blockState);
|
||||
}
|
||||
|
||||
// TODO will require entity tracking on the netty thread to prevent future race conditions
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessEntity(Player p, int entityId) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftWorld) p.getWorld()).getHandle().moonrise$getEntityLookup().get(entityId);
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftWorld) p.getWorld()).getHandle().moonrise$getEntityLookup().get(entityId);
|
||||
|
||||
if(nmsEntity != null) {
|
||||
if (nmsEntity != null) {
|
||||
return !hullHider.isBlockHidden(p, nmsEntity.getBlockX(), nmsEntity.getBlockY(), nmsEntity.getBlockZ());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerPrivilegedToAccessBlocEntity(Player p, int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
Region hiddenRegion = getHiddenRegion(p);
|
||||
return !hiddenRegion.inRegion(blockX, blockY, blockZ) || !blockEntityTypeToObfuscate.contains(type);
|
||||
public boolean isPlayerPrivilegedToAccessBlockEntity(Player p, int blockX, int blockY, int blockZ, BlockEntityType<?> type) {
|
||||
return !getHiddenRegion(p).inRegion(blockX, blockY, blockZ) || !blockEntityTypeToObfuscate.contains(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEveryonePrivilegedToAccessAllDataWithinChunk(int chunkX, int chunkZ) {
|
||||
return getHiddenRegions().stream().allMatch(region -> region.chunkOutside(chunkX, chunkZ));
|
||||
public boolean isPlayerPrivilegedToPerformAction(Player p) {
|
||||
return p.getGameMode() != GameMode.SPECTATOR;
|
||||
}
|
||||
};
|
||||
|
||||
new StateDependentListener(ENABLED, FightState.Schem, this);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,10 +175,6 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private Set<Region> getHiddenRegions() {
|
||||
return Fight.teams().stream().map(FightTeam::getExtendRegion).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Region getHiddenRegion(Player player) {
|
||||
if (Config.isReferee(player)) return Region.EMPTY;
|
||||
|
||||
@@ -178,4 +185,27 @@ public class TechHiderWrapper extends StateDependent implements Listener {
|
||||
|
||||
return Fight.getOpposite(team).getExtendRegion();
|
||||
}
|
||||
|
||||
private Stream<BlockState> getWaterloggedBlockStates() {
|
||||
FluidState waterFluidState = Fluids.WATER.getSource(false);
|
||||
|
||||
return BuiltInRegistries.BLOCK.stream()
|
||||
.map((block) -> block.getStateDefinition().getPossibleStates())
|
||||
.flatMap(Collection::stream)
|
||||
.filter((blockState -> blockState.getFluidState() == waterFluidState));
|
||||
}
|
||||
|
||||
private Set<BlockState> getBlockStatesToHideFromMaterials(Set<Material> materials) {
|
||||
Stream<BlockState> allStatesFromMaterials = materials.stream()
|
||||
.map(CraftMagicNumbers::getBlock)
|
||||
.map((block) -> block.getStateDefinition().getPossibleStates())
|
||||
.flatMap(Collection::stream);
|
||||
|
||||
if(materials.contains(Material.WATER)) {
|
||||
return Stream.concat(allStatesFromMaterials, getWaterloggedBlockStates()).collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
else {
|
||||
return allStatesFromMaterials.collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,16 +30,6 @@ dependencies {
|
||||
implementation(project(":FightSystem:FightSystem_Core"))
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("WarGear20") {
|
||||
group = "run"
|
||||
description = "Run a WarGear 1.20 Fight Server"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":FightSystem:shadowJar")
|
||||
template = "WarGear20"
|
||||
worldName = "arenas/Pentraki"
|
||||
config = "WarGear20.yml"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("HalloweenWS") {
|
||||
group = "run"
|
||||
description = "Run a Halloween 1.21 Fight Replay Server"
|
||||
@@ -60,26 +50,6 @@ tasks.register<FightServer>("WarGear21") {
|
||||
dependsOn(":KotlinCore:shadowJar")
|
||||
template = "WarGear21"
|
||||
worldName = "arenas/Pentraki"
|
||||
config = "WarGear20.yml"
|
||||
config = "WarGear21.yml"
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("SpaceCraftDev20") {
|
||||
group = "run"
|
||||
description = "Run a SpaceCraftDev 1.20 Fight Server"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":FightSystem:shadowJar")
|
||||
template = "SpaceCraft20"
|
||||
worldName = "arenas/AS_Horizon"
|
||||
config = "SpaceCraftDev20.yml"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("QuickGear20") {
|
||||
group = "run"
|
||||
description = "Run a QuickGear 1.20 Fight Server"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":FightSystem:shadowJar")
|
||||
template = "QuickGear20"
|
||||
worldName = "arenas/WarGearPark"
|
||||
config = "QuickGear20.yml"
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
plugins {
|
||||
steamwar.java
|
||||
widener
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -32,6 +33,11 @@ dependencies {
|
||||
compileOnly(libs.fawe)
|
||||
}
|
||||
|
||||
widener {
|
||||
fromCatalog(libs.nms)
|
||||
fromCatalog(libs.paperapi)
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevLobby20") {
|
||||
group = "run"
|
||||
description = "Run a 1.20 Dev Lobby"
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
package de.steamwar.lobby.boatrace;
|
||||
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityAction;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RInteraction;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.util.LeaderboardManager;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@@ -58,11 +60,12 @@ public class BoatRace implements EventListener, Listener {
|
||||
|
||||
static {
|
||||
boatNpcServer = new REntityServer();
|
||||
REntity starter = new REntity(boatNpcServer, EntityType.VILLAGER, BoatRacePositions.NPC);
|
||||
boatNpcServer.setCallback((player, rEntity, entityAction) -> {
|
||||
if (rEntity != starter) return;
|
||||
Bukkit.getWorlds().get(0).getEntities().stream().filter(entity -> entity.getType() == EntityType.END_CRYSTAL).forEach(Entity::remove);
|
||||
if (entityAction == REntityServer.EntityAction.INTERACT && !oneNotStarted) {
|
||||
new REntity(boatNpcServer, EntityType.VILLAGER, BoatRacePositions.NPC);
|
||||
RInteraction interaction = new RInteraction(boatNpcServer, BoatRacePositions.NPC.clone().subtract(0.5, 0, 0.5));
|
||||
interaction.setInteractionHeight(1.95f);
|
||||
interaction.setCallback((player, entity, action) -> {
|
||||
Bukkit.getWorlds().get(0).getEntities().stream().filter(e -> e.getType() == EntityType.END_CRYSTAL).forEach(Entity::remove);
|
||||
if (action == REntityAction.INTERACT && !oneNotStarted) {
|
||||
oneNotStarted = true;
|
||||
new BoatRace(player);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ColorInit {
|
||||
if (inputStream == null) {
|
||||
colors = new byte[256 * 256 * 256];
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
colors[i] = MapPalette.matchColor(new Color(i));
|
||||
colors[i] = matchColor(new Color(i));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -57,4 +57,26 @@ public class ColorInit {
|
||||
}
|
||||
System.out.println("[ColorInit] Initialization took " + (System.currentTimeMillis() - time) + "ms");
|
||||
}
|
||||
|
||||
public static byte matchColor(Color color) {
|
||||
if (color.getAlpha() < 128) return 0;
|
||||
|
||||
if (MapPalette.mapColorCache != null && MapPalette.mapColorCache.isCached()) {
|
||||
return MapPalette.mapColorCache.matchColor(color);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
double best = -1;
|
||||
|
||||
for (int i = 4; i < MapPalette.colors.length; i++) {
|
||||
double distance = MapPalette.getDistance(color, MapPalette.colors[i]);
|
||||
if (distance < best || best == -1) {
|
||||
best = distance;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Minecraft has 248 colors, some of which have negative byte representations
|
||||
return (byte) (index < 128 ? index : -129 + (index - 127));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,8 @@ public class CustomMap implements Listener {
|
||||
int green = pixels[i2];
|
||||
int i3 = (y * width + x) * numBands + 2;
|
||||
int blue = pixels[i3];
|
||||
Color nearest = MapPalette.getColor(ColorInit.getColorByte(red, green, blue));
|
||||
int colorIndex = ColorInit.getColorByte(red, green, blue);
|
||||
Color nearest = MapPalette.colors[colorIndex >= 0 ? colorIndex : colorIndex + 256];
|
||||
|
||||
pixels[(y * width + x) * numBands] = nearest.getRed();
|
||||
pixels[i2] = nearest.getGreen();
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
accessWidener v2 named
|
||||
|
||||
# For CustomMap and ColorInit
|
||||
accessible field org/bukkit/map/MapPalette colors [Ljava/awt/Color;
|
||||
accessible method org/bukkit/map/MapPalette getDistance (Ljava/awt/Color;Ljava/awt/Color;)D
|
||||
accessible field org/bukkit/map/MapPalette mapColorCache Lorg/bukkit/map/MapPalette$MapColorCache;
|
||||
@@ -20,9 +20,12 @@
|
||||
package de.steamwar.misslewars.slowmo;
|
||||
|
||||
import de.steamwar.misslewars.MissileWars;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.TickRateManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class SlowMoRunner {
|
||||
private static TickRateManager tickRateManager = MinecraftServer.getServer().tickRateManager();
|
||||
|
||||
private static long currentTime = 0;
|
||||
private static long current = 0;
|
||||
@@ -40,14 +43,14 @@ public class SlowMoRunner {
|
||||
if (currentTime > 0) {
|
||||
current += 1;
|
||||
if (current % 5 == 0) {
|
||||
SlowMoUtils.unfreeze();
|
||||
tickRateManager.setFrozen(false);
|
||||
current = 0;
|
||||
} else {
|
||||
SlowMoUtils.freeze();
|
||||
tickRateManager.setFrozen(true);
|
||||
}
|
||||
currentTime--;
|
||||
} else {
|
||||
SlowMoUtils.unfreeze();
|
||||
tickRateManager.setFrozen(false);
|
||||
}
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.misslewars.slowmo;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class SlowMoUtils {
|
||||
|
||||
private static final Field field;
|
||||
public static final boolean freezeEnabled;
|
||||
|
||||
private static boolean frozen = false;
|
||||
|
||||
private static final World world;
|
||||
|
||||
static {
|
||||
Field temp;
|
||||
try {
|
||||
temp = ServerLevel.class.getField("freezed");
|
||||
} catch (NoSuchFieldException e) {
|
||||
temp = null;
|
||||
}
|
||||
field = temp;
|
||||
if (field != null) field.setAccessible(true);
|
||||
freezeEnabled = field != null;
|
||||
world = Bukkit.getWorlds().get(0);
|
||||
}
|
||||
|
||||
public static void freeze() {
|
||||
setFreeze(world, true);
|
||||
}
|
||||
|
||||
public static void unfreeze() {
|
||||
setFreeze(world, false);
|
||||
}
|
||||
|
||||
public static boolean frozen() {
|
||||
return freezeEnabled && frozen;
|
||||
}
|
||||
|
||||
private static void setFreeze(World world, boolean state) {
|
||||
if (freezeEnabled) {
|
||||
if (frozen == state) return;
|
||||
try {
|
||||
field.set(((CraftWorld) world).getHandle(), state);
|
||||
frozen = state;
|
||||
} catch (IllegalAccessException e) {
|
||||
// Ignored;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,8 @@ public class AutoChecker {
|
||||
public static final AutoChecker impl = new AutoChecker();
|
||||
|
||||
public AutoCheckerResult check(Clipboard clipboard, GameModeConfig<Material, String> type) {
|
||||
return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX())
|
||||
.depth(clipboard.getDimensions().getBlockZ()).blockScanResult(scan(clipboard, type))
|
||||
return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().x()).width(clipboard.getDimensions().x())
|
||||
.depth(clipboard.getDimensions().z()).blockScanResult(scan(clipboard, type))
|
||||
.entities(clipboard.getEntities().stream().map(Entity::getLocation)
|
||||
.map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()))
|
||||
.collect(Collectors.toList()))
|
||||
@@ -46,19 +46,19 @@ public class AutoChecker {
|
||||
}
|
||||
|
||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig<Material, String> type) {
|
||||
return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().getBlockY()).width(clipboard.getDimensions().getBlockX())
|
||||
.depth(clipboard.getDimensions().getBlockZ()).build();
|
||||
return AutoCheckerResult.builder().type(type).height(clipboard.getDimensions().y()).width(clipboard.getDimensions().x())
|
||||
.depth(clipboard.getDimensions().z()).build();
|
||||
}
|
||||
|
||||
public AutoChecker.BlockScanResult scan(Clipboard clipboard, GameModeConfig<Material, String> type) {
|
||||
AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult();
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
BlockVector3 max = clipboard.getMaximumPoint();
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
||||
for (int x = min.x(); x <= max.x(); x++) {
|
||||
for (int y = min.y(); y <= max.y(); y++) {
|
||||
for (int z = min.z(); z <= max.z(); z++) {
|
||||
final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z));
|
||||
final Material material = Material.matchMaterial(block.getBlockType().getId());
|
||||
final Material material = Material.matchMaterial(block.getBlockType().id());
|
||||
if (material == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class AutoChecker {
|
||||
checkInventory(result, block, material, new BlockPos(x, y, z), type);
|
||||
}
|
||||
|
||||
if (x == min.getBlockX() || x == max.getBlockX() || y == max.getBlockY() || z == min.getBlockZ() || z == max.getBlockZ()) {
|
||||
if (x == min.x() || x == max.x() || y == max.y() || z == min.z() || z == max.z()) {
|
||||
result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -245,12 +245,12 @@ public class SchematicCommand extends SWCommand {
|
||||
BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState();
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
BlockVector3 max = clipboard.getMaximumPoint();
|
||||
for (int i = min.getBlockX(); i <= max.getBlockX(); i++) {
|
||||
for (int j = min.getBlockY(); j <= max.getBlockY(); j++) {
|
||||
for (int k = min.getBlockZ(); k <= max.getBlockZ(); k++) {
|
||||
for (int i = min.x(); i <= max.x(); i++) {
|
||||
for (int j = min.y(); j <= max.y(); j++) {
|
||||
for (int k = min.z(); k <= max.z(); k++) {
|
||||
BlockVector3 vector = BlockVector3.at(i, j, k);
|
||||
BaseBlock block = clipboard.getFullBlock(vector);
|
||||
if (toReplace.contains(Material.matchMaterial(block.getBlockType().getId()))) {
|
||||
if (toReplace.contains(Material.matchMaterial(block.getBlockType().id()))) {
|
||||
clipboard.setBlock(vector, replaceType.toBaseBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
plugins {
|
||||
steamwar.java
|
||||
widener
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
@@ -61,3 +62,7 @@ dependencies {
|
||||
|
||||
implementation(libs.anvilgui)
|
||||
}
|
||||
|
||||
widener {
|
||||
fromCatalog(libs.nms)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.comphenix.tinyprotocol;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.core.CRIUWakeupEvent;
|
||||
import de.steamwar.core.Core;
|
||||
import io.netty.channel.*;
|
||||
@@ -180,22 +179,12 @@ public class TinyProtocol {
|
||||
networkManagers = serverConnection.getConnections();
|
||||
// We need to synchronize against this list
|
||||
createServerChannelHandler();
|
||||
for (ChannelFuture item : serverConnection.channels) {
|
||||
// Channel future that contains the server connection
|
||||
Channel serverChannel = item.channel();
|
||||
|
||||
// Find the correct list, or implicitly throw an exception
|
||||
boolean looking = true;
|
||||
for (int i = 0; looking; i++) {
|
||||
List<Object> list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection);
|
||||
|
||||
for (Object item : list) {
|
||||
if (!(item instanceof ChannelFuture)) break;
|
||||
|
||||
// Channel future that contains the server connection
|
||||
Channel serverChannel = ((ChannelFuture) item).channel();
|
||||
|
||||
serverChannels.add(serverChannel);
|
||||
serverChannel.pipeline().addFirst(serverChannelHandler);
|
||||
looking = false;
|
||||
}
|
||||
serverChannels.add(serverChannel);
|
||||
serverChannel.pipeline().addFirst(serverChannelHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +216,7 @@ public class TinyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void addFilter(Class<T> packetType, BiFunction<Player, ? super T, Object> filter) {
|
||||
public <T extends Packet<?>> void addFilter(Class<T> packetType, BiFunction<Player, ? super T, Object> filter) {
|
||||
packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add((BiFunction) filter);
|
||||
}
|
||||
|
||||
@@ -235,8 +224,8 @@ public class TinyProtocol {
|
||||
packetFilters.getOrDefault(packetType, Collections.emptyList()).remove(filter);
|
||||
}
|
||||
|
||||
public void addGlobalClientboundFilter(BiFunction<Player, Object, Object> filter) {
|
||||
globalClientboundFilters.add(filter);
|
||||
public void addGlobalClientboundFilter(BiFunction<Player, Packet<?>, Object> filter) {
|
||||
globalClientboundFilters.add((BiFunction) filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,7 +442,7 @@ public class TinyProtocol {
|
||||
try {
|
||||
msg = filterPacket(player, msg);
|
||||
|
||||
if(msg instanceof Packet<?>) {
|
||||
if (msg instanceof Packet<?>) {
|
||||
for (BiFunction<Player, Object, Object> filter : globalClientboundFilters) {
|
||||
msg = filter.apply(player, msg);
|
||||
if (msg == null) break;
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@UtilityClass
|
||||
public final class Reflection {
|
||||
|
||||
public static final int MAJOR_VERSION;
|
||||
public static final int MINOR_VERSION;
|
||||
|
||||
static {
|
||||
String[] version = Bukkit.getServer().getBukkitVersion().split("-")[0].split("\\.");
|
||||
MAJOR_VERSION = Integer.parseInt(version[1]);
|
||||
MINOR_VERSION = version.length > 2 ? Integer.parseInt(version[2]) : 0;
|
||||
}
|
||||
|
||||
private static final String ORG_BUKKIT_CRAFTBUKKIT = Bukkit.getServer().getClass().getPackage().getName();
|
||||
public static final String LEGACY_NET_MINECRAFT_SERVER = ORG_BUKKIT_CRAFTBUKKIT.replace("org.bukkit.craftbukkit", "net.minecraft.server");
|
||||
|
||||
private static final Map<String, String> spigotClassnames = new HashMap<>();
|
||||
|
||||
static {
|
||||
// See https://mappings.dev for complete mappings
|
||||
spigotClassnames.put("net.minecraft.Util", "net.minecraft.SystemUtils");
|
||||
|
||||
spigotClassnames.put("net.minecraft.core.BlockPos", "net.minecraft.core.BlockPosition");
|
||||
spigotClassnames.put("net.minecraft.core.DefaultedRegistry", "net.minecraft.core.RegistryBlocks");
|
||||
spigotClassnames.put("net.minecraft.core.IdMapper", "net.minecraft.core.RegistryBlockID");
|
||||
spigotClassnames.put("net.minecraft.core.Vec3i", "net.minecraft.core.BaseBlockPosition");
|
||||
|
||||
spigotClassnames.put("net.minecraft.nbt.CompoundTag", "net.minecraft.nbt.NBTTagCompound");
|
||||
|
||||
spigotClassnames.put("net.minecraft.network.Connection", "net.minecraft.network.NetworkManager");
|
||||
|
||||
spigotClassnames.put("net.minecraft.network.chat.Component", "net.minecraft.network.chat.IChatBaseComponent");
|
||||
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundAddEntityPacket", "net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket", "net.minecraft.network.protocol.game.PacketPlayOutNamedEntitySpawn");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundAnimatePacket", "net.minecraft.network.protocol.game.PacketPlayOutAnimation");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket", "net.minecraft.network.protocol.game.PacketPlayOutBlockBreak");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket", "net.minecraft.network.protocol.game.PacketPlayOutTileEntityData");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundBlockEventPacket", "net.minecraft.network.protocol.game.PacketPlayOutBlockAction");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket", "net.minecraft.network.protocol.game.PacketPlayOutBlockChange");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundContainerClosePacket", "net.minecraft.network.protocol.game.PacketPlayOutCloseWindow");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundEntityEventPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityStatus");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundExplodePacket", "net.minecraft.network.protocol.game.PacketPlayOutExplosion");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundGameEventPacket", "net.minecraft.network.protocol.game.PacketPlayOutGameStateChange");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo", "net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$a");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundLevelEventPacket", "net.minecraft.network.protocol.game.PacketPlayOutWorldEvent");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket", "net.minecraft.network.protocol.game.PacketPlayOutWorldParticles");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntity");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Pos", "net.minecraft.network.protocol.game.PacketPlayOutEntity$PacketPlayOutRelEntityMove");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$PosRot", "net.minecraft.network.protocol.game.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot", "net.minecraft.network.protocol.game.PacketPlayOutEntity$PacketPlayOutEntityLook");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket", "net.minecraft.network.protocol.game.PacketPlayOutOpenSignEditor");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundRotateHeadPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket", "net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSetObjectivePacket", "net.minecraft.network.protocol.game.PacketPlayOutScoreboardObjective");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSetScorePacket", "net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundSoundPacket", "net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket", "net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundContainerClickPacket", "net.minecraft.network.protocol.game.PacketPlayInWindowClick");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundInteractPacket", "net.minecraft.network.protocol.game.PacketPlayInUseEntity");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundInteractPacket$Action", "net.minecraft.network.protocol.game.PacketPlayInUseEntity$EnumEntityUseAction");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType", "net.minecraft.network.protocol.game.PacketPlayInUseEntity$b");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos", "net.minecraft.network.protocol.game.PacketPlayInFlying$PacketPlayInPosition");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot", "net.minecraft.network.protocol.game.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot", "net.minecraft.network.protocol.game.PacketPlayInFlying$PacketPlayInLook");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket", "net.minecraft.network.protocol.game.PacketPlayInBlockDig");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket", "net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundSignUpdatePacket", "net.minecraft.network.protocol.game.PacketPlayInUpdateSign");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundUseItemPacket", "net.minecraft.network.protocol.game.PacketPlayInBlockPlace");
|
||||
spigotClassnames.put("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket", "net.minecraft.network.protocol.game.PacketPlayInUseItem");
|
||||
|
||||
spigotClassnames.put("net.minecraft.network.syncher.EntityDataAccessor", "net.minecraft.network.syncher.DataWatcherObject");
|
||||
spigotClassnames.put("net.minecraft.network.syncher.EntityDataSerializer", "net.minecraft.network.syncher.DataWatcherSerializer");
|
||||
spigotClassnames.put("net.minecraft.network.syncher.EntityDataSerializers", "net.minecraft.network.syncher.DataWatcherRegistry");
|
||||
spigotClassnames.put("net.minecraft.network.syncher.SynchedEntityData$DataItem", "net.minecraft.network.syncher.DataWatcher$Item");
|
||||
|
||||
spigotClassnames.put("net.minecraft.server.ServerScoreboard$Method", "net.minecraft.server.ScoreboardServer$Action");
|
||||
|
||||
spigotClassnames.put("net.minecraft.server.level.ChunkMap", "net.minecraft.server.level.PlayerChunkMap");
|
||||
spigotClassnames.put("net.minecraft.server.level.ChunkMap$TrackedEntity", "net.minecraft.server.level.PlayerChunkMap$EntityTracker");
|
||||
spigotClassnames.put("net.minecraft.server.level.ServerChunkCache", "net.minecraft.server.level.ChunkProviderServer");
|
||||
spigotClassnames.put("net.minecraft.server.level.ServerLevel", "net.minecraft.server.level.WorldServer");
|
||||
spigotClassnames.put("net.minecraft.server.level.ServerPlayer", "net.minecraft.server.level.EntityPlayer");
|
||||
|
||||
spigotClassnames.put("net.minecraft.server.network.ServerConnectionListener", "net.minecraft.server.network.ServerConnection");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.InteractionHand", "net.minecraft.world.EnumHand");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.entity.EntityType", "net.minecraft.world.entity.EntityTypes");
|
||||
spigotClassnames.put("net.minecraft.world.entity.Pose", "net.minecraft.world.entity.EntityPose");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.entity.item.PrimedTnt", "net.minecraft.world.entity.item.EntityTNTPrimed");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.entity.projectile.AbstractArrow", "net.minecraft.world.entity.projectile.EntityArrow");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.level.GameType", "net.minecraft.world.level.EnumGamemode");
|
||||
spigotClassnames.put("net.minecraft.world.level.LevelAccessor", "net.minecraft.world.level.GeneratorAccess");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.level.block.state.BlockState", "net.minecraft.world.level.block.state.IBlockData");
|
||||
spigotClassnames.put("net.minecraft.world.level.block.state.StateDefinition", "net.minecraft.world.level.block.state.BlockStateList");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.level.chunk.LevelChunk", "net.minecraft.world.level.chunk.Chunk");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.level.material.FlowingFluid", "net.minecraft.world.level.material.FluidTypeFlowing");
|
||||
spigotClassnames.put("net.minecraft.world.level.material.Fluids", "net.minecraft.world.level.material.FluidTypes");
|
||||
spigotClassnames.put("net.minecraft.world.level.material.FluidState", "net.minecraft.world.level.material.Fluid");
|
||||
|
||||
spigotClassnames.put("net.minecraft.world.phys.BlockHitResult", "net.minecraft.world.phys.MovingObjectPositionBlock");
|
||||
spigotClassnames.put("net.minecraft.world.phys.Vec3", "net.minecraft.world.phys.Vec3D");
|
||||
|
||||
spigotClassnames.put("net.minecraft.resources.ResourceLocation", "net.minecraft.resources.MinecraftKey");
|
||||
|
||||
spigotClassnames.put("net.minecraft.util.ProgressListener", "net.minecraft.util.IProgressUpdate");
|
||||
}
|
||||
|
||||
public static Class<?> getClass(String name) {
|
||||
try {
|
||||
if (name.startsWith("org.bukkit.craftbukkit")) {
|
||||
return Class.forName(ORG_BUKKIT_CRAFTBUKKIT + name.substring(22));
|
||||
} else if (MAJOR_VERSION < 17 && name.startsWith("net.minecraft")) {
|
||||
return Class.forName(LEGACY_NET_MINECRAFT_SERVER + "." + spigotClassnames.getOrDefault(name, name).split("[.](?=[^.]*$)")[1]);
|
||||
} else if (MAJOR_VERSION < 21 || MINOR_VERSION < 4) {
|
||||
return Class.forName(spigotClassnames.getOrDefault(name, name));
|
||||
} else {
|
||||
Class<?> clazz = null;
|
||||
try {
|
||||
clazz = Class.forName(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
if (clazz != null && clazz.getName().equals(name)) {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
try {
|
||||
return Core.class.getClassLoader().getParent().loadClass(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (clazz == null) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalArgumentException("Cannot find " + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Field<T> {
|
||||
private final java.lang.reflect.Field f;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T get(Object target) {
|
||||
try {
|
||||
return (T) f.get(target);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalArgumentException("Cannot read field", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(Object target, Object value) {
|
||||
try {
|
||||
f.set(target, value);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalArgumentException("Cannot write field", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Field<T> getField(Class<?> target, String name, Class<T> fieldType) {
|
||||
return getField(target, name, fieldType, 0);
|
||||
}
|
||||
|
||||
public static <T> Field<T> getField(Class<?> target, Class<T> fieldType, int index) {
|
||||
return getField(target, null, fieldType, index);
|
||||
}
|
||||
|
||||
public static <T> Field<T> getField(Class<?> target, Class<T> fieldType, int index, Class<?>... parameters) {
|
||||
return getField(target, null, fieldType, index, parameters);
|
||||
}
|
||||
|
||||
private static <T> Field<T> getField(Class<?> target, String name, Class<T> fieldType, int index, Class<?>... parameters) {
|
||||
for (final java.lang.reflect.Field field : target.getDeclaredFields()) {
|
||||
if (matching(field, name, fieldType, parameters) && index-- <= 0) {
|
||||
field.setAccessible(true);
|
||||
return new Field<>(field);
|
||||
}
|
||||
}
|
||||
|
||||
// Search in parent classes
|
||||
if (target.getSuperclass() != null) {
|
||||
return getField(target.getSuperclass(), name, fieldType, index);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
|
||||
}
|
||||
|
||||
private static <T> boolean matching(java.lang.reflect.Field field, String name, Class<T> fieldType, Class<?>... parameters) {
|
||||
if (name != null && !field.getName().equals(name)) return false;
|
||||
|
||||
if (!fieldType.isAssignableFrom(field.getType())) return false;
|
||||
|
||||
if (parameters.length > 0) {
|
||||
Type[] arguments = ((ParameterizedType) field.getGenericType()).getActualTypeArguments();
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (arguments[i] instanceof ParameterizedType ? ((ParameterizedType) arguments[i]).getRawType() != parameters[i] : arguments[i] != parameters[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Method {
|
||||
private final java.lang.reflect.Method m;
|
||||
|
||||
public Object invoke(Object target, Object... arguments) {
|
||||
try {
|
||||
return m.invoke(target, arguments);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Cannot invoke method " + m, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Method getTypedMethod(Class<?> clazz, String methodName, Class<?> returnType, Class<?>... params) {
|
||||
for (final java.lang.reflect.Method method : clazz.getDeclaredMethods()) {
|
||||
if ((methodName == null || method.getName().equals(methodName))
|
||||
&& (returnType == null || method.getReturnType().equals(returnType))
|
||||
&& Arrays.equals(method.getParameterTypes(), params)) {
|
||||
method.setAccessible(true);
|
||||
return new Method(method);
|
||||
}
|
||||
}
|
||||
|
||||
// Search in every superclass
|
||||
if (clazz.getSuperclass() != null) {
|
||||
return getTypedMethod(clazz.getSuperclass(), methodName, returnType, params);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format("Cannot find method %s (%s).", methodName, Arrays.asList(params)));
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Constructor {
|
||||
private final java.lang.reflect.Constructor<?> c;
|
||||
|
||||
public Object invoke(Object... arguments) {
|
||||
try {
|
||||
return c.newInstance(arguments);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Cannot invoke constructor " + c, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Constructor getConstructor(Class<?> clazz, Class<?>... params) {
|
||||
for (final java.lang.reflect.Constructor<?> constructor : clazz.getDeclaredConstructors()) {
|
||||
if (Arrays.equals(constructor.getParameterTypes(), params)) {
|
||||
constructor.setAccessible(true);
|
||||
return new Constructor(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException(String.format("Unable to find constructor for %s (%s).", clazz, Arrays.asList(params)));
|
||||
}
|
||||
|
||||
public static Object newInstance(Class<?> clazz) {
|
||||
try {
|
||||
return Unsafe.getUnsafe().allocateInstance(clazz);
|
||||
} catch (InstantiationException e) {
|
||||
throw new SecurityException("Could not create object", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,35 +22,20 @@ package de.steamwar.command;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
class CommandRegistering {
|
||||
|
||||
private static final CommandMap commandMap;
|
||||
private static final SimpleCommandMap commandMap;
|
||||
private static final Map<String, Command> knownCommandMap;
|
||||
|
||||
static {
|
||||
try {
|
||||
final Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
commandMap = (CommandMap) commandMapField.get(Bukkit.getServer());
|
||||
} catch (NoSuchFieldException | IllegalAccessException exception) {
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException("Oh shit. Commands cannot be registered.", exception);
|
||||
}
|
||||
try {
|
||||
final Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||
knownCommandsField.setAccessible(true);
|
||||
knownCommandMap = (Map<String, Command>) knownCommandsField.get(commandMap);
|
||||
} catch (NoSuchFieldException | IllegalAccessException exception) {
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException("Oh shit. Commands cannot be registered.", exception);
|
||||
}
|
||||
commandMap = ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
knownCommandMap = commandMap.getKnownCommands();
|
||||
}
|
||||
|
||||
static void unregister(Command command) {
|
||||
|
||||
@@ -19,20 +19,11 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.world.entity.PositionMoveRotation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BountifulWrapper {
|
||||
public static final BountifulWrapper impl = new BountifulWrapper();
|
||||
|
||||
@@ -44,60 +35,4 @@ public class BountifulWrapper {
|
||||
if (type == ChatMessageType.CHAT) type = ChatMessageType.SYSTEM;
|
||||
player.spigot().sendMessage(type, msg);
|
||||
}
|
||||
|
||||
private static final Class<?> dataWatcherRegistry = EntityDataSerializers.class;
|
||||
private static final Class<?> dataWatcherSerializer = EntityDataSerializer.class;
|
||||
|
||||
public Object getDataWatcherObject(int index, Class<?> type) {
|
||||
return new EntityDataAccessor<>(index, (EntityDataSerializer<Object>) Reflection.getField(dataWatcherRegistry, dataWatcherSerializer, 0, type).get(null));
|
||||
}
|
||||
|
||||
public Object getDataWatcherItem(Object dwo, Object value) {
|
||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<Object>) dwo, value);
|
||||
}
|
||||
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset) {
|
||||
try {
|
||||
Reflection.Field<PositionMoveRotation> field = Reflection.getField(packetClass, PositionMoveRotation.class, 0);
|
||||
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), field.get(packet).deltaMovement(), yaw, pitch));
|
||||
};
|
||||
} catch (IllegalArgumentException e) {
|
||||
Reflection.Field<Double> posX = Reflection.getField(packetClass, double.class, fieldOffset);
|
||||
Reflection.Field<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset + 1);
|
||||
Reflection.Field<Double> posZ = Reflection.getField(packetClass, double.class, fieldOffset + 2);
|
||||
boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn");
|
||||
Class<?> pitchYawType = isByteClass ? byte.class : int.class;
|
||||
Reflection.Field<?> lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1);
|
||||
Reflection.Field<?> lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2);
|
||||
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
posX.set(packet, x);
|
||||
posY.set(packet, y);
|
||||
posZ.set(packet, z);
|
||||
if (isByteClass) {
|
||||
lookYaw.set(packet, (byte) (yaw * 256 / 360));
|
||||
lookPitch.set(packet, (byte) (pitch * 256 / 360));
|
||||
} else {
|
||||
lookYaw.set(packet, (int) (yaw * 256 / 360));
|
||||
lookPitch.set(packet, (int) (pitch * 256 / 360));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public BountifulWrapper.UUIDSetter getUUIDSetter(Class<?> packetClass) {
|
||||
Reflection.Field<UUID> uuidField = Reflection.getField(packetClass, UUID.class, 0);
|
||||
|
||||
return uuidField::set;
|
||||
}
|
||||
|
||||
public interface PositionSetter {
|
||||
void set(Object packet, double x, double y, double z, float pitch, float yaw);
|
||||
}
|
||||
|
||||
public interface UUIDSetter {
|
||||
void set(Object packet, UUID uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -96,9 +95,6 @@ class CheckpointUtilsJ9 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final Reflection.Field<List> channelFutures = Reflection.getField(ServerConnectionListener.class, List.class, 0, ChannelFuture.class);
|
||||
|
||||
private static void freezeInternal(Path path) throws Exception {
|
||||
Bukkit.getPluginManager().callEvent(new CRIUSleepEvent());
|
||||
|
||||
@@ -109,9 +105,9 @@ class CheckpointUtilsJ9 {
|
||||
|
||||
// Close socket
|
||||
ServerConnectionListener serverConnection = MinecraftServer.getServer().getConnection();
|
||||
List<?> channels = channelFutures.get(serverConnection);
|
||||
for (Object future : channels) {
|
||||
((ChannelFuture) future).channel().close().syncUninterruptibly();
|
||||
List<ChannelFuture> channels = serverConnection.channels;
|
||||
for (ChannelFuture future : channels) {
|
||||
future.channel().close().syncUninterruptibly();
|
||||
}
|
||||
channels.clear();
|
||||
|
||||
@@ -145,8 +141,8 @@ class CheckpointUtilsJ9 {
|
||||
|
||||
// Reopen socket
|
||||
serverConnection.startTcpServerListener(InetAddress.getLoopbackAddress(), port);
|
||||
for (Object future : channels) {
|
||||
((ChannelFuture) future).channel().config().setAutoRead(true);
|
||||
for (ChannelFuture future : channels) {
|
||||
future.channel().config().setAutoRead(true);
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent());
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* the Free Software Foundation, either versionStrings 3 of the License, or
|
||||
* (at your option) any later versionStrings.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.SWTypeMapperCreator;
|
||||
import de.steamwar.command.TabCompletionCache;
|
||||
@@ -49,9 +48,13 @@ public class Core extends JavaPlugin {
|
||||
|
||||
public static final Message MESSAGE = new Message("SpigotCore", Core.class.getClassLoader());
|
||||
|
||||
@Getter
|
||||
@Deprecated
|
||||
public static int getVersion() {
|
||||
return Reflection.MAJOR_VERSION;
|
||||
private static final int version;
|
||||
|
||||
static {
|
||||
String[] versionStrings = Bukkit.getServer().getBukkitVersion().split("-")[0].split("\\.");
|
||||
version = Integer.parseInt(versionStrings[1]);
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.sql.SWException;
|
||||
import org.spigotmc.WatchdogThread;
|
||||
|
||||
@@ -39,9 +38,7 @@ public class ErrorHandler extends Handler {
|
||||
|
||||
public ErrorHandler() {
|
||||
Logger.getLogger("").addHandler(this);
|
||||
|
||||
Reflection.Field<WatchdogThread> getInstance = Reflection.getField(WatchdogThread.class, WatchdogThread.class, 0);
|
||||
watchdogThreadId = getInstance.get(null).getId();
|
||||
watchdogThreadId = WatchdogThread.instance.threadId();
|
||||
}
|
||||
|
||||
void unregister() {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
|
||||
import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo;
|
||||
@@ -33,13 +32,8 @@ public class WorldIdentifier {
|
||||
|
||||
private static ResourceKey<Level> resourceKey = null;
|
||||
|
||||
private static final Class<?> resourceKeyClass = ResourceKey.class;
|
||||
private static final Class<?> minecraftKeyClass = ResourceLocation.class;
|
||||
private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass);
|
||||
private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class);
|
||||
|
||||
public static void set(String name) {
|
||||
resourceKey = (ResourceKey<Level>) resourceKeyConstructor.invoke(minecraftKeyConstructor.invoke("minecraft", "dimension"), minecraftKeyConstructor.invoke("steamwar", name));
|
||||
resourceKey = new ResourceKey<>(new ResourceLocation("minecraft", "dimension"), new ResourceLocation("steamwar", name));
|
||||
}
|
||||
|
||||
public WorldIdentifier() {
|
||||
|
||||
+2
-7
@@ -22,7 +22,6 @@ package de.steamwar.core.authlib;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.Services;
|
||||
@@ -35,13 +34,10 @@ public class SteamwarGameProfileRepository implements GameProfileRepository {
|
||||
public static final SteamwarGameProfileRepository impl = new SteamwarGameProfileRepository();
|
||||
|
||||
private static final GameProfileRepository fallback;
|
||||
private static final Reflection.Field<Services> field;
|
||||
private static final Services current;
|
||||
|
||||
static {
|
||||
Class<?> clazz = MinecraftServer.getServer().getClass();
|
||||
field = Reflection.getField(clazz, Services.class, 0);
|
||||
current = field.get(MinecraftServer.getServer());
|
||||
current = MinecraftServer.getServer().services;
|
||||
fallback = current.profileRepository();
|
||||
}
|
||||
|
||||
@@ -68,7 +64,6 @@ public class SteamwarGameProfileRepository implements GameProfileRepository {
|
||||
}
|
||||
|
||||
public void inject() {
|
||||
Services newServices = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations());
|
||||
field.set(MinecraftServer.getServer(), newServices);
|
||||
MinecraftServer.getServer().services = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,13 @@
|
||||
package de.steamwar.core.events;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.techhider.ProtocolUtils;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -38,7 +35,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Linked
|
||||
public class AntiNocom implements Listener {
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
package de.steamwar.cursor;
|
||||
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Getter
|
||||
public class Cursor implements SWPlayer.Component {
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private final REntityServer targetServer;
|
||||
private final Player owner;
|
||||
|
||||
private final AtomicBoolean isRendering = new AtomicBoolean(false);
|
||||
|
||||
private RFallingBlockEntity cursorEntity;
|
||||
private final REntityServer cursorServer;
|
||||
private Location cursorLocation;
|
||||
private REntity hitEntity;
|
||||
|
||||
@Setter
|
||||
private Material cursorMaterial;
|
||||
@Setter
|
||||
private List<CursorMode> allowedCursorModes;
|
||||
private final Material highlightMaterial;
|
||||
private final ClickHandler onClick;
|
||||
private final BiConsumer<Location, Optional<REntity>> onRender;
|
||||
|
||||
|
||||
public Cursor(REntityServer targetServer, Player owner, Material highlightMaterial, Material cursorMaterial, List<CursorMode> allowedModes, ClickHandler onClick) {
|
||||
this(targetServer, owner, highlightMaterial, cursorMaterial, allowedModes, onClick, (location, hitEntity) -> {
|
||||
});
|
||||
}
|
||||
|
||||
public Cursor(REntityServer targetServer, Player owner, Material highlightMaterial, Material cursorMaterial, List<CursorMode> allowedModes, ClickHandler onClick, BiConsumer<Location, Optional<REntity>> onRender) {
|
||||
this.targetServer = targetServer;
|
||||
this.owner = owner;
|
||||
this.highlightMaterial = highlightMaterial;
|
||||
this.cursorMaterial = cursorMaterial;
|
||||
this.allowedCursorModes = allowedModes;
|
||||
this.onClick = onClick;
|
||||
this.onRender = onRender;
|
||||
|
||||
cursorServer = new REntityServer();
|
||||
cursorServer.addPlayer(owner);
|
||||
|
||||
SWPlayer.of(owner).setComponent(this);
|
||||
}
|
||||
|
||||
public void renderDeduplicated() {
|
||||
if (!isRendering.getAndSet(true)) {
|
||||
render();
|
||||
isRendering.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void render() {
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(owner, owner.getLocation(), targetServer.getEntities());
|
||||
if (rayTraceResult == null) {
|
||||
if (cursorEntity != null)
|
||||
cursorEntity.die();
|
||||
cursorEntity = null;
|
||||
cursorLocation = null;
|
||||
hitEntity = null;
|
||||
onRender.accept(null, Optional.empty());
|
||||
return;
|
||||
}
|
||||
|
||||
REntity hitEntity = rayTraceResult.getHitEntity() == cursorEntity ? null : rayTraceResult.getHitEntity();
|
||||
|
||||
|
||||
Material activeCursorMaterial = hitEntity == null ? cursorMaterial : highlightMaterial;
|
||||
CursorMode activeCursorMode = allowedCursorModes.stream().filter((mode) -> mode.isActive.test(owner)).min(Comparator.comparingInt(a -> a.priority))
|
||||
.orElse(CursorMode.BLOCK_ALIGNED);
|
||||
|
||||
Location activeCursorLocation = hitEntity == null ? activeCursorMode.positionTransform.apply(owner, rayTraceResult).toLocation(WORLD)
|
||||
: new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD);
|
||||
|
||||
cursorLocation = activeCursorLocation;
|
||||
this.hitEntity = hitEntity;
|
||||
|
||||
if (cursorEntity == null) {
|
||||
cursorEntity = new RFallingBlockEntity(cursorServer, activeCursorLocation, activeCursorMaterial);
|
||||
cursorEntity.setNoGravity(true);
|
||||
} else if (cursorEntity.getMaterial() == activeCursorMaterial) {
|
||||
cursorEntity.move(activeCursorLocation);
|
||||
} else {
|
||||
cursorEntity.die();
|
||||
cursorEntity = new RFallingBlockEntity(cursorServer, activeCursorLocation, activeCursorMaterial);
|
||||
cursorEntity.setNoGravity(true);
|
||||
if (activeCursorMaterial == highlightMaterial) {
|
||||
cursorEntity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
onRender.accept(cursorLocation, Optional.ofNullable(hitEntity));
|
||||
}
|
||||
|
||||
protected void handlePlayerClick(Action clickAction) {
|
||||
renderDeduplicated();
|
||||
onClick.onClick(this.cursorLocation, Optional.ofNullable(this.hitEntity), clickAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnmount(SWPlayer player) {
|
||||
cursorServer.close();
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum CursorMode {
|
||||
FREE(1, (player, rayTraceResult) -> {
|
||||
Vector pos = rayTraceResult.getHitPosition();
|
||||
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (face.getModY() == 0 && player.isSneaking()) {
|
||||
pos.setY(pos.getY() - 0.49);
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}, Player::isSneaking),
|
||||
|
||||
SURFACE_ALIGNED(2, (player, rayTraceResult) -> {
|
||||
Vector hitPosition = rayTraceResult.getHitPosition().clone();
|
||||
Vector pos = blockAlignedPosition(rayTraceResult);
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
|
||||
if (face != null && face != BlockFace.SELF) {
|
||||
switch (face) {
|
||||
case UP:
|
||||
pos.setY(hitPosition.getY());
|
||||
break;
|
||||
case DOWN:
|
||||
pos.setY(hitPosition.getY() + face.getModY());
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
pos.setX(hitPosition.getX() + face.getModX() * 0.5);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
pos.setZ(hitPosition.getZ() + face.getModZ() * 0.5);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}, (player) -> true),
|
||||
|
||||
BLOCK_ALIGNED(0, (player, rayTraceResult) -> blockAlignedPosition(rayTraceResult), (player) -> true);
|
||||
|
||||
|
||||
private final int priority;
|
||||
private final BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> positionTransform;
|
||||
private final Predicate<Player> isActive;
|
||||
|
||||
private static Vector blockAlignedPosition(RayTraceUtils.RRayTraceResult rayTraceResult) {
|
||||
Vector pos = rayTraceResult.getHitPosition();
|
||||
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
|
||||
pos.setY(pos.getBlockY() + 1.0);
|
||||
} else {
|
||||
pos.setY(pos.getBlockY());
|
||||
}
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ClickHandler {
|
||||
void onClick(Location location, Optional<REntity> hitEntity, Action action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package de.steamwar.cursor;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.SWPlayer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@Linked
|
||||
public class CursorListener implements Listener {
|
||||
@Getter
|
||||
private static CursorListener instance;
|
||||
|
||||
public CursorListener() {
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, this::updateCursorFromPacket);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Rot.class, this::updateCursorFromPacket);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, this::updateCursorFromPacket);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
||||
SWPlayer.allWithSingleComponent(Cursor.class)
|
||||
.map(SWPlayer.SWPlayerWithComponent::getComponent)
|
||||
.forEach(Cursor::renderDeduplicated);
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public Packet<?> updateCursorFromPacket(Player player, Packet<?> packet) {
|
||||
SWPlayer swPlayer = SWPlayer.of(player);
|
||||
Optional<Cursor> activeCursor = swPlayer.getComponent(Cursor.class);
|
||||
|
||||
activeCursor.ifPresent(Cursor::renderDeduplicated);
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
SWPlayer.of(event.getPlayer()).getComponent(Cursor.class).ifPresent(cursor -> {
|
||||
event.setCancelled(true);
|
||||
cursor.handlePlayerClick(event.getAction());
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
package de.steamwar.cursor;
|
||||
|
||||
import de.steamwar.entity.REntity;
|
||||
import lombok.Data;
|
||||
@@ -20,6 +20,7 @@
|
||||
package de.steamwar.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import org.bukkit.Location;
|
||||
@@ -27,13 +28,16 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class RArmorStand extends REntity {
|
||||
@Getter
|
||||
public class RArmorStand extends REntity implements RInteractableEntity<RArmorStand> {
|
||||
|
||||
private static final EntityDataAccessor<Byte> sizeWatcher = new EntityDataAccessor<>(15, EntityDataSerializers.BYTE);
|
||||
|
||||
@Getter
|
||||
private final Size size;
|
||||
|
||||
@Setter
|
||||
private REntityActionListener<RArmorStand> callback = null;
|
||||
|
||||
public RArmorStand(REntityServer server, Location location, Size size) {
|
||||
super(server, EntityType.ARMOR_STAND, location, 0);
|
||||
this.size = size;
|
||||
@@ -45,7 +49,7 @@ public class RArmorStand extends REntity {
|
||||
super.spawn(packetSink);
|
||||
|
||||
if (size != null && size != Size.NORMAL) {
|
||||
packetSink.accept(getDataWatcherPacket(sizeWatcher, size.value));
|
||||
entityDataPacket().add(sizeWatcher, size.value).send(packetSink);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user