mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-04 18:02:27 +01:00
76a75f866b
* Updated Upstream and Sidestream(s) (Paper) 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: d15161114 [Auto] Updated Upstream (Spigot) e8889e96a [Auto] Updated Upstream (CraftBukkit) 3bc888ba6 [Auto] Updated Upstream (CraftBukkit) * Updated Upstream and Sidestream(s) (Paper) 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: 3fea87edb [Auto] Updated Upstream (CraftBukkit) a111b1365 Send post ChatEvent messages as MessageType.CHAT * Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur) 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: 3db3aaf39 [Auto] Updated Upstream (CraftBukkit) c953e51dd [Auto] Updated Upstream (CraftBukkit/Spigot) dc529c7a9 Fix PlayerEditBookEvent (#5463) Tuinity Changes: a0aa5ab Do not load 1 radius neighbours for lighting 5ccfa52 Fix terrible patch times af53d70 Stop large move vectors in player packet handling from killing the server 6e56ee7 Fix OBFHELPER for flushHeader in RegionFile 995d05c Do not update TE's in generating chunks Purpur Changes: 2e66f83 [ci-skip] Fix typo 6cbe4fc Change Logo Tuinity to Purpur 5e89d23 Updated Upstream (Paper & Airplane) * Updated Upstream and Sidestream(s) (Paper) 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: 304a216ba [CI-SKIP] Ignore gitignore when adding files in automation d8e384a16 [CI-SKIP] Drop `Allow PlayerEditBookEvent to fire for off hand` (#5471) * fix kotlin-stdlib dependency * update dependencies * how did that happen... * Updated Upstream and Sidestream(s) (Paper) 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: de138fac4 [Auto] Updated Upstream (Bukkit) * Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane) 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: 4492bc4cc remove l4j class no longer in existence from preload list be1370517 Updated Upstream (CraftBukkit) (#5484) d560151ec Bump mysql-connector-java to 8.0.23 (Fixes #5473) (#5474) 61f400f11 Update log4j to 2.11.2 for JDK 9+ compat (#5400) a98196585 Updated Upstream (Bukkit/CraftBukkit) Tuinity Changes: d5261ad Do not load chunks for getCubes by default da9cf98 Don't read neighbour chunk data off disk when converting chunks Airplane Changes: 8de8e82 Updated Upstream (Tuinity)
225 lines
11 KiB
Diff
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 27599f422be266ad2fdbda49617661801c2c1991..2457b240f3b49dbd5fe0eb603d86418fd65f0205 100644
|
|
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
|
|
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
|
|
@@ -135,6 +135,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 a33f2ef70ebb32e7d57a055a2e88cf5c4de48e75..0d5acd5e7c2faafd59aa2df9e61f8bb1baa28ffe 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
@@ -3053,7 +3053,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;
|
|
+ }
|
|
+}
|