mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 16:29:16 +00:00
All source patches applied and starts
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -10,8 +10,10 @@ paper-server
|
||||
paper-api-generator
|
||||
|
||||
# sakura
|
||||
build.gradle.kts.rej
|
||||
sakura-api/build.gradle.kts
|
||||
sakura-server/build.gradle.kts
|
||||
sakura-server/src/vanilla
|
||||
src/minecraft/
|
||||
src/vanilla/
|
||||
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
@@ -3,7 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("io.papermc.paperweight.patcher") version "2.0.0-beta.13"
|
||||
id("io.papermc.paperweight.patcher") version "2.0.0-beta.14"
|
||||
}
|
||||
|
||||
paperweight {
|
||||
@@ -27,11 +27,6 @@ paperweight {
|
||||
patchesDir = file("$brand-api/paper-patches")
|
||||
outputDir = file("paper-api")
|
||||
}
|
||||
patchDir("paperApiGenerator") {
|
||||
upstreamPath = "paper-api-generator"
|
||||
patchesDir = file("$brand-api-generator/paper-patches")
|
||||
outputDir = file("paper-api-generator")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ group=me.samsuik.sakura
|
||||
version=1.21.4-R0.1-SNAPSHOT
|
||||
mcVersion=1.21.4
|
||||
|
||||
paperRef=8e80d4e15852ffbed1a18d1e9b34550191433200
|
||||
paperRef=b1b88cd31687c5b3f80c4b0b51fd93a63b3e2498
|
||||
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.vfs.watch=false
|
||||
|
||||
53
sakura-api/build.gradle.kts.patch
Normal file
53
sakura-api/build.gradle.kts.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
--- a/paper-api/build.gradle.kts
|
||||
+++ b/paper-api/build.gradle.kts
|
||||
@@ -93,7 +_,7 @@
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
-val generatedApiPath: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath()
|
||||
+val generatedApiPath: java.nio.file.Path = rootProject.layout.projectDirectory.dir("paper-api/src/generated/java").asFile.toPath()
|
||||
idea {
|
||||
module {
|
||||
generatedSourceDirs.add(generatedApiPath.toFile())
|
||||
@@ -103,6 +_,18 @@
|
||||
main {
|
||||
java {
|
||||
srcDir(generatedApiPath)
|
||||
+ srcDir(file("../paper-api/src/main/java"))
|
||||
+ }
|
||||
+ resources {
|
||||
+ srcDir(file("../paper-api/src/main/resources"))
|
||||
+ }
|
||||
+ }
|
||||
+ test {
|
||||
+ java {
|
||||
+ srcDir(file("../paper-api/src/test/java"))
|
||||
+ }
|
||||
+ resources {
|
||||
+ srcDir(file("../paper-api/src/test/resources"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +_,7 @@
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
- options.overview = "src/main/javadoc/overview.html"
|
||||
+ options.overview = "../paper-api/src/main/javadoc/overview.html"
|
||||
options.use()
|
||||
options.isDocFilesSubDirs = true
|
||||
options.links(
|
||||
@@ -202,11 +_,11 @@
|
||||
}
|
||||
|
||||
// workaround for https://github.com/gradle/gradle/issues/4046
|
||||
- inputs.dir("src/main/javadoc").withPropertyName("javadoc-sourceset")
|
||||
+ inputs.dir("../paper-api/src/main/javadoc").withPropertyName("javadoc-sourceset")
|
||||
val fsOps = services.fileSystemOperations
|
||||
doLast {
|
||||
fsOps.copy {
|
||||
- from("src/main/javadoc") {
|
||||
+ from("../paper-api/src/main/javadoc") {
|
||||
include("**/doc-files/**")
|
||||
}
|
||||
into("build/docs/javadoc")
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -126,6 +_,20 @@
|
||||
// Paper end
|
||||
}
|
||||
|
||||
+ // Sakura start - customise version command; expose git information
|
||||
+ @NotNull
|
||||
+ public static String getGitInformation() {
|
||||
+ final io.papermc.paper.ServerBuildInfo version = io.papermc.paper.ServerBuildInfo.buildInfo();
|
||||
+ final String gitBranch = version.gitBranch().orElse("Dev");
|
||||
+ final String gitCommit = version.gitCommit().orElse("");
|
||||
+ String branchMsg = " on " + gitBranch;
|
||||
+ if ("master".equals(gitBranch) || "main".equals(gitBranch)) {
|
||||
+ branchMsg = ""; // Don't show branch on main/master
|
||||
+ }
|
||||
+ return "(Git: " + gitCommit + branchMsg + ")";
|
||||
+ }
|
||||
+ // Sakura end - customise version command; expose git information
|
||||
+
|
||||
/**
|
||||
* Gets the name of this server implementation.
|
||||
*
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -205,6 +_,10 @@
|
||||
return new Location(this, x, y, z);
|
||||
}
|
||||
// Paper end
|
||||
+ // Sakura start
|
||||
+ @NotNull
|
||||
+ me.samsuik.sakura.local.storage.LocalStorageHandler getStorageHandler();
|
||||
+ // Sakura end
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) block at the given coordinates.
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
@@ -33,6 +_,11 @@
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
// Paper end - version command 2.0
|
||||
+// Sakura start - customise version command
|
||||
+import net.kyori.adventure.text.event.HoverEvent;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+// Sakura end - customise version command
|
||||
|
||||
public class VersionCommand extends BukkitCommand {
|
||||
private VersionFetcher versionFetcher; // Paper - version command 2.0
|
||||
@@ -44,6 +_,15 @@
|
||||
return versionFetcher;
|
||||
}
|
||||
|
||||
+ // Sakura start - customise version command
|
||||
+ private static final String VERSION_MESSAGE = """
|
||||
+ <dark_purple>.
|
||||
+ <dark_purple>| <white>This server is running <gradient:red:light_purple>Sakura</gradient>
|
||||
+ <dark_purple>| <white>Commit<dark_gray>: \\<<commit>> <gray>targeting </gray>(<yellow>MC</yellow>: <gray><version></gray>)
|
||||
+ <dark_purple>| <white>Github<dark_gray>: \\<<yellow><click:open_url:'https://github.com/Samsuik/Sakura'>link</click></yellow>>
|
||||
+ <dark_purple>'""";
|
||||
+ // Sakura end - customise version command
|
||||
+
|
||||
public VersionCommand(@NotNull String name) {
|
||||
super(name);
|
||||
|
||||
@@ -55,11 +_,16 @@
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
|
||||
- if (!testPermission(sender)) return true;
|
||||
-
|
||||
- if (args.length == 0) {
|
||||
+ // Sakura start - customise version command
|
||||
+ if (args.length == 0 || !this.testPermission(sender)) {
|
||||
+ sender.sendMessage(MiniMessage.miniMessage().deserialize(VERSION_MESSAGE,
|
||||
+ Placeholder.component("commit", Component.text("hover", NamedTextColor.YELLOW)
|
||||
+ .hoverEvent(HoverEvent.showText(Component.text(Bukkit.getGitInformation())))),
|
||||
+ Placeholder.unparsed("version", Bukkit.getMinecraftVersion())
|
||||
+ ));
|
||||
//sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
|
||||
- sendVersion(sender);
|
||||
+ //sendVersion(sender);
|
||||
+ // Sakura end - customise version command
|
||||
} else {
|
||||
StringBuilder name = new StringBuilder();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -35,6 +_,22 @@
|
||||
*/
|
||||
public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>, net.kyori.adventure.sound.Sound.Emitter { // Paper
|
||||
|
||||
+ // Sakura start - entity pushed by fluid api
|
||||
+ /**
|
||||
+ * Gets if the entity will be pushed by fluid.
|
||||
+ *
|
||||
+ * @return if this entity can be pushed by fluid.
|
||||
+ */
|
||||
+ boolean isPushedByFluid();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the entity will be pushed by fluid.
|
||||
+ *
|
||||
+ * @param state whether entity should be pushed by fluid
|
||||
+ */
|
||||
+ void setPushedByFluid(boolean state);
|
||||
+ // Sakura end - entity pushed by fluid api
|
||||
+
|
||||
/**
|
||||
* Gets the entity's current position
|
||||
*
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
@@ -9,6 +_,22 @@
|
||||
*/
|
||||
public interface FallingBlock extends Entity {
|
||||
|
||||
+ // Sakura start - falling block height parity api
|
||||
+ /**
|
||||
+ * Gets if falling block has height parity
|
||||
+ *
|
||||
+ * @return parity
|
||||
+ */
|
||||
+ boolean getHeightParity();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets falling block height parity
|
||||
+ *
|
||||
+ * @param parity value
|
||||
+ */
|
||||
+ void setHeightParity(boolean parity);
|
||||
+ // Sakura end - falling block height parity api
|
||||
+
|
||||
/**
|
||||
* Get the Material of the falling block
|
||||
*
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -61,6 +_,12 @@
|
||||
*/
|
||||
public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper
|
||||
|
||||
+ // Sakura start - entity tracking range modifier
|
||||
+ double getTrackingRangeModifier();
|
||||
+
|
||||
+ void setTrackingRangeModifier(double mod);
|
||||
+ // Sakura end - entity tracking range modifier
|
||||
+
|
||||
// Paper start
|
||||
@Override
|
||||
default net.kyori.adventure.identity.@NotNull Identity identity() {
|
||||
@@ -0,0 +1,42 @@
|
||||
package me.samsuik.sakura.entity.merge;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public enum MergeLevel {
|
||||
/**
|
||||
* Disabled.
|
||||
*/
|
||||
NONE(-1),
|
||||
/**
|
||||
* "STRICT" merges entities with the same properties, position, momentum and OOE.
|
||||
* This is considered safe to use, and will not break cannon mechanics.
|
||||
*/
|
||||
STRICT(1),
|
||||
/**
|
||||
* "LENIENT" merges entities aggressively by tracking the entities that have
|
||||
* previously merged. This is a hybrid of "SPAWN" and "STRICT" merging, with the
|
||||
* visuals of "STRICT" merging and better merging potential of "SPAWN" merging.
|
||||
*/
|
||||
LENIENT(2),
|
||||
/**
|
||||
* "SPAWN" merges entities one gametick after they have spawned. Merging is
|
||||
* only possible after it has been established that the entity is safe to
|
||||
* merge by collecting information on the entities that merge together over time.
|
||||
*/
|
||||
SPAWN(3);
|
||||
|
||||
private final int level;
|
||||
|
||||
MergeLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public boolean atLeast(MergeLevel level) {
|
||||
return this.getLevel() >= level.getLevel();
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.samsuik.sakura.entity.merge;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface Mergeable {
|
||||
MergeLevel getMergeLevel();
|
||||
|
||||
void setMergeLevel(MergeLevel level);
|
||||
|
||||
int getStacked();
|
||||
|
||||
void setStacked(int stacked);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.samsuik.sakura.local;
|
||||
|
||||
import io.papermc.paper.math.Position;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public record LocalRegion(int minX, int minZ, int maxX, int maxZ) {
|
||||
public static LocalRegion from(BoundingBox boundingBox) {
|
||||
return of(boundingBox.getMin(), boundingBox.getMax());
|
||||
}
|
||||
|
||||
public static LocalRegion of(Vector min, Vector max) {
|
||||
return of(min.getBlockX(), min.getBlockZ(), max.getBlockX(), max.getBlockZ());
|
||||
}
|
||||
|
||||
public static LocalRegion of(Position min, Position max) {
|
||||
return of(min.blockX(), min.blockZ(), max.blockX(), max.blockZ());
|
||||
}
|
||||
|
||||
public static LocalRegion of(int minX, int minZ, int maxX, int maxZ) {
|
||||
return new LocalRegion(
|
||||
Math.min(minX, maxX), Math.min(minZ, maxZ),
|
||||
Math.max(minX, maxX), Math.max(minZ, maxZ)
|
||||
);
|
||||
}
|
||||
|
||||
public static LocalRegion at(int x, int z, int radius) {
|
||||
return new LocalRegion(x-radius, z-radius, x+radius, z+radius);
|
||||
}
|
||||
|
||||
public boolean intersects(LocalRegion region) {
|
||||
return (this.minX < region.minX() && this.maxX > region.minX() || this.maxX > region.maxX() && this.minX < region.maxX())
|
||||
&& (this.minZ < region.minZ() && this.maxZ > region.minZ() || this.maxZ > region.maxZ() && this.minZ < region.maxZ());
|
||||
}
|
||||
|
||||
public boolean contains(LocalRegion region) {
|
||||
return this.minX < region.minX() && this.maxX > region.maxX()
|
||||
&& this.maxZ < region.minZ() && this.maxZ > region.maxZ();
|
||||
}
|
||||
|
||||
public boolean contains(int x, int z) {
|
||||
return this.minX <= x && this.maxX >= x && this.minZ <= z && this.maxZ >= z;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package me.samsuik.sakura.local;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@NullMarked
|
||||
public record LocalValueKey<T>(NamespacedKey key, Supplier<T> defaultSupplier) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || this.getClass() != o.getClass()) return false;
|
||||
|
||||
LocalValueKey<?> that = (LocalValueKey<?>) o;
|
||||
return this.key.equals(that.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.key.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.samsuik.sakura.local;
|
||||
|
||||
import me.samsuik.sakura.physics.PhysicsVersion;
|
||||
import me.samsuik.sakura.redstone.RedstoneImplementation;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class LocalValueKeys {
|
||||
private static final String NAMESPACE = "sakura";
|
||||
|
||||
public static final LocalValueKey<PhysicsVersion> PHYSICS_VERSION = create("physics-version", () -> PhysicsVersion.LATEST);
|
||||
public static final LocalValueKey<Map<Material, Map.Entry<Integer, Float>>> DURABLE_MATERIALS = create("durable-materials", HashMap::new);
|
||||
public static final LocalValueKey<RedstoneImplementation> REDSTONE_IMPLEMENTATION = create("redstone-implementation", () -> RedstoneImplementation.VANILLA);
|
||||
public static final LocalValueKey<Boolean> CONSISTENT_EXPLOSION_RADIUS = create("consistent-radius", () -> false);
|
||||
public static final LocalValueKey<Boolean> REDSTONE_CACHE = create("redstone-cache", () -> false);
|
||||
public static final LocalValueKey<Integer> LAVA_FLOW_SPEED = create("lava-flow-speed", () -> -1);
|
||||
|
||||
private static <T> LocalValueKey<T> create(String key, Supplier<T> supplier) {
|
||||
return new LocalValueKey<>(new NamespacedKey(NAMESPACE, key), supplier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.samsuik.sakura.local.storage;
|
||||
|
||||
import me.samsuik.sakura.local.LocalRegion;
|
||||
import org.bukkit.Location;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface LocalStorageHandler {
|
||||
default @NonNull Optional<LocalRegion> locate(@NonNull Location location) {
|
||||
return this.locate(location.blockX(), location.blockZ());
|
||||
}
|
||||
|
||||
@NonNull Optional<LocalRegion> locate(int x, int z);
|
||||
|
||||
@Nullable LocalValueStorage get(@NonNull LocalRegion region);
|
||||
|
||||
boolean has(@NonNull LocalRegion region);
|
||||
|
||||
void put(@NonNull LocalRegion region, @NonNull LocalValueStorage storage);
|
||||
|
||||
void remove(@NonNull LocalRegion region);
|
||||
|
||||
@NonNull List<LocalRegion> regions();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package me.samsuik.sakura.local.storage;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import me.samsuik.sakura.local.LocalValueKey;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@NullMarked
|
||||
@SuppressWarnings("unchecked")
|
||||
public final class LocalValueStorage {
|
||||
private final Map<LocalValueKey<?>, Object> map = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
public <T> void set(LocalValueKey<T> key, T insert) {
|
||||
this.map.put(key, insert);
|
||||
}
|
||||
|
||||
public void remove(LocalValueKey<?> key) {
|
||||
this.map.remove(key);
|
||||
}
|
||||
|
||||
public <T> Optional<T> get(LocalValueKey<T> key) {
|
||||
T value = (T) this.map.get(key);
|
||||
return Optional.ofNullable(value);
|
||||
}
|
||||
|
||||
public <T> T getOrDefault(LocalValueKey<T> key, T def) {
|
||||
return (T) this.map.getOrDefault(key, def);
|
||||
}
|
||||
|
||||
public boolean exists(LocalValueKey<?> key) {
|
||||
return this.map.containsKey(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T> T value(LocalValueKey<T> key) {
|
||||
return (T) this.map.get(key);
|
||||
}
|
||||
|
||||
public <T> T value(LocalValueKey<T> key, boolean returnDefault) {
|
||||
T val = (T) this.map.get(key);
|
||||
if (!returnDefault || val != null)
|
||||
return val;
|
||||
// update value
|
||||
this.set(key, val = key.defaultSupplier().get());
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package me.samsuik.sakura.physics;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public enum PhysicsVersion {
|
||||
LEGACY("legacy", 1_0_0), // replicates patched 1.8.8 paper mechanics
|
||||
v1_8_2("1.8.2", 1_8_2), // vanilla mechanics
|
||||
v1_9("1.9", 1_9_0),
|
||||
v1_10("1.10", 1_10_0),
|
||||
v1_11("1.11", 1_11_0),
|
||||
v1_12("1.12", 1_12_0),
|
||||
v1_13("1.13", 1_13_0),
|
||||
v1_14("1.14", 1_14_0),
|
||||
v1_16("1.16", 1_16_0),
|
||||
v1_17("1.17", 1_17_0),
|
||||
v1_18_2("1.18.2", 1_18_2),
|
||||
v1_19_3("1.19.3", 1_19_3),
|
||||
v1_20("1.20", 1_20_0),
|
||||
v1_21_2("1.21.2", 1_21_2),
|
||||
LATEST("latest", 9_99_9); // latest version
|
||||
|
||||
private final String friendlyName;
|
||||
private final int version;
|
||||
|
||||
PhysicsVersion(String friendlyName, int version) {
|
||||
this.friendlyName = friendlyName;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean isLegacy() {
|
||||
return this == LEGACY;
|
||||
}
|
||||
|
||||
public boolean afterOrEqual(int version) {
|
||||
return this.version >= version;
|
||||
}
|
||||
|
||||
public boolean before(int version) {
|
||||
return this.version < version;
|
||||
}
|
||||
|
||||
public boolean is(int version) {
|
||||
return this.version == version;
|
||||
}
|
||||
|
||||
public boolean isWithin(int min, int max) {
|
||||
return this.version >= min && this.version <= max;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getFriendlyName() {
|
||||
return this.friendlyName;
|
||||
}
|
||||
|
||||
public static PhysicsVersion from(String string) {
|
||||
int parsedVersion = Integer.MIN_VALUE;
|
||||
try {
|
||||
String versionString = string.replace(".", "");
|
||||
parsedVersion = Integer.parseInt(versionString);
|
||||
} catch (NumberFormatException nfe) {
|
||||
// ignored
|
||||
}
|
||||
for (PhysicsVersion ver : values()) {
|
||||
if (ver.name().equalsIgnoreCase(string) || ver.getFriendlyName().equalsIgnoreCase(string) || ver.is(parsedVersion)) {
|
||||
return ver;
|
||||
}
|
||||
}
|
||||
return LATEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.samsuik.sakura.redstone;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public enum RedstoneImplementation {
|
||||
VANILLA("vanilla"),
|
||||
EIGENCRAFT("eigencraft"),
|
||||
ALTERNATE_CURRENT("alternate-current");
|
||||
|
||||
private final String friendlyName;
|
||||
|
||||
RedstoneImplementation(String friendlyName) {
|
||||
this.friendlyName = friendlyName;
|
||||
}
|
||||
|
||||
public String getFriendlyName() {
|
||||
return this.friendlyName;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
dependencies {
|
||||
mache("io.papermc:mache:1.21.4+build.7")
|
||||
@@ -21,6 +_,21 @@
|
||||
@@ -21,6 +_,17 @@
|
||||
// macheOldPath = file("F:\\Projects\\PaperTooling\\mache\\versions\\1.21.4\\src\\main\\java")
|
||||
// gitFilePatches = true
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
+ }
|
||||
+
|
||||
+ activeFork = fork
|
||||
+
|
||||
+ paper {
|
||||
+ paperServerDir = upstreamsDirectory().map { it.dir("paper/paper-server") }
|
||||
+ }
|
||||
+
|
||||
spigot {
|
||||
buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42"
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
||||
@@ -297,6 +_,12 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Sakura start - add utility methods to entity slices
|
||||
+ public Entity[] getSectionEntities(int sectionY) {
|
||||
+ return this.allEntities.getSectionEntities(sectionY);
|
||||
+ }
|
||||
+ // Sakura end - add utility methods to entity slices
|
||||
+
|
||||
public void getHardCollidingEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
|
||||
this.hardCollidingEntities.getEntities(except, box, into, predicate);
|
||||
}
|
||||
@@ -383,6 +_,13 @@
|
||||
|
||||
private E[] storage;
|
||||
private int size;
|
||||
+ // Sakura start - use methods from EntityList
|
||||
+ private it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap entityToIndex = null;
|
||||
+ private void setupIndexMap() {
|
||||
+ this.entityToIndex = new it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap(2, 0.8f);
|
||||
+ this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE);
|
||||
+ }
|
||||
+ // Sakura end - use methods from EntityList
|
||||
|
||||
public BasicEntityList() {
|
||||
this(0);
|
||||
@@ -403,6 +_,7 @@
|
||||
private void resize() {
|
||||
if (this.storage == EMPTY) {
|
||||
this.storage = (E[])new Entity[DEFAULT_CAPACITY];
|
||||
+ this.setupIndexMap(); // Sakura - use methods from EntityList
|
||||
} else {
|
||||
this.storage = Arrays.copyOf(this.storage, this.storage.length * 2);
|
||||
}
|
||||
@@ -416,6 +_,7 @@
|
||||
} else {
|
||||
this.storage[idx] = entity;
|
||||
}
|
||||
+ this.entityToIndex.put(entity.getId(), idx); // Sakura - use methods from EntityList
|
||||
}
|
||||
|
||||
public int indexOf(final E entity) {
|
||||
@@ -431,24 +_,32 @@
|
||||
}
|
||||
|
||||
public boolean remove(final E entity) {
|
||||
- final int idx = this.indexOf(entity);
|
||||
- if (idx == -1) {
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- final int size = --this.size;
|
||||
- final E[] storage = this.storage;
|
||||
- if (idx != size) {
|
||||
- System.arraycopy(storage, idx + 1, storage, idx, size - idx);
|
||||
- }
|
||||
-
|
||||
- storage[size] = null;
|
||||
+ // Sakura start - use methods from EntityList
|
||||
+ if (this.entityToIndex == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final int index = this.entityToIndex.remove(entity.getId());
|
||||
+ if (index == Integer.MIN_VALUE) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // move the entity at the end to this index
|
||||
+ final int endIndex = --this.size;
|
||||
+ final E end = this.storage[endIndex];
|
||||
+ if (index != endIndex) {
|
||||
+ // not empty after this call
|
||||
+ this.entityToIndex.put(end.getId(), index); // update index
|
||||
+ }
|
||||
+ this.storage[index] = end;
|
||||
+ this.storage[endIndex] = null;
|
||||
+ // Sakura end - use methods from EntityList
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean has(final E entity) {
|
||||
- return this.indexOf(entity) != -1;
|
||||
+ return this.entityToIndex != null && this.entityToIndex.containsKey(entity.getId()); // Sakura - use methods from EntityList
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +_,18 @@
|
||||
this.entitiesBySection[sectionIndex] = null;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Sakura start - add utility methods to entity slices
|
||||
+ public Entity[] getSectionEntities(int sectionY) {
|
||||
+ BasicEntityList<Entity> list = this.entitiesBySection[sectionY - this.slices.minSection];
|
||||
+
|
||||
+ if (list != null) {
|
||||
+ return list.storage;
|
||||
+ }
|
||||
+
|
||||
+ return new Entity[0];
|
||||
+ }
|
||||
+ // Sakura end - add utility methods to entity slices
|
||||
|
||||
public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
|
||||
if (this.count == 0) {
|
||||
@@ -0,0 +1,55 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -300,6 +_,7 @@
|
||||
public volatile boolean abnormalExit; // Paper - Improved watchdog support
|
||||
public volatile Thread shutdownThread; // Paper - Improved watchdog support
|
||||
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
+ public final me.samsuik.sakura.configuration.SakuraConfigurations sakuraConfigurations; // Sakura
|
||||
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
@@ -390,6 +_,17 @@
|
||||
}
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
+ // Sakura start - track tick information
|
||||
+ private final me.samsuik.sakura.tps.TickInformationCollector tickInformationCollector = new me.samsuik.sakura.tps.TickInformationCollector();
|
||||
+
|
||||
+ public final me.samsuik.sakura.tps.ServerTickInformation latestTickInformation() {
|
||||
+ return this.tickInformationCollector.latestTickInformation();
|
||||
+ }
|
||||
+
|
||||
+ public final ImmutableList<me.samsuik.sakura.tps.ServerTickInformation> tickHistory(long from, long to) {
|
||||
+ return this.tickInformationCollector.collect(from, to);
|
||||
+ }
|
||||
+ // Sakura end - track tick information
|
||||
|
||||
public MinecraftServer(
|
||||
// CraftBukkit start
|
||||
@@ -471,6 +_,10 @@
|
||||
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
// CraftBukkit end
|
||||
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
|
||||
+ // Sakura start
|
||||
+ final java.nio.file.Path sakuraConfigDirPath = ((java.io.File) options.valueOf("sakura-settings-directory")).toPath();
|
||||
+ this.sakuraConfigurations = me.samsuik.sakura.configuration.SakuraConfigurations.setup(sakuraConfigDirPath);
|
||||
+ // Sakura end
|
||||
}
|
||||
|
||||
private void readScoreboard(DimensionDataStorage dataStorage) {
|
||||
@@ -1221,6 +_,7 @@
|
||||
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
|
||||
final long diff = currentTime - tickSection;
|
||||
final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
|
||||
+ this.tickInformationCollector.levelData(this.levels.values(), currentTps.doubleValue()); // Sakura - track tick information
|
||||
tps1.add(currentTps, diff);
|
||||
tps5.add(currentTps, diff);
|
||||
tps15.add(currentTps, diff);
|
||||
@@ -1256,6 +_,7 @@
|
||||
throw new RuntimeException("Chunk system crash propagated to tick()", crash);
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
+ this.tickInformationCollector.tickDuration((System.nanoTime() - currentTime) / 1_000_000L); // Sakura - track tick information
|
||||
this.tickFrame.end();
|
||||
profilerFiller.popPush("nextTickWait");
|
||||
this.mayHaveDelayedTasks = true;
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -225,6 +_,11 @@
|
||||
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||
+ // Sakura start - sakura configuration files
|
||||
+ sakuraConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
+ sakuraConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this);
|
||||
+ // Sakura end - sakura configuration files
|
||||
|
||||
this.setPvpAllowed(properties.pvp);
|
||||
this.setFlightAllowed(properties.allowFlight);
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -129,7 +_,7 @@
|
||||
public final AtomicInteger tickingGenerated = new AtomicInteger(); // Paper - public
|
||||
private final String storageName;
|
||||
private final PlayerMap playerMap = new PlayerMap();
|
||||
- public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = new Int2ObjectOpenHashMap<>();
|
||||
+ public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = new me.samsuik.sakura.utils.collections.TrackedEntityChunkMap(); // Sakura - optimised tracked entity map
|
||||
private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap();
|
||||
// Paper - rewrite chunk system
|
||||
public int serverViewDistance;
|
||||
@@ -1217,7 +_,10 @@
|
||||
double vec3_dz = player.getZ() - this.entity.getZ();
|
||||
// Paper end - remove allocation of Vec3D here
|
||||
int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player);
|
||||
- double d = Math.min(this.getEffectiveRange(), playerViewDistance * 16);
|
||||
+ // Sakura start - entity tracking range modifier
|
||||
+ double visibleRange = this.getEffectiveRange() * player.trackingRangeModifier;
|
||||
+ double d = Math.min(visibleRange, playerViewDistance * 16);
|
||||
+ // Sakura end - entity tracking range modifier
|
||||
double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper
|
||||
double d2 = d * d;
|
||||
// Paper start - Configurable entity tracking range by Y
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -588,7 +_,7 @@
|
||||
org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit
|
||||
) {
|
||||
// CraftBukkit start
|
||||
- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor
|
||||
+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), () -> server.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), server.registryAccess())), dispatcher); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor
|
||||
this.pvpMode = server.isPvpAllowed();
|
||||
this.levelStorageAccess = levelStorageAccess;
|
||||
this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile());
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -423,6 +_,7 @@
|
||||
return this.viewDistanceHolder;
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
+ public double trackingRangeModifier = 1.0; // Sakura - entity tracking range modifier
|
||||
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
|
||||
super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile);
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -525,6 +_,7 @@
|
||||
}
|
||||
}
|
||||
// Paper end - optimise entity tracker
|
||||
+ public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
|
||||
|
||||
public Entity(EntityType<?> entityType, Level level) {
|
||||
this.type = entityType;
|
||||
@@ -4025,7 +_,7 @@
|
||||
}
|
||||
|
||||
public boolean isPushedByFluid() {
|
||||
- return true;
|
||||
+ return this.pushedByFluid; // Sakura - entity pushed by fluid api
|
||||
}
|
||||
|
||||
public static double getViewScale() {
|
||||
@@ -0,0 +1,176 @@
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -307,6 +_,43 @@
|
||||
return this.getYHeadRot();
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Sakura start - legacy combat mechanics
|
||||
+ private static final ResourceLocation LEGACY_COMBAT_MODIFIER_ID = ResourceLocation.fromNamespaceAndPath("sakura", "legacy_combat");
|
||||
+ private static final AttributeModifier LEGACY_ATTACK_SPEED_MODIFIER = new AttributeModifier(LEGACY_COMBAT_MODIFIER_ID, 100.0, AttributeModifier.Operation.ADD_VALUE);
|
||||
+
|
||||
+ private void updateAttackSpeedModifier() {
|
||||
+ AttributeInstance attackSpeed = this.getAttribute(Attributes.ATTACK_SPEED);
|
||||
+ if (attackSpeed != null) {
|
||||
+ attackSpeed.removeModifier(LEGACY_ATTACK_SPEED_MODIFIER);
|
||||
+
|
||||
+ if (this.level().sakuraConfig().players.combat.legacyCombatMechanics) {
|
||||
+ attackSpeed.addTransientModifier(LEGACY_ATTACK_SPEED_MODIFIER);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ protected final float getAttackDamageFromAttributes() {
|
||||
+ AttributeInstance attackDamage = this.getAttribute(Attributes.ATTACK_DAMAGE);
|
||||
+ AttributeModifier legacyModifier = null;
|
||||
+
|
||||
+ if (this.level().sakuraConfig().players.combat.legacyCombatMechanics) {
|
||||
+ ItemStack heldItem = this.getLastHandItem(EquipmentSlot.MAINHAND);
|
||||
+ double attackDifference = me.samsuik.sakura.player.combat.CombatUtil.getLegacyAttackDifference(heldItem);
|
||||
+ legacyModifier = new AttributeModifier(LEGACY_COMBAT_MODIFIER_ID, attackDifference, AttributeModifier.Operation.ADD_VALUE);
|
||||
+ }
|
||||
+
|
||||
+ final double damage;
|
||||
+ if (attackDamage == null || legacyModifier == null) {
|
||||
+ damage = this.getAttributeValue(Attributes.ATTACK_DAMAGE);
|
||||
+ } else {
|
||||
+ attackDamage.addTransientModifier(legacyModifier);
|
||||
+ damage = this.getAttributeValue(Attributes.ATTACK_DAMAGE);
|
||||
+ attackDamage.removeModifier(legacyModifier);
|
||||
+ }
|
||||
+
|
||||
+ return (float) damage;
|
||||
+ }
|
||||
+ // Sakura end - legacy combat mechanics
|
||||
|
||||
protected LivingEntity(EntityType<? extends LivingEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -1479,7 +_,7 @@
|
||||
}
|
||||
// Paper end - Check distance in entity interactions
|
||||
|
||||
- this.knockback(0.4F, d, d1, damageSource.getDirectEntity(), damageSource.getDirectEntity() == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events
|
||||
+ this.knockback((float) this.level().sakuraConfig().players.knockback.baseKnockback, d, d1, damageSource.getDirectEntity(), damageSource.getDirectEntity() == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events // Sakura - configure entity knockback
|
||||
if (!flag) {
|
||||
this.indicateDamage(d, d1);
|
||||
}
|
||||
@@ -1570,7 +_,7 @@
|
||||
}
|
||||
|
||||
protected void blockedByShield(LivingEntity defender) {
|
||||
- defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events
|
||||
+ defender.knockback((float) this.level().sakuraConfig().players.knockback.shieldHitKnockback, defender.getX() - this.getX(), defender.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events // Sakura - configure entity knockback
|
||||
}
|
||||
|
||||
private boolean checkTotemDeathProtection(DamageSource damageSource) {
|
||||
@@ -1747,6 +_,12 @@
|
||||
|
||||
// Paper start
|
||||
if (this.dead) { // Paper
|
||||
+ // Sakura start - instant mob death animation
|
||||
+ if (this.level().sakuraConfig().entity.instantDeathAnimation && !(this instanceof Player)) {
|
||||
+ this.deathTime = 20;
|
||||
+ return;
|
||||
+ }
|
||||
+ // Sakura end - instant mob death animation
|
||||
this.level().broadcastEntityEvent(this, (byte)3);
|
||||
|
||||
this.setPose(Pose.DYING);
|
||||
@@ -1920,7 +_,7 @@
|
||||
}
|
||||
|
||||
public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events
|
||||
- strength *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
|
||||
+ strength *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * this.level().sakuraConfig().players.knockback.knockbackResistanceModifier; // Sakura - configure entity knockback
|
||||
if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0
|
||||
// this.hasImpulse = true; // CraftBukkit - Move down
|
||||
Vec3 deltaMovement = this.getDeltaMovement();
|
||||
@@ -1931,10 +_,18 @@
|
||||
}
|
||||
|
||||
Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength);
|
||||
+ // Sakura start - configure entity knockback
|
||||
+ double velocityY = deltaMovement.y / 2.0D + this.level().sakuraConfig().players.knockback.knockbackVertical.or(strength);
|
||||
+ if (!this.level().sakuraConfig().players.knockback.verticalKnockbackRequireGround || this.onGround()) {
|
||||
+ velocityY = Math.min(this.level().sakuraConfig().players.knockback.knockbackVerticalLimit, velocityY);
|
||||
+ } else {
|
||||
+ velocityY = deltaMovement.y;
|
||||
+ }
|
||||
+ // Sakura end - configure entity knockback
|
||||
// Paper start - knockback events
|
||||
Vec3 finalVelocity = new Vec3(
|
||||
deltaMovement.x / 2.0 - vec3.x,
|
||||
- this.onGround() ? Math.min(0.4, deltaMovement.y / 2.0 + strength) : deltaMovement.y,
|
||||
+ velocityY, // Sakura - configure entity knockback
|
||||
deltaMovement.z / 2.0 - vec3.z
|
||||
);
|
||||
Vec3 diff = finalVelocity.subtract(deltaMovement);
|
||||
@@ -2156,9 +_,21 @@
|
||||
protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) {
|
||||
if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) {
|
||||
// this.hurtArmor(damageSource, damageAmount); // CraftBukkit - actuallyHurt(DamageSource, float, EntityDamageEvent) for damage handling
|
||||
+ // Sakura start - legacy combat mechanics
|
||||
+ if (!this.level().sakuraConfig().players.combat.legacyCombatMechanics) {
|
||||
damageAmount = CombatRules.getDamageAfterAbsorb(
|
||||
this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)
|
||||
);
|
||||
+ } else {
|
||||
+ // See: applyArmorModifier(DamageSource, float)
|
||||
+ // int k = 1.0 - (20.0 / 25.0);
|
||||
+ // int i = 25 - this.getArmorValue();
|
||||
+ // float f1 = damageAmount * (float) i;
|
||||
+ // damageAmount = f1 / 25.0F;
|
||||
+ float armorDamageModifier = 1.0f - (this.getArmorValue() / 25.0f);
|
||||
+ damageAmount *= armorDamageModifier;
|
||||
+ }
|
||||
+ // Sakura end - legacy combat mechanics
|
||||
}
|
||||
|
||||
return damageAmount;
|
||||
@@ -2248,7 +_,13 @@
|
||||
com.google.common.base.Function<Double, Double> blocking = new com.google.common.base.Function<Double, Double>() {
|
||||
@Override
|
||||
public Double apply(Double f) {
|
||||
+ // Sakura start - shield damage reduction
|
||||
+ if (!level().sakuraConfig().players.combat.shieldDamageReduction || damagesource.getDirectEntity() instanceof AbstractArrow) {
|
||||
return -((LivingEntity.this.isDamageSourceBlocked(damagesource)) ? f : 0.0);
|
||||
+ } else {
|
||||
+ return -(LivingEntity.this.isBlocking() ? f * 0.5 : 0.0);
|
||||
+ }
|
||||
+ // Sakura end - shield damage reduction
|
||||
}
|
||||
};
|
||||
float blockingModifier = blocking.apply((double) amount).floatValue();
|
||||
@@ -2344,6 +_,12 @@
|
||||
// Apply damage to armor
|
||||
if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) {
|
||||
float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
|
||||
+ // Sakura start - add max armour durability damage
|
||||
+ final int maxArmourDamage = this.level().sakuraConfig().players.combat.maxArmourDamage.or(-1);
|
||||
+ if (maxArmourDamage >= 0) {
|
||||
+ armorDamage = Math.min(armorDamage, maxArmourDamage);
|
||||
+ }
|
||||
+ // Sakura end - add max armour durability damage
|
||||
this.hurtArmor(damageSource, armorDamage);
|
||||
}
|
||||
|
||||
@@ -3269,6 +_,11 @@
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
EnchantmentHelper.runLocationChangedEffects(serverLevel, itemBySlot, this, equipmentSlot1);
|
||||
}
|
||||
+ // Sakura start - legacy combat mechanics
|
||||
+ if (this instanceof ServerPlayer && equipmentSlot1 == EquipmentSlot.MAINHAND) {
|
||||
+ this.updateAttackSpeedModifier();
|
||||
+ }
|
||||
+ // Sakura end - legacy combat mechanics
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3492,7 +_,7 @@
|
||||
}
|
||||
}
|
||||
// Paper end - Add EntityMoveEvent
|
||||
- if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
|
||||
+ if (this.level() instanceof ServerLevel serverLevel && this.level().sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura - configure entity water sensitivity
|
||||
this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -846,7 +_,7 @@
|
||||
protected final void serverAiStep() {
|
||||
this.noActionTime++;
|
||||
// Paper start - Allow nerfed mobs to jump and float
|
||||
- if (!this.aware) {
|
||||
+ if (!this.aware || this.level().sakuraConfig().entity.disableMobAi) { // Sakura - add option to disable entity ai
|
||||
if (goalFloat != null) {
|
||||
if (goalFloat.canUse()) goalFloat.tick();
|
||||
this.getJumpControl().tick();
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/world/entity/animal/IronGolem.java
|
||||
+++ b/net/minecraft/world/entity/animal/IronGolem.java
|
||||
@@ -228,6 +_,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // Sakura start - configure iron golems taking fall damage
|
||||
+ @Override
|
||||
+ protected int calculateFallDamage(float fallDistance, float damageMultiplier) {
|
||||
+ if (!this.level().sakuraConfig().entity.ironGolemsTakeFalldamage) {
|
||||
+ return super.calculateFallDamage(fallDistance, damageMultiplier);
|
||||
+ } else {
|
||||
+ float safeFallDistance = (float)this.getAttributeValue(Attributes.SAFE_FALL_DISTANCE);
|
||||
+ float damage = fallDistance - safeFallDistance;
|
||||
+ return net.minecraft.util.Mth.ceil(damage * damageMultiplier * this.getAttributeValue(Attributes.FALL_DAMAGE_MULTIPLIER));
|
||||
+ }
|
||||
+ }
|
||||
+ // Sakura end - configure iron golems taking fall damage
|
||||
+
|
||||
public int getAttackAnimationTick() {
|
||||
return this.attackAnimationTick;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -68,9 +_,11 @@
|
||||
public boolean forceTickAfterTeleportToDuplicate;
|
||||
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
|
||||
public boolean autoExpire = true; // Paper - Expand FallingBlock API
|
||||
+ public boolean heightParity; // Sakura - falling block height parity api
|
||||
|
||||
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
+ this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics
|
||||
}
|
||||
|
||||
public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) {
|
||||
@@ -138,6 +_,13 @@
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
+ // Sakura start - falling block height parity api
|
||||
+ @Override
|
||||
+ public final double getEyeY() {
|
||||
+ return this.heightParity ? this.getY() : super.getEyeY();
|
||||
+ }
|
||||
+ // Sakura end - falling block height parity api
|
||||
+
|
||||
@Override
|
||||
protected double getDefaultGravity() {
|
||||
return 0.04;
|
||||
@@ -165,7 +_,7 @@
|
||||
this.handlePortal();
|
||||
if (this.level() instanceof ServerLevel serverLevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) {
|
||||
BlockPos blockPos = this.blockPosition();
|
||||
- boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
|
||||
+ boolean flag = this.level().sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura - configure concrete solidifying in water
|
||||
boolean flag1 = flag && this.level().getFluidState(blockPos).is(FluidTags.WATER);
|
||||
double d = this.getDeltaMovement().lengthSqr();
|
||||
if (flag && d > 1.0) {
|
||||
@@ -181,7 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!this.onGround() && !flag1) {
|
||||
+ if (!this.onGround() && !flag1 || this.level().sakuraConfig().cannons.sand.despawnInsideMovingPistons && this.autoExpire && this.time > 600) { // Sakura - allow falling blocks to despawn inside moving pistons
|
||||
if ((this.time > 100 && autoExpire) && (blockPos.getY() <= this.level().getMinY() || blockPos.getY() > this.level().getMaxY()) || (this.time > 600 && autoExpire)) { // Paper - Expand FallingBlock API
|
||||
if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
this.spawnAtLocation(serverLevel, block);
|
||||
@@ -199,7 +_,7 @@
|
||||
);
|
||||
boolean flag2 = FallingBlock.isFree(this.level().getBlockState(blockPos.below())) && (!flag || !flag1);
|
||||
boolean flag3 = this.blockState.canSurvive(this.level(), blockPos) && !flag2;
|
||||
- if (canBeReplaced && flag3) {
|
||||
+ if (canBeReplaced && flag3 && this.level().sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura - falling block stacking restrictions
|
||||
if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED)
|
||||
&& this.level().getFluidState(blockPos).getType() == Fluids.WATER) {
|
||||
this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(true));
|
||||
@@ -243,6 +_,10 @@
|
||||
this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
this.callOnBrokenAfterFall(block, blockPos);
|
||||
this.spawnAtLocation(serverLevel, block);
|
||||
+ // Sakura start - fix falling blocks staying alive when entity drops are disabled
|
||||
+ } else {
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
+ // Sakura end - fix falling blocks staying alive when entity drops are disabled
|
||||
}
|
||||
} else {
|
||||
this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -363,6 +_,11 @@
|
||||
|
||||
@Override
|
||||
public boolean ignoreExplosion(Explosion explosion) {
|
||||
+ // Sakura start - add list of items that ignore explosions
|
||||
+ if (this.level().sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Sakura end - add list of items that ignore explosions
|
||||
return !explosion.shouldAffectBlocklikeEntities() || super.ignoreExplosion(explosion);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -73,6 +_,12 @@
|
||||
this.yo = y;
|
||||
this.zo = z;
|
||||
this.owner = owner;
|
||||
+ // Sakura start - configure cannon mechanics
|
||||
+ switch (level.sakuraConfig().cannons.mechanics.tntSpread) {
|
||||
+ case NONE -> this.setDeltaMovement(0.0, 0.0, 0.0);
|
||||
+ case Y -> this.setDeltaMovement(this.getDeltaMovement().multiply(0.0, 1.0, 0.0));
|
||||
+ }
|
||||
+ // Sakura end - configure cannon mechanics
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +_,21 @@
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
+ // Sakura start - optimise tnt fluid state
|
||||
+ @Override
|
||||
+ protected boolean updateInWaterStateAndDoFluidPushing() {
|
||||
+ if (this.isPushedByFluid()) {
|
||||
+ return super.updateInWaterStateAndDoFluidPushing();
|
||||
+ } else {
|
||||
+ // super method also handles lava fluid pushing
|
||||
+ // we only need to search for water to negate fall distance
|
||||
+ this.fluidHeight.clear();
|
||||
+ this.updateInWaterStateAndDoWaterCurrentPushing();
|
||||
+ return this.isInWater();
|
||||
+ }
|
||||
+ }
|
||||
+ // Sakura end - optimise tnt fluid state
|
||||
+
|
||||
@Override
|
||||
protected double getDefaultGravity() {
|
||||
return 0.04;
|
||||
@@ -98,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
- if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
||||
+ // Sakura - remove max tnt per tick
|
||||
this.handlePortal();
|
||||
this.applyGravity();
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
@@ -130,6 +_,14 @@
|
||||
this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
+ // Sakura start - configure force position updates
|
||||
+ if (this.level().sakuraConfig().cannons.tnt.forcePositionUpdates) {
|
||||
+ this.forcePositionUpdateInWater();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void forcePositionUpdateInWater() {
|
||||
+ // Sakura end - configure force position updates
|
||||
// Paper start - Option to prevent TNT from moving in water
|
||||
if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) {
|
||||
/*
|
||||
@@ -248,7 +_,7 @@
|
||||
// Paper start - Option to prevent TNT from moving in water
|
||||
@Override
|
||||
public boolean isPushedByFluid() {
|
||||
- return !this.level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
|
||||
+ return !this.level().paperConfig().fixes.preventTntFromMovingInWater && this.level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - configure cannon mechanics
|
||||
}
|
||||
// Paper end - Option to prevent TNT from moving in water
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -200,6 +_,7 @@
|
||||
private int currentImpulseContextResetGraceTime;
|
||||
public boolean affectsSpawning = true; // Paper - Affects Spawning API
|
||||
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
||||
+ private long lastSprintKnockback = -1; // Sakura - configure entity knockback
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
@@ -895,6 +_,10 @@
|
||||
public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) {
|
||||
if (super.isInvulnerableTo(level, damageSource)) {
|
||||
return true;
|
||||
+ // Sakura start - allow disabling explosions hurting players
|
||||
+ } else if (!this.level().sakuraConfig().cannons.explosion.explosionsHurtPlayers && damageSource.is(DamageTypeTags.IS_EXPLOSION)) {
|
||||
+ return true;
|
||||
+ // Sakura end - allow disabling explosions hurting players
|
||||
} else if (damageSource.is(DamageTypeTags.IS_DROWNING)) {
|
||||
return !level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE);
|
||||
} else if (damageSource.is(DamageTypeTags.IS_FALL)) {
|
||||
@@ -1225,13 +_,19 @@
|
||||
if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable.
|
||||
{
|
||||
// Paper end - PlayerAttackEntityEvent
|
||||
- float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE);
|
||||
+ float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : this.getAttackDamageFromAttributes(); // Sakura - legacy combat mechanics
|
||||
ItemStack weaponItem = this.getWeaponItem();
|
||||
DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this));
|
||||
float f1 = this.getEnchantedDamage(target, f, damageSource) - f;
|
||||
float attackStrengthScale = this.getAttackStrengthScale(0.5F);
|
||||
+ // Sakura start - legacy combat mechanics
|
||||
+ if (!this.level().sakuraConfig().players.combat.legacyCombatMechanics) {
|
||||
f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F;
|
||||
f1 *= attackStrengthScale;
|
||||
+ } else if (f1 != 0.0) {
|
||||
+ f1 += me.samsuik.sakura.player.combat.CombatUtil.calculateLegacySharpnessDamage(this, weaponItem, damageSource);
|
||||
+ }
|
||||
+ // Sakura end - legacy combat mechanics
|
||||
// this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
|
||||
if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE)
|
||||
&& target instanceof Projectile projectile) {
|
||||
@@ -1249,7 +_,7 @@
|
||||
if (f > 0.0F || f1 > 0.0F) {
|
||||
boolean flag = attackStrengthScale > 0.9F;
|
||||
boolean flag1;
|
||||
- if (this.isSprinting() && flag) {
|
||||
+ if (this.isSprinting() && (!this.level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura - configure entity knockback
|
||||
this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
||||
flag1 = true;
|
||||
} else {
|
||||
@@ -1265,7 +_,7 @@
|
||||
&& !this.hasEffect(MobEffects.BLINDNESS)
|
||||
&& !this.isPassenger()
|
||||
&& target instanceof LivingEntity
|
||||
- && !this.isSprinting();
|
||||
+ && (this.level().sakuraConfig().players.combat.legacyCombatMechanics || !this.isSprinting()); // Sakura - legacy combat mechanics
|
||||
flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits
|
||||
if (flag2) {
|
||||
damageSource = damageSource.critical(true); // Paper start - critical damage API
|
||||
@@ -1292,7 +_,21 @@
|
||||
if (flag4) {
|
||||
float f4 = this.getKnockback(target, damageSource) + (flag1 ? 1.0F : 0.0F);
|
||||
if (f4 > 0.0F) {
|
||||
- if (target instanceof LivingEntity livingEntity1) {
|
||||
+ // Sakura start - configure entity knockback; extra sprinting knockback
|
||||
+ long millis = System.currentTimeMillis();
|
||||
+ long sinceLastKnockback = millis - this.lastSprintKnockback;
|
||||
+ if (flag1) { // attackHasExtraKnockback
|
||||
+ double knockbackToApply = 0.0;
|
||||
+ if (sinceLastKnockback >= this.level().sakuraConfig().players.knockback.sprinting.knockbackDelay.value().orElse(0)) {
|
||||
+ knockbackToApply = this.level().sakuraConfig().players.knockback.sprinting.extraKnockback;
|
||||
+ this.lastSprintKnockback = millis;
|
||||
+ }
|
||||
+ f4 = (f4 - 1.0f) + ((float) knockbackToApply * 2.0f);
|
||||
+ }
|
||||
+ if (f4 == 0.0f) {
|
||||
+ // required
|
||||
+ } else if (target instanceof LivingEntity livingEntity1) {
|
||||
+ // Sakura end - configure entity knockback; extra sprinting knockback
|
||||
livingEntity1.knockback(
|
||||
f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))
|
||||
, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events
|
||||
@@ -1314,7 +_,7 @@
|
||||
// Paper end - Configurable sprint interruption on attack
|
||||
}
|
||||
|
||||
- if (flag3) {
|
||||
+ if (flag3 && this.level().sakuraConfig().players.combat.allowSweepAttacks) { // Sakura - allow disabling sweep attacks
|
||||
float f5 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f;
|
||||
|
||||
for (LivingEntity livingEntity2 : this.level()
|
||||
@@ -1331,7 +_,7 @@
|
||||
}
|
||||
// CraftBukkit end
|
||||
livingEntity2.knockback(
|
||||
- 0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))
|
||||
+ (float) this.level().sakuraConfig().players.knockback.sweepingEdgeKnockback, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) // Sakura - configure entity knockback
|
||||
, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // CraftBukkit // Paper - knockback events
|
||||
);
|
||||
// CraftBukkit - moved up
|
||||
@@ -1421,7 +_,7 @@
|
||||
if (target instanceof LivingEntity) {
|
||||
float f7 = f3 - ((LivingEntity)target).getHealth();
|
||||
this.awardStat(Stats.DAMAGE_DEALT, Math.round(f7 * 10.0F));
|
||||
- if (this.level() instanceof ServerLevel && f7 > 2.0F) {
|
||||
+ if (this.level() instanceof ServerLevel && f7 > 2.0F && !this.level().sakuraConfig().players.combat.oldSoundsAndParticleEffects) { // Sakura - old combat sounds and particles
|
||||
int i = (int)(f7 * 0.5);
|
||||
((ServerLevel)this.level())
|
||||
.sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5), target.getZ(), i, 0.1, 0.0, 0.1, 0.2);
|
||||
@@ -1824,6 +_,7 @@
|
||||
|
||||
// Paper start - send while respecting visibility
|
||||
private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) {
|
||||
+ if (fromEntity.level().sakuraConfig().players.combat.oldSoundsAndParticleEffects) return; // Sakura - old combat sounds and particles
|
||||
fromEntity.level().playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity itself
|
||||
if (fromEntity instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundSoundPacket(net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(soundEffect), soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong()));
|
||||
@@ -2210,7 +_,13 @@
|
||||
|
||||
@Override
|
||||
public EntityDimensions getDefaultDimensions(Pose pose) {
|
||||
- return POSES.getOrDefault(pose, STANDING_DIMENSIONS);
|
||||
+ // Sakura start - player poses shrink collision box
|
||||
+ final EntityDimensions dimensions = POSES.getOrDefault(pose, STANDING_DIMENSIONS);
|
||||
+ if (!this.level().sakuraConfig().players.posesShrinkCollisionBox && dimensions.height() == STANDING_DIMENSIONS.height()) {
|
||||
+ return STANDING_DIMENSIONS;
|
||||
+ }
|
||||
+ return dimensions;
|
||||
+ // Sakura end - player poses shrink collision box
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,24 @@
|
||||
--- a/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
+++ b/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
@@ -288,6 +_,12 @@
|
||||
if (!this.level().isClientSide) {
|
||||
this.setHookedEntity(result.getEntity());
|
||||
}
|
||||
+ // Sakura start - configure entity knockback
|
||||
+ if (this.level().sakuraConfig().players.knockback.fishingHooksApplyKnockback) {
|
||||
+ final Entity entity = result.getEntity();
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0f);
|
||||
+ }
|
||||
+ // Sakura end - configure entity knockback
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -603,7 +_,7 @@
|
||||
|
||||
public void pullEntity(Entity entity) {
|
||||
Entity owner = this.getOwner();
|
||||
- if (owner != null) {
|
||||
+ if (owner != null && (this.level().sakuraConfig().players.fishingHooksPullEntities || entity instanceof ItemEntity)) { // Sakura - configure fishing hooks pulling entities
|
||||
Vec3 vec3 = new Vec3(owner.getX() - this.getX(), owner.getY() - this.getY(), owner.getZ() - this.getZ()).scale(0.1);
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/projectile/ProjectileUtil.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ProjectileUtil.java
|
||||
@@ -51,9 +_,15 @@
|
||||
vec3 = hitResult.getLocation();
|
||||
}
|
||||
|
||||
- HitResult entityHitResult = getEntityHitResult(
|
||||
- level, projectile, pos, vec3, projectile.getBoundingBox().expandTowards(deltaMovement).inflate(1.0), filter, margin
|
||||
- );
|
||||
+ // Sakura start - configure potion mechanics
|
||||
+ final AABB movementAABB = projectile.getBoundingBox().expandTowards(deltaMovement).inflate(1.0);
|
||||
+ final HitResult entityHitResult;
|
||||
+ if (level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && projectile instanceof ThrownPotion) {
|
||||
+ entityHitResult = getEntityHitResult(projectile, pos, vec3, movementAABB, filter, margin);
|
||||
+ } else {
|
||||
+ entityHitResult = getEntityHitResult(level, projectile, pos, vec3, movementAABB, filter, margin);
|
||||
+ }
|
||||
+ // Sakura end - configure potion mechanics
|
||||
if (entityHitResult != null) {
|
||||
hitResult = entityHitResult;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java
|
||||
@@ -41,12 +_,18 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Sakura start - enderpearls use outline for collision
|
||||
+ protected net.minecraft.world.level.ClipContext.Block getClipType() {
|
||||
+ return net.minecraft.world.level.ClipContext.Block.COLLIDER;
|
||||
+ }
|
||||
+ // Sakura end - enderpearls use outline for collision
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
this.handleFirstTickBubbleColumn();
|
||||
this.applyGravity();
|
||||
this.applyInertia();
|
||||
- HitResult hitResultOnMoveVector = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
|
||||
+ HitResult hitResultOnMoveVector = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType()); // Sakura - enderpearls use outline for collision
|
||||
Vec3 location;
|
||||
if (hitResultOnMoveVector.getType() != HitResult.Type.MISS) {
|
||||
location = hitResultOnMoveVector.getLocation();
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
|
||||
@@ -186,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // Sakura start - enderpearls use outline for collision
|
||||
+ @Override
|
||||
+ protected net.minecraft.world.level.ClipContext.Block getClipType() {
|
||||
+ return this.level().sakuraConfig().entity.enderPearl.useOutlineForCollision ? net.minecraft.world.level.ClipContext.Block.OUTLINE : super.getClipType();
|
||||
+ }
|
||||
+ // Sakura end - enderpearls use outline for collision
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
int sectionPosX = SectionPos.blockToSectionCoord(this.position().x());
|
||||
@@ -0,0 +1,28 @@
|
||||
--- a/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
@@ -49,6 +_,25 @@
|
||||
public ThrownPotion(Level level, double x, double y, double z, ItemStack item) {
|
||||
super(EntityType.POTION, x, y, z, level, item);
|
||||
}
|
||||
+
|
||||
+ // Sakura start - configure potion mechanics
|
||||
+ @Override
|
||||
+ public void shoot(double x, double y, double z, float speed, float divergence) {
|
||||
+ super.shoot(x, y, z, speed, divergence);
|
||||
+
|
||||
+ net.minecraft.world.phys.Vec3 movement = this.getDeltaMovement();
|
||||
+ double moveX = movement.x * this.level().sakuraConfig().entity.thrownPotion.horizontalSpeed;
|
||||
+ double moveY = movement.y * this.level().sakuraConfig().entity.thrownPotion.verticalSpeed;
|
||||
+ double moveZ = movement.z * this.level().sakuraConfig().entity.thrownPotion.horizontalSpeed;
|
||||
+
|
||||
+ this.setDeltaMovement(moveX, moveY, moveZ);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected boolean checkLeftOwner() {
|
||||
+ return super.checkLeftOwner() || this.level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5;
|
||||
+ }
|
||||
+ // Sakura end - configure potion mechanics
|
||||
|
||||
@Override
|
||||
protected Item getDefaultItem() {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user