Port even more patches

Ported some patches from EMC and Origami
This commit is contained in:
Ivan Pekov 2020-08-15 19:18:36 +03:00 committed by GitHub
parent f380815804
commit c75ada51ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 620 additions and 550 deletions

View File

@ -21,8 +21,10 @@ # Patches
| server | Add more dupe options | Mariell Hoversholm | |
| server | Add no-tick block list | William Blake Galbreath | |
| server | Add option to disable dolphin treasure searching | William Blake Galbreath | |
| server | Add option to disable observer clocks | Phoenix616 | |
| server | Add option to disable saving projectiles to disk | William Blake Galbreath | |
| server | Add permission for F3+N debug | William Blake Galbreath | |
| server | Add timings for Behavior | Phoenix616 | |
| server | Akarin Updated Save json list async | tsao chi | |
| server | Allow anvil colors | William Blake Galbreath | |
| api | Allow inventory resizing | William Blake Galbreath | |
@ -48,6 +50,8 @@ # Patches
| server | Dont send useless entity packets | William Blake Galbreath | |
| server | Entity lifespan | William Blake Galbreath | |
| server | Fix 'outdated server' showing in ping before server fully | William Blake Galbreath | |
| server | Fix Bukkit.createInventory() with type LECTERN | willies952002 | |
| server | Fix exp drop of zombie pigmen (MC-56653) | Phoenix616 | |
| server | Fix lead fall dmg config | tr7zw | |
| server | Fix the dead lagging the server | William Blake Galbreath | |
| server | Giants AI settings | William Blake Galbreath | |
@ -89,6 +93,7 @@ # Patches
| server | Remove stream for ender teleport | Sotr | |
| server | Remove vanilla profiler callers | Sotr | |
| server | Skip events if there's no listeners | William Blake Galbreath | |
| server | Slow down villager pickup of thrown items | Aikar | |
| server | Snowman drop and put back pumpkin | William Blake Galbreath | |
| server | Squid EAR immunity | William Blake Galbreath | |
| server | Swaps the predicate order of collision | ㄗㄠˋ ㄑㄧˊ | |

View File

@ -1 +1 @@
Improve-Hopper-Performance&Don-t-trigger-Lootable-Refresh-for-non-player-intera&Tweak-Explosions&dont-load-chunks-for-physics
Improve-Hopper-Performance&Don-t-trigger-Lootable-Refresh-for-non-player-intera&Tweak-Explosions&dont-load-chunks-for-physics&Fix-Bukkit.createInventory-with-type-LECTERN&Slow-down-villager-pickup-of-thrown-items

View File

@ -1 +1 @@
Origami-Server-Config&Optimize-inventory-API-item-handling&Don-t-load-chunk-with-seed-based-feature-search&Hopper-Optimizations&Don-t-wake-up-entities-when-damage-event-is-cancelle
Origami-Server-Config&Optimize-inventory-API-item-handling&Don-t-load-chunk-with-seed-based-feature-search&Hopper-Optimizations&Don-t-wake-up-entities-when-damage-event-is-cancelle&Add-option-to-disable-observer-clocks&Add-timings-for-Behavior&Fix-exp-drop-of-zombie-pigmen-MC-56653

View File

@ -137,7 +137,7 @@ index e0af5eb280dfd2ef6c9a80385e1705f7231a5338..f6623032e5d4034c104aa1fc6ff42651
brandName = getString("brand-name", brandName);
}
diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java
index fe7330fabe386966c2d203a190a00a785ea21be0..be8daf986eb9c83bd5974eca78a00f717e4f5061 100644
index fe7330fabe386966c2d203a190a00a785ea21be0..4ff73f74a0d4e0b95e67b99b551dadd3ab4d0f55 100644
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
@@ -16,7 +16,7 @@ public final class OrigamiConfig {
@ -149,12 +149,11 @@ index fe7330fabe386966c2d203a190a00a785ea21be0..be8daf986eb9c83bd5974eca78a00f71
private static int configVersion;
public static void init(final File file) {
@@ -112,6 +112,20 @@ public final class OrigamiConfig {
@@ -112,6 +112,28 @@ public final class OrigamiConfig {
config.addDefault("worlds.default." + path, Double.valueOf(dfl));
return config.getDouble("worlds." + worldName + "." + path, config.getDouble("worlds.default." + path, dfl));
}
+
+ // Yatopia start
+ public boolean tickEmptyHoppers = true;
+ public int fullHopperCooldown = 128;
+ private void hopperOptimizations() {
@ -166,31 +165,85 @@ index fe7330fabe386966c2d203a190a00a785ea21be0..be8daf986eb9c83bd5974eca78a00f71
+ private void fastFeatureSearchDontLoad() {
+ fastFeatureSearchDontLoad = getBoolean("fast-feature-search-dont-load", false);
+ }
+ // Yatopia end
+
+ public boolean pigmenDontTargetUnlessHit = false;
+ private void pigmenDontTargetUnlessHit() {
+ pigmenDontTargetUnlessHit = getBoolean("pigmen.dont-target-unless-hit", pigmenDontTargetUnlessHit);
+ }
+
+ public boolean disableObserverClocks = false;
+ private void observerClock() {
+ disableObserverClocks = getBoolean("disable-observer-clocks", disableObserverClocks);
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java.rej b/src/main/java/de/minebench/origami/OrigamiConfig.java.rej
deleted file mode 100644
index 8428d4bd05075e86b281312fa38106882c54735b..0000000000000000000000000000000000000000
index 02f5ccf54210776770d3215afb7c8e82f750d57e..0000000000000000000000000000000000000000
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java.rej
+++ /dev/null
@@ -1,14 +0,0 @@
@@ -1,12 +0,0 @@
-diff a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java (rejected hunks)
-@@ -169,6 +169,12 @@ public final class OrigamiConfig {
- Bukkit.getLogger().info("Farm detection radius: " + pigmenFarmsRadius + ", count: " + pigmenFarmsCount);
- }
-@@ -153,6 +153,10 @@ public final class OrigamiConfig {
- public int getTickRate(String type, String typeName, String entityType, int def) {
- return tickRates.getOrDefault(type + "." + entityType + "." + typeName, tickRates.getOrDefault(type + "." + typeName, def));
- }
-+ public boolean tickEmptyHoppers = false;
-+ public int fullHopperCooldown = 128;
-+ private void hopperOptimizations() {
-+ tickEmptyHoppers = getBoolean("tick-empty-hoppers", tickEmptyHoppers);
-+ fullHopperCooldown = getInt("ticks-per.full-hopper-cooldown", fullHopperCooldown);
-+ public boolean pigmenDontTargetUnlessHit = false;
-+ private void pigmenDontTargetUnlessHit() {
-+ pigmenDontTargetUnlessHit = getBoolean("pigmen.dont-target-unless-hit", pigmenDontTargetUnlessHit);
-+ }
- public int pigmenPortalSpawn = 2000;
- public double pigmenPortalBoost = 0.0;
- public boolean pigmenFarmsWaterAi = false;
diff --git a/src/main/java/net/minecraft/server/Behavior.java b/src/main/java/net/minecraft/server/Behavior.java
index 0490f6bb798b94ce69a40f8a940caaa545c4a3c0..65cbe8ea9551ee804ca35a594680e845eebbacac 100644
--- a/src/main/java/net/minecraft/server/Behavior.java
+++ b/src/main/java/net/minecraft/server/Behavior.java
@@ -11,6 +11,7 @@ public abstract class Behavior<E extends EntityLiving> {
private long c;
private final int d;
private final int e;
+ co.aikar.timings.Timing timing; // Origami - behavior timing
public Behavior(Map<MemoryModuleType<?>, MemoryStatus> map) {
this(map, 60);
@@ -25,6 +26,9 @@ public abstract class Behavior<E extends EntityLiving> {
this.d = i;
this.e = j;
this.a = map;
+ // Origami start - behavior timing
+ timing = co.aikar.timings.WorldTimingsHandler.getBehaviorTimings(getClass().getSimpleName());
+ // Origami end
}
public Behavior.Status a() {
diff --git a/src/main/java/net/minecraft/server/Behavior.java.rej b/src/main/java/net/minecraft/server/Behavior.java.rej
deleted file mode 100644
index c3d129452b4f6ff2069bc066e594b1c632ceb0d4..0000000000000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/Behavior.java.rej
+++ /dev/null
@@ -1,19 +0,0 @@
-diff a/src/main/java/net/minecraft/server/Behavior.java b/src/main/java/net/minecraft/server/Behavior.java (rejected hunks)
-@@ -15,6 +15,7 @@ public abstract class Behavior<E extends EntityLiving> {
- private final String configKey;
- private static final String RATE_TYPE = "behavior";
- // Origami end
-+ co.aikar.timings.Timing timing; // Origami - behavior timing
-
- public Behavior(Map<MemoryModuleType<?>, MemoryStatus> map) {
- this(map, 60);
-@@ -37,6 +38,9 @@ public abstract class Behavior<E extends EntityLiving> {
- }
- this.configKey = key;
- // Origami end
-+ // Origami start - behavior timing
-+ timing = co.aikar.timings.WorldTimingsHandler.getBehaviorTimings(key);
-+ // Origami end
- }
-
- public static boolean teleportingOfVehiclesWithPassenger = true;
- public Behavior.Status a() {
diff --git a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java
index 685351f11497a33ef4ba99055fa7da3a8de18af2..dba7cbb02b16dfc6b45efea7c3dd3304693d0ac7 100644
--- a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java
@ -1073,7 +1126,7 @@ index a8d2be07d45549cf7a8ac048b44284c4c0a96686..00000000000000000000000000000000
-
- }
diff --git a/src/main/java/net/minecraft/server/EntityFox.java b/src/main/java/net/minecraft/server/EntityFox.java
index b04f061859f2db52cdefb0192883f2a7c5117fea..080635ce047d25bd76baf371298d4f45375aa681 100644
index b04f061859f2db52cdefb0192883f2a7c5117fea..7ce648e38b18c4decdba6d9dff81f833dcfb6454 100644
--- a/src/main/java/net/minecraft/server/EntityFox.java
+++ b/src/main/java/net/minecraft/server/EntityFox.java
@@ -31,9 +31,9 @@ public class EntityFox extends EntityAnimal {
@ -1109,11 +1162,10 @@ index b04f061859f2db52cdefb0192883f2a7c5117fea..080635ce047d25bd76baf371298d4f45
}
private List<UUID> fa() {
@@ -262,6 +268,29 @@ public class EntityFox extends EntityAnimal {
list.add((this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error
@@ -263,6 +269,29 @@ public class EntityFox extends EntityAnimal {
return list;
}
+
+ // Purpur start
+ @Override
+ public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
@ -1136,9 +1188,10 @@ index b04f061859f2db52cdefb0192883f2a7c5117fea..080635ce047d25bd76baf371298d4f45
+ return super.b(entityhuman, enumhand);
+ }
+ // Purpur end
+
private void b(@Nullable UUID uuid) {
if (((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).isPresent()) {
this.datawatcher.set(EntityFox.SECOND_TRUSTED_PLAYER, Optional.ofNullable(uuid));
diff --git a/src/main/java/net/minecraft/server/EntityFox.java.rej b/src/main/java/net/minecraft/server/EntityFox.java.rej
deleted file mode 100644
index 641f24b3e166d895d795c73d46cdc26a7d87f0df..0000000000000000000000000000000000000000
@ -1766,9 +1819,18 @@ index bf6c6ecea998206d783fe42b96f34144123d48d6..00000000000000000000000000000000
- public EntityPhantom(EntityTypes<? extends EntityPhantom> entitytypes, World world) {
- super(entitytypes, world);
diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java
index 13a2af03fc5a511f13a9be28a813e7275448d09d..aa9687f47bf30ef13f9ab90eb3d11212b5996a90 100644
index 13a2af03fc5a511f13a9be28a813e7275448d09d..258d19f8aa5c092a940c0e722e114c1c5be578b8 100644
--- a/src/main/java/net/minecraft/server/EntityPigZombie.java
+++ b/src/main/java/net/minecraft/server/EntityPigZombie.java
@@ -70,7 +70,7 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable {
this.eY();
}
- if (this.isAngry()) {
+ if (this.isAngry() && !this.world.origamiConfig.pigmenDontTargetUnlessHit) { // Origami - fix MC-56653
this.lastDamageByPlayerTime = this.ticksLived;
}
@@ -103,15 +103,15 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable {
double d0 = this.b(GenericAttributes.FOLLOW_RANGE);
AxisAlignedBB axisalignedbb = AxisAlignedBB.a(this.getPositionVector()).grow(d0, 10.0D, d0);
@ -1796,37 +1858,20 @@ index 13a2af03fc5a511f13a9be28a813e7275448d09d..aa9687f47bf30ef13f9ab90eb3d11212
private void fa() {
diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java.rej b/src/main/java/net/minecraft/server/EntityPigZombie.java.rej
deleted file mode 100644
index 39ea87798a00d40a1512c337b74d10c41330cc99..0000000000000000000000000000000000000000
index 7c6c99ccd4d034994668f62d82fa8180ab0bba57..0000000000000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/EntityPigZombie.java.rej
+++ /dev/null
@@ -1,27 +0,0 @@
@@ -1,10 +0,0 @@
-diff a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java (rejected hunks)
-@@ -101,15 +103,16 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable {
- double d0 = this.b(GenericAttributes.FOLLOW_RANGE);
- AxisAlignedBB axisalignedbb = AxisAlignedBB.a(this.getPositionVector()).grow(d0, 10.0D, d0);
-@@ -68,7 +68,7 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable {
- this.eZ();
- }
-
-- this.world.b(EntityPigZombie.class, axisalignedbb).stream().filter((entitypigzombie) -> {
-- return entitypigzombie != this;
-- }).filter((entitypigzombie) -> {
-- return entitypigzombie.getGoalTarget() == null;
-- }).filter((entitypigzombie) -> {
-- return !entitypigzombie.r(this.getGoalTarget());
-- }).forEach((entitypigzombie) -> {
-- entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit
-- });
-+ // CraftBukkit
-+ for (EntityPigZombie entitypigzombie : this.world.b(EntityPigZombie.class, axisalignedbb)) {
-+ if (entitypigzombie != this) {
-+ if (entitypigzombie.getGoalTarget() == null) {
-+ if (!entitypigzombie.r(this.getGoalTarget())) {
-+ entitypigzombie.setGoalTarget(this.getGoalTarget(), EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true);
-+ }
-+ }
-+ }
-+ }
- }
-- if (this.isAngry()) {
-+ if (this.isAngry() && !this.world.origamiConfig.pigmenDontTargetUnlessHit) { // Origami - fix MC-56653
- this.lastDamageByPlayerTime = this.ticksLived;
- }
-
- private void fb() {
diff --git a/src/main/java/net/minecraft/server/EntityPiglin.java b/src/main/java/net/minecraft/server/EntityPiglin.java
index e1b4330074cf3c3de31dbfcd9e1b99feb7baf669..2581c6da77c3fcec5a18f5fcacf30a36bf6b5ee6 100644
--- a/src/main/java/net/minecraft/server/EntityPiglin.java

View File

@ -18,357 +18,357 @@ index b67f05f290db653cf75a89e85bd3decb5044a1e0..11758b6b158d971b9beb1b609d7513da
new TimingsExport(listeners, parent, history).start();
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaCommand.java b/src/main/java/dev/tr7zw/yatopia/YatopiaCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..27c6daf22b5ddc8e9de6ef084f396347a5b44feb
index 0000000000000000000000000000000000000000..aa78ff26f578c6ea71a8e3d86fc64e2a82bb7e57
--- /dev/null
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaCommand.java
@@ -0,0 +1,126 @@
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.function.Function;
+import net.minecraft.server.MinecraftKey;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.spigotmc.TicksPerSecondCommand;
+
+public class YatopiaCommand extends Command {
+
+ public YatopiaCommand(String name) {
+ super(name);
+ this.description = "Yatopia related commands";
+ this.usageMessage = "/yatopia [help | reload | info | version]";
+ this.setPermission("bukkit.command.yatopia");
+ }
+
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+ if (args.length <= 1) {
+ return getListMatchingLast(args, "help", "info", "reload", "version");
+ }
+ return Collections.emptyList();
+ }
+
+ // Code from Mojang - copyright them
+ public static List<String> getListMatchingLast(String[] args, String... matches) {
+ return getListMatchingLast(args, Arrays.asList(matches));
+ }
+
+ public static boolean matches(String s, String s1) {
+ return s1.regionMatches(true, 0, s, 0, s.length());
+ }
+
+ public static List<String> getListMatchingLast(String[] strings, Collection<?> collection) {
+ String last = strings[strings.length - 1];
+ List<String> results = Lists.newArrayList();
+
+ if (!collection.isEmpty()) {
+ Function<Object, String> toStringFunction = (o) -> {
+ Preconditions.checkNotNull(o);
+ return o.toString();
+ };
+ for (Object c : collection) {
+ String value = toStringFunction.apply(c);
+ if (matches(last, value)) {
+ results.add(value);
+ }
+ }
+
+ if (results.isEmpty()) {
+ for (Object c : collection) {
+ if (c instanceof MinecraftKey) {
+ MinecraftKey key = (MinecraftKey) c;
+ if (matches(last, key.getKey())) {
+ results.add(key.toString());
+ }
+ }
+ }
+ }
+ }
+
+ return results;
+ }
+ // end copy stuff
+
+ @Override
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
+ if (!testPermission(sender)) return true;
+
+ if (args.length == 0) {
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ switch (args[0].toLowerCase(Locale.ENGLISH)) {
+ case "info":
+ doInfo(sender);
+ break;
+ case "reload":
+ doReload(sender);
+ break;
+ case "ver":
+ case "version":
+ Command ver = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version");
+ if (ver != null) {
+ ver.execute(sender, commandLabel, new String[0]);
+ break;
+ }
+ // else - fall through to default
+ default:
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ return true;
+ }
+
+ private void doInfo(CommandSender sender) {
+ Command.broadcastCommandMessage(sender, ChatColor.GOLD + "Last tick took " + TicksPerSecondCommand.format(Bukkit.getLastTickMs()));
+ //TODO
+ }
+
+ private void doReload(CommandSender sender) {
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
+
+ MinecraftServer console = MinecraftServer.getServer();
+ dev.tr7zw.yatopia.YatopiaConfig.init((File) console.options.valueOf("yatopia-settings"));
+ console.server.reloadCount++;
+
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Yatopia config reload complete.");
+ }
+}
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.function.Function;
+import net.minecraft.server.MinecraftKey;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.spigotmc.TicksPerSecondCommand;
+
+public class YatopiaCommand extends Command {
+
+ public YatopiaCommand(String name) {
+ super(name);
+ this.description = "Yatopia related commands";
+ this.usageMessage = "/yatopia [help | reload | info | version]";
+ this.setPermission("bukkit.command.yatopia");
+ }
+
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+ if (args.length <= 1) {
+ return getListMatchingLast(args, "help", "info", "reload", "version");
+ }
+ return Collections.emptyList();
+ }
+
+ // Code from Mojang - copyright them
+ public static List<String> getListMatchingLast(String[] args, String... matches) {
+ return getListMatchingLast(args, Arrays.asList(matches));
+ }
+
+ public static boolean matches(String s, String s1) {
+ return s1.regionMatches(true, 0, s, 0, s.length());
+ }
+
+ public static List<String> getListMatchingLast(String[] strings, Collection<?> collection) {
+ String last = strings[strings.length - 1];
+ List<String> results = Lists.newArrayList();
+
+ if (!collection.isEmpty()) {
+ Function<Object, String> toStringFunction = (o) -> {
+ Preconditions.checkNotNull(o);
+ return o.toString();
+ };
+ for (Object c : collection) {
+ String value = toStringFunction.apply(c);
+ if (matches(last, value)) {
+ results.add(value);
+ }
+ }
+
+ if (results.isEmpty()) {
+ for (Object c : collection) {
+ if (c instanceof MinecraftKey) {
+ MinecraftKey key = (MinecraftKey) c;
+ if (matches(last, key.getKey())) {
+ results.add(key.toString());
+ }
+ }
+ }
+ }
+ }
+
+ return results;
+ }
+ // end copy stuff
+
+ @Override
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
+ if (!testPermission(sender)) return true;
+
+ if (args.length == 0) {
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ switch (args[0].toLowerCase(Locale.ENGLISH)) {
+ case "info":
+ doInfo(sender);
+ break;
+ case "reload":
+ doReload(sender);
+ break;
+ case "ver":
+ case "version":
+ Command ver = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version");
+ if (ver != null) {
+ ver.execute(sender, commandLabel, new String[0]);
+ break;
+ }
+ // else - fall through to default
+ default:
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ return true;
+ }
+
+ private void doInfo(CommandSender sender) {
+ Command.broadcastCommandMessage(sender, ChatColor.GOLD + "Last tick took " + TicksPerSecondCommand.format(Bukkit.getLastTickMs()));
+ //TODO
+ }
+
+ private void doReload(CommandSender sender) {
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
+
+ MinecraftServer console = MinecraftServer.getServer();
+ dev.tr7zw.yatopia.YatopiaConfig.init((File) console.options.valueOf("yatopia-settings"));
+ console.server.reloadCount++;
+
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Yatopia config reload complete.");
+ }
+}
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6e34ea413e29792043955a655d4261553825157
index 0000000000000000000000000000000000000000..6a62f2314c8f62cef83ed4b68cb45368bad62628
--- /dev/null
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -0,0 +1,215 @@
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Throwables;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.configuration.InvalidConfigurationException;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class YatopiaConfig {
+
+ public static File CONFIG_FILE;
+ private static final String HEADER = "This is the main configuration file for Yatopia.\n"
+ + "Yatopia contains many breaking changes and settings, so know what you are doing!\n"
+ + "You have been warned!\n";
+ /*========================================================================*/
+ public static YamlConfiguration config;
+ public static int version; // since we're remapping sidestreams' configs we need this public
+ static Map<String, Command> commands;
+ public static boolean verbose; // since we're remapping sidestreams' configs we need this public
+ private static boolean fatalError;
+ /*========================================================================*/
+ private static boolean metricsStarted;
+
+ public static void init(File configFile) {
+ CONFIG_FILE = configFile;
+ config = new YamlConfiguration();
+ try {
+ config.load(CONFIG_FILE);
+ } catch (IOException ex) {
+ } catch (InvalidConfigurationException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load yatopia.yml, please correct your syntax errors", ex);
+ throw Throwables.propagate(ex);
+ }
+ config.options().header(HEADER);
+ config.options().copyDefaults(true);
+ verbose = getBoolean("verbose", false);
+
+ commands = new HashMap<String, Command>();
+ commands.put("yatopia", new YatopiaCommand("yatopia"));
+
+ version = getInt("config-version", 1);
+ set("config-version", 1);
+ removeLeftovers();
+ readConfig(YatopiaConfig.class, null);
+ }
+
+ private static void removeLeftovers() {
+ // this method is only to remove non-used values in the config
+
+ // leftover from akarin / rainforest
+ if (config.get("world-settings") != null) {
+ set("world-settings", null);
+ }
+ // unused settings getting removed
+ if (config.get("settings.disablePlayerOutOfWorldBorderCheck") != null) {
+ set("settings.disablePlayerOutOfWorldBorderCheck", null);
+ }
+ if (config.get("settings.disableEntityCollisions") != null) {
+ set("settings.disableEntityCollisions", null);
+ }
+ if (config.get("settings.onlyPlayerCollisions") != null) {
+ set("settings.onlyPlayerCollisions", null);
+ }
+ }
+
+ protected static void logError(String s) {
+ Bukkit.getLogger().severe(s);
+ }
+
+ protected static void fatal(String s) {
+ fatalError = true;
+ throw new RuntimeException("Fatal yatopia.yml config error: " + s);
+ }
+
+ protected static void log(String s) {
+ if (verbose) {
+ Bukkit.getLogger().info(s);
+ }
+ }
+
+ public static void registerCommands() {
+ for (Map.Entry<String, Command> entry : commands.entrySet()) {
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Yatopia", entry.getValue());
+ }
+ }
+
+ static void readConfig(Class<?> clazz, Object instance) {
+ for (Method method : clazz.getDeclaredMethods()) {
+ if (Modifier.isPrivate(method.getModifiers())) {
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
+ try {
+ method.setAccessible(true);
+ method.invoke(instance);
+ } catch (InvocationTargetException ex) {
+ throw Throwables.propagate(ex.getCause());
+ } catch (Exception ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
+ }
+ }
+ }
+ }
+
+ try {
+ config.save(CONFIG_FILE);
+ } catch (IOException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
+ }
+ }
+
+ private static final Pattern SPACE = Pattern.compile(" ");
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
+
+ public static int getSeconds(String str) {
+ str = SPACE.matcher(str).replaceAll("");
+ final char unit = str.charAt(str.length() - 1);
+ str = NOT_NUMERIC.matcher(str).replaceAll("");
+ double num;
+ try {
+ num = Double.parseDouble(str);
+ } catch (Exception e) {
+ num = 0D;
+ }
+ switch (unit) {
+ case 'd':
+ num *= (double) 60 * 60 * 24;
+ break;
+ case 'h':
+ num *= (double) 60 * 60;
+ break;
+ case 'm':
+ num *= 60;
+ break;
+ default:
+ case 's':
+ break;
+ }
+ return (int) num;
+ }
+
+ protected static String timeSummary(int seconds) {
+ String time = "";
+
+ if (seconds > 60 * 60 * 24) {
+ time += TimeUnit.SECONDS.toDays(seconds) + "d";
+ seconds %= 60 * 60 * 24;
+ }
+
+ if (seconds > 60 * 60) {
+ time += TimeUnit.SECONDS.toHours(seconds) + "h";
+ seconds %= 60 * 60;
+ }
+
+ if (seconds > 0) {
+ time += TimeUnit.SECONDS.toMinutes(seconds) + "m";
+ }
+ return time;
+ }
+
+ private static void set(String path, Object val) {
+ config.set(path, val);
+ }
+
+ private static boolean getBoolean(String path, boolean def) {
+ config.addDefault(path, def);
+ return config.getBoolean(path, config.getBoolean(path));
+ }
+
+ private static double getDouble(String path, double def) {
+ config.addDefault(path, def);
+ return config.getDouble(path, config.getDouble(path));
+ }
+
+ private static float getFloat(String path, float def) {
+ // TODO: Figure out why getFloat() always returns the default value.
+ return (float) getDouble(path, (double) def);
+ }
+
+ private static int getInt(String path, int def) {
+ config.addDefault(path, def);
+ return config.getInt(path, config.getInt(path));
+ }
+
+ private static <T> List<T> getList(String path, List<T> def) {
+ config.addDefault(path, def);
+ return (List<T>) config.getList(path, config.getList(path));
+ }
+
+ private static String getString(String path, String def) {
+ config.addDefault(path, def);
+ return config.getString(path, config.getString(path));
+ }
+
+ public static boolean disableEntityStuckChecks = false;
+ private static void disableEntityStuckChecks() {
+ disableEntityStuckChecks = getBoolean("settings.disableEntityStuckChecks", false);
+ }
+
+ public static boolean disableEntityCollisionboxes = false;
+ private static void disableEntityCollisionboxes() {
+ disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
+ }
+
+}
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Throwables;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.configuration.InvalidConfigurationException;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class YatopiaConfig {
+
+ public static File CONFIG_FILE;
+ private static final String HEADER = "This is the main configuration file for Yatopia.\n"
+ + "Yatopia contains many breaking changes and settings, so know what you are doing!\n"
+ + "You have been warned!\n";
+ /*========================================================================*/
+ public static YamlConfiguration config;
+ public static int version; // since we're remapping sidestreams' configs we need this public
+ static Map<String, Command> commands;
+ public static boolean verbose; // since we're remapping sidestreams' configs we need this public
+ private static boolean fatalError;
+ /*========================================================================*/
+ private static boolean metricsStarted;
+
+ public static void init(File configFile) {
+ CONFIG_FILE = configFile;
+ config = new YamlConfiguration();
+ try {
+ config.load(CONFIG_FILE);
+ } catch (IOException ex) {
+ } catch (InvalidConfigurationException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load yatopia.yml, please correct your syntax errors", ex);
+ throw Throwables.propagate(ex);
+ }
+ config.options().header(HEADER);
+ config.options().copyDefaults(true);
+ verbose = getBoolean("verbose", false);
+
+ commands = new HashMap<String, Command>();
+ commands.put("yatopia", new YatopiaCommand("yatopia"));
+
+ version = getInt("config-version", 1);
+ set("config-version", 1);
+ removeLeftovers();
+ readConfig(YatopiaConfig.class, null);
+ }
+
+ private static void removeLeftovers() {
+ // this method is only to remove non-used values in the config
+
+ // leftover from akarin / rainforest
+ if (config.get("world-settings") != null) {
+ set("world-settings", null);
+ }
+ // unused settings getting removed
+ if (config.get("settings.disablePlayerOutOfWorldBorderCheck") != null) {
+ set("settings.disablePlayerOutOfWorldBorderCheck", null);
+ }
+ if (config.get("settings.disableEntityCollisions") != null) {
+ set("settings.disableEntityCollisions", null);
+ }
+ if (config.get("settings.onlyPlayerCollisions") != null) {
+ set("settings.onlyPlayerCollisions", null);
+ }
+ }
+
+ protected static void logError(String s) {
+ Bukkit.getLogger().severe(s);
+ }
+
+ protected static void fatal(String s) {
+ fatalError = true;
+ throw new RuntimeException("Fatal yatopia.yml config error: " + s);
+ }
+
+ protected static void log(String s) {
+ if (verbose) {
+ Bukkit.getLogger().info(s);
+ }
+ }
+
+ public static void registerCommands() {
+ for (Map.Entry<String, Command> entry : commands.entrySet()) {
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Yatopia", entry.getValue());
+ }
+ }
+
+ static void readConfig(Class<?> clazz, Object instance) {
+ for (Method method : clazz.getDeclaredMethods()) {
+ if (Modifier.isPrivate(method.getModifiers())) {
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
+ try {
+ method.setAccessible(true);
+ method.invoke(instance);
+ } catch (InvocationTargetException ex) {
+ throw Throwables.propagate(ex.getCause());
+ } catch (Exception ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
+ }
+ }
+ }
+ }
+
+ try {
+ config.save(CONFIG_FILE);
+ } catch (IOException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
+ }
+ }
+
+ private static final Pattern SPACE = Pattern.compile(" ");
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
+
+ public static int getSeconds(String str) {
+ str = SPACE.matcher(str).replaceAll("");
+ final char unit = str.charAt(str.length() - 1);
+ str = NOT_NUMERIC.matcher(str).replaceAll("");
+ double num;
+ try {
+ num = Double.parseDouble(str);
+ } catch (Exception e) {
+ num = 0D;
+ }
+ switch (unit) {
+ case 'd':
+ num *= (double) 60 * 60 * 24;
+ break;
+ case 'h':
+ num *= (double) 60 * 60;
+ break;
+ case 'm':
+ num *= 60;
+ break;
+ default:
+ case 's':
+ break;
+ }
+ return (int) num;
+ }
+
+ protected static String timeSummary(int seconds) {
+ String time = "";
+
+ if (seconds > 60 * 60 * 24) {
+ time += TimeUnit.SECONDS.toDays(seconds) + "d";
+ seconds %= 60 * 60 * 24;
+ }
+
+ if (seconds > 60 * 60) {
+ time += TimeUnit.SECONDS.toHours(seconds) + "h";
+ seconds %= 60 * 60;
+ }
+
+ if (seconds > 0) {
+ time += TimeUnit.SECONDS.toMinutes(seconds) + "m";
+ }
+ return time;
+ }
+
+ private static void set(String path, Object val) {
+ config.set(path, val);
+ }
+
+ private static boolean getBoolean(String path, boolean def) {
+ config.addDefault(path, def);
+ return config.getBoolean(path, config.getBoolean(path));
+ }
+
+ private static double getDouble(String path, double def) {
+ config.addDefault(path, def);
+ return config.getDouble(path, config.getDouble(path));
+ }
+
+ private static float getFloat(String path, float def) {
+ // TODO: Figure out why getFloat() always returns the default value.
+ return (float) getDouble(path, (double) def);
+ }
+
+ private static int getInt(String path, int def) {
+ config.addDefault(path, def);
+ return config.getInt(path, config.getInt(path));
+ }
+
+ private static <T> List<T> getList(String path, List<T> def) {
+ config.addDefault(path, def);
+ return (List<T>) config.getList(path, config.getList(path));
+ }
+
+ private static String getString(String path, String def) {
+ config.addDefault(path, def);
+ return config.getString(path, config.getString(path));
+ }
+
+ public static boolean disableEntityStuckChecks = false;
+ private static void disableEntityStuckChecks() {
+ disableEntityStuckChecks = getBoolean("settings.disableEntityStuckChecks", false);
+ }
+
+ public static boolean disableEntityCollisionboxes = false;
+ private static void disableEntityCollisionboxes() {
+ disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
+ }
+
+}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index a60634fc455e8a59399020689b70eb64b6824d12..cb4a89940cf02de5c3eefc5c746397a931c96b7a 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
@ -423,7 +423,7 @@ index f24f7f1230a380f46112e886fb5dff7c33edb2ce..88f4c30a03e9139b0284ff1a545ad809
if (this.isFireProof() || this.world.isClientSide) {
this.extinguish();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e2a540d07c68e4ca9b2a2a46d6ba9a33903eced9..40e0ce2fbad4af193ede76047ad7d894369f10c9 100644
index e2a540d07c68e4ca9b2a2a46d6ba9a33903eced9..d06400a15121368d526617e1cdd1cb5138b39db7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -837,6 +837,7 @@ public final class CraftServer implements Server {
@ -434,20 +434,20 @@ index e2a540d07c68e4ca9b2a2a46d6ba9a33903eced9..40e0ce2fbad4af193ede76047ad7d894
for (WorldServer world : console.getWorlds()) {
world.worldDataServer.setDifficulty(config.difficulty);
world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals);
@@ -2265,6 +2266,13 @@ public final class CraftServer implements Server {
return de.minebench.origami.OrigamiConfig.config;
@@ -2266,6 +2267,13 @@ public final class CraftServer implements Server {
}
// Origami end
+
+ // Yatopia start
+ @Override
+ @Override
+ public YamlConfiguration getYatopiaConfig() {
+ return dev.tr7zw.yatopia.YatopiaConfig.config;
+ }
+ // Yatopia end
+
@Override
public void restart() {
org.spigotmc.RestartCommand.restart();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 63cbecc4cdd549247b58fd094c27683655667799..afbcaee4177323da039793bc27869085c632c76a 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java

View File

@ -14,14 +14,15 @@ The whole code is based around 1 class, the EntityFilter class. Whole filtering
Co-authored-by: tr7zw <tr7zw@live.de>
diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java
index be8daf986eb9c83bd5974eca78a00f717e4f5061..755e5f6ebf1559c3f4359d356b49615cbd0f19e1 100644
index 4ff73f74a0d4e0b95e67b99b551dadd3ab4d0f55..4ae94d576bf1b8e6fceb5fe1aa722ce5be2fb957 100644
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
@@ -125,6 +125,37 @@ public final class OrigamiConfig {
private void fastFeatureSearchDontLoad() {
fastFeatureSearchDontLoad = getBoolean("fast-feature-search-dont-load", false);
@@ -134,6 +134,39 @@ public final class OrigamiConfig {
private void observerClock() {
disableObserverClocks = getBoolean("disable-observer-clocks", disableObserverClocks);
}
+
+ // Yatopia start
+ public boolean playerCollisions = true;
+ public boolean animalCollisions = true;
+ public boolean ambientCollisions = true;
@ -52,142 +53,144 @@ index be8daf986eb9c83bd5974eca78a00f717e4f5061..755e5f6ebf1559c3f4359d356b49615c
+ && pillagerCollisions && ironGolemCollisions && miscCollisions && itemCollisions
+ && waterCreatureCollisions && waterAmbientCollisions;
+ }
// Yatopia end
+ // Yatopia end
}
}
\ No newline at end of file
diff --git a/src/main/java/dev/tr7zw/yatopia/EntityFilter.java b/src/main/java/dev/tr7zw/yatopia/EntityFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..e20dfbdfc07e5bc68e66940ef12d7e847ebd35d9
index 0000000000000000000000000000000000000000..1c50d30d74e06b78d96660dd2b9d7230ec609e89
--- /dev/null
+++ b/src/main/java/dev/tr7zw/yatopia/EntityFilter.java
@@ -0,0 +1,127 @@
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Predicates;
+import de.minebench.origami.OrigamiConfig;
+import java.util.function.Predicate;
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityTypes;
+import net.minecraft.server.EnumCreatureType;
+import net.minecraft.server.IEntitySelector;
+import net.minecraft.server.ScoreboardTeamBase;
+
+public class EntityFilter {
+
+ public static Predicate<Entity> getFilter(Entity entity) {
+ OrigamiConfig.WorldConfig config = entity.world.origamiConfig;
+ if (config.allCollisionsEnabled) {
+ return IEntitySelector.a(entity);
+ }
+
+ ScoreboardTeamBase entityTeam = entity.getScoreboardTeam();
+ ScoreboardTeamBase.EnumTeamPush entityTeamPush =
+ entityTeam == null ?
+ ScoreboardTeamBase.EnumTeamPush.ALWAYS :
+ entityTeam.getCollisionRule();
+
+ if (entityTeamPush == ScoreboardTeamBase.EnumTeamPush.NEVER || entity.world.isClientSide
+ || entity.isSpectator()) {
+ return Predicates.alwaysFalse();
+ }
+
+ Predicate<Entity> ret = (tested) -> {
+ if (!tested.canCollideWith(entity) || !entity.canCollideWith(tested)) {
+ return false;
+ }
+ ScoreboardTeamBase testedTeam = tested.getScoreboardTeam();
+ ScoreboardTeamBase.EnumTeamPush testedPush =
+ testedTeam == null ?
+ ScoreboardTeamBase.EnumTeamPush.ALWAYS :
+ testedTeam.getCollisionRule();
+
+ if (testedPush == ScoreboardTeamBase.EnumTeamPush.NEVER) {
+ return false;
+ }
+ if (testedTeam != null && entityTeam != null) {
+ // see IEntitySelector#a(Entity)
+ // copied from there, although for me this logic doesn't seem quite right
+ boolean ally = entityTeam.isAlly(testedTeam);
+
+ if ((entityTeamPush == ScoreboardTeamBase.EnumTeamPush.PUSH_OWN_TEAM ||
+ testedPush == ScoreboardTeamBase.EnumTeamPush.PUSH_OWN_TEAM) && ally) {
+ return false;
+ }
+ return (entityTeamPush != ScoreboardTeamBase.EnumTeamPush.PUSH_OTHER_TEAMS
+ && testedPush != ScoreboardTeamBase.EnumTeamPush.PUSH_OTHER_TEAMS) || ally;
+ } else {
+ return testedPush == ScoreboardTeamBase.EnumTeamPush.ALWAYS &&
+ entityTeamPush == ScoreboardTeamBase.EnumTeamPush.ALWAYS;
+ }
+ };
+
+ ret = ret.and((tested) -> {
+ // no need to continue if we already got false from this check
+ if (!tested.canCollideWith(entity) || !entity.canCollideWith(tested)) {
+ return false;
+ }
+
+ Predicate<Entity> entitySpecific = (es) -> {
+ if (config.playerCollisions) {
+ return es.getEntityType() == EntityTypes.PLAYER;
+ }
+ return false;
+ };
+
+ if (config.animalCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.CREATURE);
+ }
+
+ if (config.ambientCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.AMBIENT);
+ }
+
+ if (config.monsterCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.MONSTER
+ && (config.pillagerCollisions || es.getEntityType() != EntityTypes.PILLAGER));
+ }
+
+ if (config.miscCollisions) {
+ entitySpecific = entitySpecific.or((es) -> {
+ if (es.getEntityType().getEnumCreatureType() == EnumCreatureType.MISC) {
+ return miscVPI(es, config, true);
+ }
+ return false;
+ });
+ } else {
+ entitySpecific = entitySpecific.or((es) -> miscVPI(es, config, false));
+ }
+
+ if (config.waterCreatureCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.WATER_CREATURE);
+ }
+
+ if (config.waterAmbientCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.WATER_AMBIENT);
+ }
+
+ return entitySpecific.test(tested);
+ });
+
+ return ret;
+ }
+
+ private static boolean miscVPI(Entity es, OrigamiConfig.WorldConfig config, boolean isMisc) {
+ Predicate<Entity> ret = (p) -> {
+ if (config.villagerCollisions) {
+ return p.getEntityType() == EntityTypes.VILLAGER;
+ }
+ return isMisc;
+ };
+ if (config.ironGolemCollisions) {
+ ret = ret.or((p) -> p.getEntityType() == EntityTypes.IRON_GOLEM);
+ }
+ if (config.itemCollisions) {
+ ret = ret.or((p) -> p.getEntityType() == EntityTypes.ITEM);
+ }
+ return ret.test(es);
+ }
+}
+package dev.tr7zw.yatopia;
+
+import com.google.common.base.Predicates;
+import de.minebench.origami.OrigamiConfig;
+import java.util.function.Predicate;
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityTypes;
+import net.minecraft.server.EnumCreatureType;
+import net.minecraft.server.IEntitySelector;
+import net.minecraft.server.ScoreboardTeamBase;
+
+public class EntityFilter {
+
+ public static Predicate<Entity> getFilter(Entity entity) {
+ OrigamiConfig.WorldConfig config = entity.world.origamiConfig;
+ if (config.allCollisionsEnabled) {
+ return IEntitySelector.a(entity);
+ }
+
+ ScoreboardTeamBase entityTeam = entity.getScoreboardTeam();
+ ScoreboardTeamBase.EnumTeamPush entityTeamPush =
+ entityTeam == null ?
+ ScoreboardTeamBase.EnumTeamPush.ALWAYS :
+ entityTeam.getCollisionRule();
+
+ if (entityTeamPush == ScoreboardTeamBase.EnumTeamPush.NEVER || entity.world.isClientSide
+ || entity.isSpectator()) {
+ return Predicates.alwaysFalse();
+ }
+
+ Predicate<Entity> ret = (tested) -> {
+ if (!tested.canCollideWith(entity) || !entity.canCollideWith(tested)) {
+ return false;
+ }
+ ScoreboardTeamBase testedTeam = tested.getScoreboardTeam();
+ ScoreboardTeamBase.EnumTeamPush testedPush =
+ testedTeam == null ?
+ ScoreboardTeamBase.EnumTeamPush.ALWAYS :
+ testedTeam.getCollisionRule();
+
+ if (testedPush == ScoreboardTeamBase.EnumTeamPush.NEVER) {
+ return false;
+ }
+ if (testedTeam != null && entityTeam != null) {
+ // see IEntitySelector#a(Entity)
+ // copied from there, although for me this logic doesn't seem quite right
+ boolean ally = entityTeam.isAlly(testedTeam);
+
+ if ((entityTeamPush == ScoreboardTeamBase.EnumTeamPush.PUSH_OWN_TEAM ||
+ testedPush == ScoreboardTeamBase.EnumTeamPush.PUSH_OWN_TEAM) && ally) {
+ return false;
+ }
+ return (entityTeamPush != ScoreboardTeamBase.EnumTeamPush.PUSH_OTHER_TEAMS
+ && testedPush != ScoreboardTeamBase.EnumTeamPush.PUSH_OTHER_TEAMS) || ally;
+ } else {
+ return testedPush == ScoreboardTeamBase.EnumTeamPush.ALWAYS &&
+ entityTeamPush == ScoreboardTeamBase.EnumTeamPush.ALWAYS;
+ }
+ };
+
+ ret = ret.and((tested) -> {
+ // no need to continue if we already got false from this check
+ if (!tested.canCollideWith(entity) || !entity.canCollideWith(tested)) {
+ return false;
+ }
+
+ Predicate<Entity> entitySpecific = (es) -> {
+ if (config.playerCollisions) {
+ return es.getEntityType() == EntityTypes.PLAYER;
+ }
+ return false;
+ };
+
+ if (config.animalCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.CREATURE);
+ }
+
+ if (config.ambientCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.AMBIENT);
+ }
+
+ if (config.monsterCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.MONSTER
+ && (config.pillagerCollisions || es.getEntityType() != EntityTypes.PILLAGER));
+ }
+
+ if (config.miscCollisions) {
+ entitySpecific = entitySpecific.or((es) -> {
+ if (es.getEntityType().getEnumCreatureType() == EnumCreatureType.MISC) {
+ return miscVPI(es, config, true);
+ }
+ return false;
+ });
+ } else {
+ entitySpecific = entitySpecific.or((es) -> miscVPI(es, config, false));
+ }
+
+ if (config.waterCreatureCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.WATER_CREATURE);
+ }
+
+ if (config.waterAmbientCollisions) {
+ entitySpecific = entitySpecific.or((es) -> es.getEntityType().getEnumCreatureType() == EnumCreatureType.WATER_AMBIENT);
+ }
+
+ return entitySpecific.test(tested);
+ });
+
+ return ret;
+ }
+
+ private static boolean miscVPI(Entity es, OrigamiConfig.WorldConfig config, boolean isMisc) {
+ Predicate<Entity> ret = (p) -> {
+ if (config.villagerCollisions) {
+ return p.getEntityType() == EntityTypes.VILLAGER;
+ }
+ return isMisc;
+ };
+ if (config.ironGolemCollisions) {
+ ret = ret.or((p) -> p.getEntityType() == EntityTypes.IRON_GOLEM);
+ }
+ if (config.itemCollisions) {
+ ret = ret.or((p) -> p.getEntityType() == EntityTypes.ITEM);
+ }
+ return ret.test(es);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 88f4c30a03e9139b0284ff1a545ad80941dbd46c..dca7a86dba22bca9bfd830a353a2c9561d1cf0ec 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java

View File

@ -5,18 +5,18 @@ Subject: [PATCH] Allow to change the piston push limit
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index b6e34ea413e29792043955a655d4261553825157..714e65985075eaf243045a3174d89231899c7f17 100644
index 6a62f2314c8f62cef83ed4b68cb45368bad62628..f23c13d14649e92e747b45d93a06bd5726bab00b 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -212,4 +212,8 @@ public class YatopiaConfig {
disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
}
disableEntityCollisionboxes = getBoolean("settings.disableEntityCollisionboxes", false);
}
+ public static int pistonPushLimit = 12;
+ private static void pistonPushLimit() {
+ pistonPushLimit = getInt("settings.pistonPushLimit", 12);
+ }
}
}
diff --git a/src/main/java/net/minecraft/server/PistonExtendsChecker.java b/src/main/java/net/minecraft/server/PistonExtendsChecker.java
index 95aeaaf0bb07c5ecf7117dae3382b0f0aac6426f..89385896af6f6088a9749a13ad5c1d0c581fa502 100644
--- a/src/main/java/net/minecraft/server/PistonExtendsChecker.java

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Item stuck sleep config
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index 714e65985075eaf243045a3174d89231899c7f17..d77ec2b69e8a195f4591a2cb9589d3676f12c4c7 100644
index f23c13d14649e92e747b45d93a06bd5726bab00b..4d718370eb544fb4eb6a1d051512f63414df8c7e 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -216,4 +216,9 @@ public class YatopiaConfig {
@ -17,7 +17,7 @@ index 714e65985075eaf243045a3174d89231899c7f17..d77ec2b69e8a195f4591a2cb9589d367
+ private static void itemStuckSleepTicks() {
+ itemStuckSleepTicks = getInt("settings.itemStuckSleepTicks", 1);
+ }
}
}
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index 732f09319a309b92d74e6536e29d30be917be455..4ba28ab7f96dd83edc552a9c81d79b3c0061dc2c 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Option for simpler Villagers
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index d77ec2b69e8a195f4591a2cb9589d3676f12c4c7..b69459bb141aec6b00a2024db583cacc1667b941 100644
index 4d718370eb544fb4eb6a1d051512f63414df8c7e..39477fcec9ea1e09b9019534f09fe3ff03bdc886 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -221,4 +221,11 @@ public class YatopiaConfig {
@ -19,7 +19,7 @@ index d77ec2b69e8a195f4591a2cb9589d3676f12c4c7..b69459bb141aec6b00a2024db583cacc
+ simplerVillagerBehavior = getBoolean("settings.villager.simplerVillagerBehavior", false);
+ villagersHideAtNight = getBoolean("settings.villager.villagersHideAtNight", false);
+ }
}
}
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
index d32581ec7f521ec53692517811c8e01dc405afbb..f351f76f840009c5b93d337249fb1361f6795c9e 100644
--- a/src/main/java/net/minecraft/server/EntityVillager.java

View File

@ -32,7 +32,7 @@ index f6623032e5d4034c104aa1fc6ff4265169e462ba..c9a61bf6531d761780ac66b69d06a1d0
protected static void logError(String s) {
diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java
index 755e5f6ebf1559c3f4359d356b49615cbd0f19e1..73f395c1350d7ec45f3951df9014beefb550cedd 100644
index 4ae94d576bf1b8e6fceb5fe1aa722ce5be2fb957..4794197d2dd3f81d2b8405f22dabe8519af9cc40 100644
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
@@ -20,6 +20,8 @@ public final class OrigamiConfig {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Fix lead fall dmg config
diff --git a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
index b69459bb141aec6b00a2024db583cacc1667b941..915a1937b1e60006c84816dd0a2ba885f17e519a 100644
index 39477fcec9ea1e09b9019534f09fe3ff03bdc886..0543de8ea80322028729723fd2b500ee7921ffd5 100644
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
@@ -228,4 +228,9 @@ public class YatopiaConfig {
@ -17,7 +17,7 @@ index b69459bb141aec6b00a2024db583cacc1667b941..915a1937b1e60006c84816dd0a2ba885
+ private static void fixFallDistance() {
+ fixFallDistance = getBoolean("settings.fixFallDistance", false);
+ }
}
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 968b1c878c519092150d309adf03dcfe3ae2e8ca..e71469504a0e9c716f50b58b21297acdc7db99f7 100644
--- a/src/main/java/net/minecraft/server/Entity.java

View File

@ -12,10 +12,10 @@ This changes it so that the portal list is filtered to only include portals with
Ported to Yatopia and added per world config option by MrIvanPlays <ivan@mrivanplays.com>
diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java
index 73f395c1350d7ec45f3951df9014beefb550cedd..72021abbe717c5ade30bf046f7ca12f7afd250c6 100644
index 4794197d2dd3f81d2b8405f22dabe8519af9cc40..dfb7a053ed0e64734a0c227c566109074321dddd 100644
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
@@ -161,6 +161,11 @@ public final class OrigamiConfig {
@@ -171,6 +171,11 @@ public final class OrigamiConfig {
&& pillagerCollisions && ironGolemCollisions && miscCollisions && itemCollisions
&& waterCreatureCollisions && waterAmbientCollisions;
}

View File

@ -20,14 +20,27 @@ function updateAll {
update Purpur ver/1.16
update Rainforest ver/1.16
update Tuinity 1.16.2tmp
git submodule update --recursive
}
if [ -z "$1" ]; then
updateAll
elif [ "$1" == "true" ]; then
update Tuinity 1.16.2tmp
git submodule update --recursive
elif [ "$1" == "false" ]; then
if [ "$2" == "true" ]; then
git submodule update --init -f
cd "$basedir"
cd Tuinity
git clean -fx
git clean -fd
git fetch
git reset --hard origin/1.16.2tmp
git submodule update --init --recursive -f
else
updateAll
fi
else
updateAll
fi
git submodule update --recursive
fi

View File

@ -42,7 +42,11 @@ subtasks=1
if [ -z "$2" ]; then
$basedir/scripts/fetchUpstream.sh
else
$basedir/scripts/fetchUpstream.sh true
if [ -z "$3" ]; then
$basedir/scripts/fetchUpstream.sh true
else
$basedir/scripts/fetchUpstream.sh false true
fi
fi
# patch paper

View File

@ -96,7 +96,7 @@ case "$1" in
(
echo "$JAVA_VERSION"
basedir
$scriptdir/updateUpstream.sh "$basedir" || exit 1
$scriptdir/updateUpstream.sh "$basedir" false true || exit 1
set -e
$scriptdir/applyPatches.sh "$basedir" || exit 1
basedir