Yatopia/patches/server/0007-Per-entity-type-collision-settings.patch
Simon Gardling e01705826c
Upstream (#484)
* Updated Upstream and Sidestream(s) (Paper/Purpur/Empirecraft)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
2a67a9e51 Fix missing CraftMetaBook#toBuilder override
48aa06106 Add more Wandering Trader API (#5020)
8cec462a5 [CI-SKIP] Remove Astei from the MIT list (#5577)
21fbc3196 [CI-SKIP] Add Other textarea to issue templates (#5562)
453e983e4 fix isProxyOnlineMode coverage, don't lookup UUIDs in offline mode (Fixes #2011)
81cc4f928 Send empty commands if tab completion is disabled (Closes #5519)
9ed3e470d Keep moveToWorld with old method signature
99a66a583 [Auto] Updated Upstream (CraftBukkit)
976c6d425 [CI-SKIP] [Auto] Rebuild Patches
51deec726 Drop unneeded portal patch (#5566)
07a18c457 [Auto] Updated Upstream (CraftBukkit)
6733d7875 [Auto] Updated Upstream (Bukkit)
9958447cb [Auto] Updated Upstream (Bukkit)
840e72091 [CI-SKIP] [Auto] Rebuild Patches
a33232d4a Add beacon activation and deactivation events (#5121)

Purpur Changes:
ebc0765 Updated Upstream (Paper)
5bc5dfd Fix #318 - Stonecutter does not damage when sneaking
8366582 Resolve #286 - Add config and API for item immunity to lightning
a86555b Updated Upstream (Paper)
8b2607c Config for only sending advancements to affected players (#312)
7ee3393 Add config for the piston push limit (#311)
a30e5ac Add config for void damage dealt
786382b Updated Upstream (Paper)
60d8411 [ci-skip] fix patch name
b64f536 Config for changing the blocks that turn into paths (#303)
1d3f710 Updated Upstream (Paper)
3af86ad Oopsie
4b0342a Gamemode extra permissions
17c8573 [CI-SKIP] Don't pass ping to demo command output
c3481c0 Initialize the credits command output in config
a176fe6 Add credits command

Empirecraft Changes:
b2879a24 Updated Paper

* Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Empirecraft)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
b3cc88799 Add the ability to clear entities from block storage (#5598)
f50171f3b Add missing rarity method on ItemStack (#5594)
aeb6e7dd2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5601)
b0a4f353b fix cancelling block falling causing client desync (fixes #5386) (#5419)
8ed45920c Don't annotate type parameters using JetBrains annotations (#5600)
d7625d926 Add new methods from PlayerMoveEvent to EntityMoveEvent (#5591)
29785297b Allow for Component suggestion tooltips in AsyncTabCompleteEvent (#5504)
0aea6c2ff Use JsonSerializationContext#serialize instead of recursion for AdventureComponents - fixes #5580 and #5371
8fcef3c1f Return after sending empty commands (#5586)

Tuinity Changes:
3350246 Updated Upstream (Paper)
f773caf Fix rare ticket level recursion crash
0fa8a0e Starlight Handle concurrent chunk generation and lighting better

Airplane Changes:
fad74c2 Fix JB annotations for gradle (credit jpenilla)
d02f034 Updated Upstream (Tuinity)

Purpur Changes:
adfe5d3 Updated Upstream (Paper)
7a728f8 Fix #325 - Fix SPIGOT-6278
f5c3dae Updated Upstream (Paper)
a80e5b6 Dont create item meta when checking if meta properties exist
90339c5 Add missing netherite from Material#isArmor
bedac18 Updated Upstream (Paper, Tuinity, & Airplane)
3b1531a [ci-skip] Add wrapper validation step to actions
73ab4e6 Update the "changing the blocks that turn into paths" defaults to reflect the vanilla defaults. (#322)
a24b31b Updated Upstream (Paper)

Empirecraft Changes:
87ceb204 Updated Paper
a3497a7e Fix some patches
2ed9e7fa Updated Paper
d5a47a3d Updated Paper

* Updated Upstream and Sidestream(s) (Tuinity)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Tuinity Changes:
1382473 Null check chunk in block changes for Starlight
2021-05-10 23:16:50 -04:00

225 lines
11 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrIvanPlays <ivan@mrivanplays.com>
Date: Thu, 13 Aug 2020 15:14:36 +0300
Subject: [PATCH] Per entity (type) collision settings
Base patch was the only player collisions patch, the original author of was tr7zw <tr7zw@live.de>
but pretty much the whole implementation changed.
This patch implements per entity (type) collision settings with 100% compatibility with bukkit api and
vanilla.
The whole code is based around 1 class, the EntityFilter class. Whole filtering logic is there.
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 e72be36d860630afb879b40bf028c5e456169634..d2a9455c0e97a51dcf1513322c23e41d8253fbc2 100644
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
@@ -127,6 +127,39 @@ public final class OrigamiConfig {
private void pigmenDontTargetUnlessHit() {
pigmenDontTargetUnlessHit = getBoolean("pigmen.dont-target-unless-hit", pigmenDontTargetUnlessHit);
}
+
+ // Yatopia start
+ public boolean playerCollisions = true;
+ public boolean animalCollisions = true;
+ public boolean ambientCollisions = true;
+ public boolean monsterCollisions = true;
+ public boolean villagerCollisions = true;
+ public boolean pillagerCollisions = true;
+ public boolean ironGolemCollisions = true;
+ public boolean miscCollisions = true;
+ public boolean itemCollisions = true;
+ public boolean waterCreatureCollisions = true;
+ public boolean waterAmbientCollisions = true;
+ public boolean allCollisionsEnabled = false;
+ private void specificCollisionSettings() {
+ playerCollisions = getBoolean("collisions.players", playerCollisions);
+ animalCollisions = getBoolean("collisions.animals", animalCollisions);
+ ambientCollisions = getBoolean("collisions.ambient", ambientCollisions);
+ monsterCollisions = getBoolean("collisions.monsters", monsterCollisions);
+ villagerCollisions = getBoolean("collisions.villagers", villagerCollisions);
+ pillagerCollisions = getBoolean("collisions.pillagers", pillagerCollisions);
+ ironGolemCollisions = getBoolean("collisions.iron-golems", ironGolemCollisions);
+ miscCollisions = getBoolean("collisions.misc", miscCollisions);
+ itemCollisions = getBoolean("collisions.items", itemCollisions);
+ waterCreatureCollisions = getBoolean("collisions.water-creature", waterCreatureCollisions);
+ waterAmbientCollisions = getBoolean("collisions.water-ambient", waterAmbientCollisions);
+
+ allCollisionsEnabled =
+ playerCollisions && animalCollisions && ambientCollisions && monsterCollisions && villagerCollisions
+ && pillagerCollisions && ironGolemCollisions && miscCollisions && itemCollisions
+ && waterCreatureCollisions && waterAmbientCollisions;
+ }
+ // Yatopia end
}
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
index 82af1ac4743e96f8934796359d30f8ee9426e8de..61b39dca71580ea07da32943efc6e1024067b1ee 100644
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
@@ -3069,7 +3069,7 @@ public abstract class EntityLiving extends Entity {
// Paper - end don't run getEntities if we're not going to use its result
// Tuinity start - reduce memory allocation from collideNearby
List<Entity> list = com.tuinity.tuinity.util.CachedLists.getTempGetEntitiesList();
- this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.pushable(this, world.paperConfig.fixClimbingBypassingCrammingRule), list); // Paper - fix climbing bypassing cramming rule
+ this.world.getEntities(this, this.getBoundingBox(), org.yatopiamc.yatopia.server.EntityFilter.getFilter(this, world.paperConfig.fixClimbingBypassingCrammingRule), list); // Paper - fix climbing bypassing cramming rule // Yatopia
try {
// Tuinity end - reduce memory allocation from collideNearby
diff --git a/src/main/java/org/yatopiamc/yatopia/server/EntityFilter.java b/src/main/java/org/yatopiamc/yatopia/server/EntityFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..77df98d9b622e66ce47d1640819a5d20e5651fdc
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/EntityFilter.java
@@ -0,0 +1,145 @@
+package org.yatopiamc.yatopia.server;
+
+import de.minebench.origami.OrigamiConfig;
+import java.util.function.Predicate;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntityTypes;
+import net.minecraft.world.entity.EnumCreatureType;
+import net.minecraft.world.entity.IEntitySelector;
+import net.minecraft.world.scores.ScoreboardTeamBase;
+
+public class EntityFilter {
+
+ public static Predicate<Entity> getFilter(Entity entity, boolean ignoreClimbing) {
+ OrigamiConfig.WorldConfig config = entity.world.origamiConfig;
+ if (config.allCollisionsEnabled) {
+ return IEntitySelector.pushable(entity, ignoreClimbing);
+ }
+
+ 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 tested -> false;
+ }
+
+ Predicate<Entity> ret = (tested) -> {
+ if (!tested.isCollidable(ignoreClimbing) || !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) -> {
+ if (tested.getEntityType() == EntityTypes.PLAYER && config.playerCollisions) {
+ return true;
+ }
+ if (tested.getEntityType().getEnumCreatureType() == EnumCreatureType.CREATURE && config.animalCollisions) {
+ return true;
+ }
+ if (tested.getEntityType().getEnumCreatureType() == EnumCreatureType.AMBIENT && config.ambientCollisions) {
+ return true;
+ }
+ if (tested.getEntityType().getEnumCreatureType() == EnumCreatureType.MONSTER) {
+ if (config.monsterCollisions) {
+ if (config.pillagerCollisions) {
+ return true;
+ } else {
+ return tested.getEntityType() != EntityTypes.PILLAGER;
+ }
+ } else {
+ if (config.pillagerCollisions) {
+ return tested.getEntityType() == EntityTypes.PILLAGER;
+ } else {
+ return false;
+ }
+ }
+ }
+ if (tested.getEntityType().getEnumCreatureType() == EnumCreatureType.MISC) {
+ if (config.miscCollisions) {
+ if (config.villagerCollisions && config.ironGolemCollisions && config.itemCollisions) {
+ return true;
+ }
+ if (!config.villagerCollisions) {
+ if (tested.getEntityType() == EntityTypes.VILLAGER) {
+ return false;
+ }
+ }
+ if (!config.ironGolemCollisions) {
+ if (tested.getEntityType() == EntityTypes.IRON_GOLEM) {
+ return false;
+ }
+ }
+ if (!config.itemCollisions) {
+ if (tested.getEntityType() == EntityTypes.ITEM) {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ if (config.villagerCollisions && config.ironGolemCollisions && config.itemCollisions) {
+ if (tested.getEntityType() == EntityTypes.VILLAGER) {
+ return true;
+ }
+ if (tested.getEntityType() == EntityTypes.IRON_GOLEM) {
+ return true;
+ }
+ if (tested.getEntityType() == EntityTypes.ITEM) {
+ return true;
+ }
+ }
+ if (config.villagerCollisions && config.ironGolemCollisions) {
+ if (tested.getEntityType() == EntityTypes.VILLAGER) {
+ return true;
+ }
+ if (tested.getEntityType() == EntityTypes.IRON_GOLEM) {
+ return true;
+ }
+ }
+ if (config.villagerCollisions) {
+ if (tested.getEntityType() == EntityTypes.VILLAGER) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ if (tested.getEntityType().getEnumCreatureType() == EnumCreatureType.WATER_CREATURE && config.waterCreatureCollisions) {
+ return true;
+ }
+ if (tested.getEntityType().getEnumCreatureType() == EnumCreatureType.WATER_AMBIENT && config.waterAmbientCollisions) {
+ return true;
+ }
+ return false;
+ });
+
+ return ret;
+ }
+}