mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-24 01:58:05 +01:00
Updated upstream
This commit is contained in:
parent
a63d39404b
commit
85c6fe24aa
2
Purpur
2
Purpur
@ -1 +1 @@
|
||||
Subproject commit 630ac49e6551aa9c05eada7f483a3b7d5a2576bb
|
||||
Subproject commit e28eb8c47dc20132e4282ac38ad0186e93724887
|
2
Tuinity
2
Tuinity
@ -1 +1 @@
|
||||
Subproject commit 9eed723fb20914beef5212ade4106595240c18da
|
||||
Subproject commit a63298fbc609c71f21cedfa118aabf091230875b
|
@ -735,7 +735,7 @@ index 8347faf8a7ee62d27cf5eb9f285695fddadfa624..00000000000000000000000000000000
|
||||
-
|
||||
- AttributeDefaults.a();
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 7f929a320bca835669b9267cdc52285ea767f2c1..af6040f2f5823ed9997ded08faf8e865f0a35031 100644
|
||||
index 672de5bc48ea83055f5de2aa35d22bd444500e3b..4cab3f19366a1ea0d6708011e83e4e44b7eff875 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.server;
|
||||
|
@ -405,7 +405,7 @@ index a60634fc455e8a59399020689b70eb64b6824d12..cb4a89940cf02de5c3eefc5c746397a9
|
||||
this.setAllowFlight(dedicatedserverproperties.allowFlight);
|
||||
this.setResourcePack(dedicatedserverproperties.resourcePack, this.aZ());
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index af6040f2f5823ed9997ded08faf8e865f0a35031..d04d74f446d2632938a87cbd63e455683b3a8f37 100644
|
||||
index 4cab3f19366a1ea0d6708011e83e4e44b7eff875..85067809b6446d09e73f29968366849ed4177cc0 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1035,7 +1035,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
@ -19,7 +19,7 @@ index f23c13d14649e92e747b45d93a06bd5726bab00b..4d718370eb544fb4eb6a1d051512f634
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
index 732f09319a309b92d74e6536e29d30be917be455..4ba28ab7f96dd83edc552a9c81d79b3c0061dc2c 100644
|
||||
index 129bf6eaf288ef7c3d303194864c4c160a1b863f..c5aaa537f86d42473a7cdbd4d29f250031f67da9 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityItem.java
|
||||
@@ -82,7 +82,7 @@ public class EntityItem extends Entity {
|
||||
|
@ -19,7 +19,7 @@ index 39477fcec9ea1e09b9019534f09fe3ff03bdc886..0543de8ea80322028729723fd2b500ee
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index d04d74f446d2632938a87cbd63e455683b3a8f37..03849c7709a5ea4852b23e828030dad2220523d3 100644
|
||||
index 85067809b6446d09e73f29968366849ed4177cc0..ba06f9ac8663f33959f6e39d145bbb48a68b0225 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1266,6 +1266,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
@ -10,150 +10,150 @@ Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
|
||||
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a6f3349eafe7ab0bb2cb8dcda38ffdb05da0d413
|
||||
index 0000000000000000000000000000000000000000..aca26213af3dc54f6f5f468e7ce96ab1213efc84
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroup.java
|
||||
@@ -0,0 +1,101 @@
|
||||
+package me.jellysquid.mods.lithium.common.entity;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collection;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.concurrent.ConcurrentHashMap;
|
||||
+import java.util.function.Function;
|
||||
+import net.minecraft.server.Entity;
|
||||
+
|
||||
+/**
|
||||
+ * Class for grouping Entity classes that meet some requirement for use in TypeFilterableList
|
||||
+ * Designed to allow create groups of entity classes that are updated when mods add new entities that fit into the group.
|
||||
+ *
|
||||
+ * @author 2No2Name
|
||||
+ */
|
||||
+public class EntityClassGroup {
|
||||
+ //Keep a set of classes that were already added to matching class groups, so we only analyse them once.
|
||||
+ private static final Map<Class<?>, Object> knownEntityClasses = new ConcurrentHashMap<>(); //value unused, no set variant available
|
||||
+ //Keep track of available class groups for updating them in case an entity class is instantiated for the first time
|
||||
+ private static final List<EntityClassGroup> entityClassGroups = new ArrayList<>();
|
||||
+
|
||||
+ public static final EntityClassGroup COLLISION_BOX_OVERRIDE = new EntityClassGroup(
|
||||
+ (entityClass) -> {
|
||||
+ boolean overwritten;
|
||||
+ while (entityClass != null && entityClass != Entity.class) {
|
||||
+ try {
|
||||
+ overwritten = true;
|
||||
+ entityClass.getDeclaredMethod("hardCollides");
|
||||
+ } catch (NoSuchMethodException e) {
|
||||
+ overwritten = false;
|
||||
+ entityClass = entityClass.getSuperclass();
|
||||
+ }
|
||||
+ if (overwritten) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ );
|
||||
+ public static final EntityClassGroup HARD_COLLISION_BOX_OVERRIDE = new EntityClassGroup(
|
||||
+ (entityClass) -> {
|
||||
+ boolean overwritten;
|
||||
+ while (entityClass != null && entityClass != Entity.class) {
|
||||
+ try {
|
||||
+ overwritten = true;
|
||||
+ entityClass.getDeclaredMethod("hardCollidesWith", Entity.class);
|
||||
+ } catch (NoSuchMethodException e) {
|
||||
+ overwritten = false;
|
||||
+ entityClass = entityClass.getSuperclass();
|
||||
+ }
|
||||
+ if (overwritten)
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ );
|
||||
+
|
||||
+ private final Map<Class<?>, Object> classGroup; //value unused, no set variant available
|
||||
+ private final Function<Class<?>, Boolean> classFitEvaluator;
|
||||
+
|
||||
+ public EntityClassGroup(Function<Class<?>, Boolean> classFitEvaluator) {
|
||||
+ this.classGroup = new ConcurrentHashMap<>();
|
||||
+ EntityClassGroup.entityClassGroups.add(this);
|
||||
+ this.classFitEvaluator = classFitEvaluator;
|
||||
+ }
|
||||
+
|
||||
+ public EntityClassGroup add(Class<?> entityClass) {
|
||||
+ this.classGroup.put(entityClass, entityClass);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ public boolean contains(Class<?> entityClass) {
|
||||
+ EntityClassGroup.analyseEntityClass(entityClass);
|
||||
+ return this.classGroup.containsKey(entityClass);
|
||||
+ }
|
||||
+
|
||||
+ public Collection<Class<?>> getCollection() {
|
||||
+ return this.classGroup.keySet();
|
||||
+ }
|
||||
+
|
||||
+ public void addClassIfFitting(Class<?> discoveredEntityClass) {
|
||||
+ if (this.classGroup.containsKey(discoveredEntityClass)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (this.classFitEvaluator != null && this.classFitEvaluator.apply(discoveredEntityClass)) {
|
||||
+ this.classGroup.put(discoveredEntityClass, discoveredEntityClass);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void analyseEntityClass(Class<?> entityClass) {
|
||||
+ if (EntityClassGroup.knownEntityClasses.containsKey(entityClass)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ EntityClassGroup.knownEntityClasses.put(entityClass, entityClass);
|
||||
+
|
||||
+ for (EntityClassGroup entityClassGroup : EntityClassGroup.entityClassGroups) {
|
||||
+ entityClassGroup.addClassIfFitting(entityClass);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+package me.jellysquid.mods.lithium.common.entity;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collection;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.concurrent.ConcurrentHashMap;
|
||||
+import java.util.function.Function;
|
||||
+import net.minecraft.server.Entity;
|
||||
+
|
||||
+/**
|
||||
+ * Class for grouping Entity classes that meet some requirement for use in TypeFilterableList
|
||||
+ * Designed to allow create groups of entity classes that are updated when mods add new entities that fit into the group.
|
||||
+ *
|
||||
+ * @author 2No2Name
|
||||
+ */
|
||||
+public class EntityClassGroup {
|
||||
+ //Keep a set of classes that were already added to matching class groups, so we only analyse them once.
|
||||
+ private static final Map<Class<?>, Object> knownEntityClasses = new ConcurrentHashMap<>(); //value unused, no set variant available
|
||||
+ //Keep track of available class groups for updating them in case an entity class is instantiated for the first time
|
||||
+ private static final List<EntityClassGroup> entityClassGroups = new ArrayList<>();
|
||||
+
|
||||
+ public static final EntityClassGroup COLLISION_BOX_OVERRIDE = new EntityClassGroup(
|
||||
+ (entityClass) -> {
|
||||
+ boolean overwritten;
|
||||
+ while (entityClass != null && entityClass != Entity.class) {
|
||||
+ try {
|
||||
+ overwritten = true;
|
||||
+ entityClass.getDeclaredMethod("hardCollides");
|
||||
+ } catch (NoSuchMethodException e) {
|
||||
+ overwritten = false;
|
||||
+ entityClass = entityClass.getSuperclass();
|
||||
+ }
|
||||
+ if (overwritten) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ );
|
||||
+ public static final EntityClassGroup HARD_COLLISION_BOX_OVERRIDE = new EntityClassGroup(
|
||||
+ (entityClass) -> {
|
||||
+ boolean overwritten;
|
||||
+ while (entityClass != null && entityClass != Entity.class) {
|
||||
+ try {
|
||||
+ overwritten = true;
|
||||
+ entityClass.getDeclaredMethod("hardCollidesWith", Entity.class);
|
||||
+ } catch (NoSuchMethodException e) {
|
||||
+ overwritten = false;
|
||||
+ entityClass = entityClass.getSuperclass();
|
||||
+ }
|
||||
+ if (overwritten)
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ );
|
||||
+
|
||||
+ private final Map<Class<?>, Object> classGroup; //value unused, no set variant available
|
||||
+ private final Function<Class<?>, Boolean> classFitEvaluator;
|
||||
+
|
||||
+ public EntityClassGroup(Function<Class<?>, Boolean> classFitEvaluator) {
|
||||
+ this.classGroup = new ConcurrentHashMap<>();
|
||||
+ EntityClassGroup.entityClassGroups.add(this);
|
||||
+ this.classFitEvaluator = classFitEvaluator;
|
||||
+ }
|
||||
+
|
||||
+ public EntityClassGroup add(Class<?> entityClass) {
|
||||
+ this.classGroup.put(entityClass, entityClass);
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ public boolean contains(Class<?> entityClass) {
|
||||
+ EntityClassGroup.analyseEntityClass(entityClass);
|
||||
+ return this.classGroup.containsKey(entityClass);
|
||||
+ }
|
||||
+
|
||||
+ public Collection<Class<?>> getCollection() {
|
||||
+ return this.classGroup.keySet();
|
||||
+ }
|
||||
+
|
||||
+ public void addClassIfFitting(Class<?> discoveredEntityClass) {
|
||||
+ if (this.classGroup.containsKey(discoveredEntityClass)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (this.classFitEvaluator != null && this.classFitEvaluator.apply(discoveredEntityClass)) {
|
||||
+ this.classGroup.put(discoveredEntityClass, discoveredEntityClass);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void analyseEntityClass(Class<?> entityClass) {
|
||||
+ if (EntityClassGroup.knownEntityClasses.containsKey(entityClass)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ EntityClassGroup.knownEntityClasses.put(entityClass, entityClass);
|
||||
+
|
||||
+ for (EntityClassGroup entityClassGroup : EntityClassGroup.entityClassGroups) {
|
||||
+ entityClassGroup.addClassIfFitting(entityClass);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroupHelper.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroupHelper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d0d8980571c8ac8eb8ef46f602fed7bbf91c05d9
|
||||
index 0000000000000000000000000000000000000000..29c944e34ceb5c9c7bbd8e85f756c58deeac7eab
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/EntityClassGroupHelper.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package me.jellysquid.mods.lithium.common.entity;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import me.jellysquid.mods.lithium.common.world.WorldHelper;
|
||||
+import net.minecraft.server.AxisAlignedBB;
|
||||
+import net.minecraft.server.Entity;
|
||||
+import net.minecraft.server.IEntityAccess;
|
||||
+import net.minecraft.server.IEntitySelector;
|
||||
+import net.minecraft.server.World;
|
||||
+
|
||||
+public class EntityClassGroupHelper {
|
||||
+
|
||||
+ /**
|
||||
+ * Partial [VanillaCopy] Classes overriding Entity.getHardCollisionBox(Entity other) or Entity.getCollisionBox()
|
||||
+ * The returned entity list is only used to call getCollisionBox and getHardCollisionBox. As most entities return null
|
||||
+ * for both of these methods, getting those is not necessary. This is why we only get entities when they overwrite
|
||||
+ * getCollisionBox
|
||||
+ *
|
||||
+ * @param entityView the world
|
||||
+ * @param selection the box the entities have to collide with
|
||||
+ * @param entity the entity that is searching for the colliding entities
|
||||
+ * @return list of entities with collision boxes
|
||||
+ */
|
||||
+ public static List<Entity> getEntitiesWithCollisionBoxForEntity(IEntityAccess entityView, AxisAlignedBB selection, Entity entity) {
|
||||
+ if (entity != null && EntityClassGroup.HARD_COLLISION_BOX_OVERRIDE.contains(entity.getClass()) || !(entityView instanceof World)) {
|
||||
+ //use vanilla code when method_30949 (previously getHardCollisionBox(Entity other)) is overwritten, as every entity could be relevant as argument of getHardCollisionBox
|
||||
+ return entityView.getEntities(entity, selection);
|
||||
+ } else {
|
||||
+ //only get entities that overwrite method_30948 (previously getCollisionBox)
|
||||
+ return WorldHelper.getEntitiesOfClassGroup((World) entityView, entity, EntityClassGroup.COLLISION_BOX_OVERRIDE, selection, IEntitySelector.exceptSpectator());
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+package me.jellysquid.mods.lithium.common.entity;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import me.jellysquid.mods.lithium.common.world.WorldHelper;
|
||||
+import net.minecraft.server.AxisAlignedBB;
|
||||
+import net.minecraft.server.Entity;
|
||||
+import net.minecraft.server.IEntityAccess;
|
||||
+import net.minecraft.server.IEntitySelector;
|
||||
+import net.minecraft.server.World;
|
||||
+
|
||||
+public class EntityClassGroupHelper {
|
||||
+
|
||||
+ /**
|
||||
+ * Partial [VanillaCopy] Classes overriding Entity.getHardCollisionBox(Entity other) or Entity.getCollisionBox()
|
||||
+ * The returned entity list is only used to call getCollisionBox and getHardCollisionBox. As most entities return null
|
||||
+ * for both of these methods, getting those is not necessary. This is why we only get entities when they overwrite
|
||||
+ * getCollisionBox
|
||||
+ *
|
||||
+ * @param entityView the world
|
||||
+ * @param selection the box the entities have to collide with
|
||||
+ * @param entity the entity that is searching for the colliding entities
|
||||
+ * @return list of entities with collision boxes
|
||||
+ */
|
||||
+ public static List<Entity> getEntitiesWithCollisionBoxForEntity(IEntityAccess entityView, AxisAlignedBB selection, Entity entity) {
|
||||
+ if (entity != null && EntityClassGroup.HARD_COLLISION_BOX_OVERRIDE.contains(entity.getClass()) || !(entityView instanceof World)) {
|
||||
+ //use vanilla code when method_30949 (previously getHardCollisionBox(Entity other)) is overwritten, as every entity could be relevant as argument of getHardCollisionBox
|
||||
+ return entityView.getEntities(entity, selection);
|
||||
+ } else {
|
||||
+ //only get entities that overwrite method_30948 (previously getCollisionBox)
|
||||
+ return WorldHelper.getEntitiesOfClassGroup((World) entityView, entity, EntityClassGroup.COLLISION_BOX_OVERRIDE, selection, IEntitySelector.exceptSpectator());
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..260ba36384a3f8ba047ba2338abb71e1369ed65e
|
||||
@ -631,84 +631,84 @@ index 0000000000000000000000000000000000000000..883581e12a014ce86dc7aea8ecab141e
|
||||
+}
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java b/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3b7b997576518d0dde1c4e3f31006dab60e5ea21
|
||||
index 0000000000000000000000000000000000000000..3ae7522ef116727ff0eb89978e26785b55d56319
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/WorldHelper.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package me.jellysquid.mods.lithium.common.world;
|
||||
+
|
||||
+import com.google.common.collect.Lists;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Predicate;
|
||||
+import me.jellysquid.mods.lithium.common.entity.EntityClassGroup;
|
||||
+import me.jellysquid.mods.lithium.common.world.chunk.ClassGroupFilterableList;
|
||||
+import net.minecraft.server.AxisAlignedBB;
|
||||
+import net.minecraft.server.Chunk;
|
||||
+import net.minecraft.server.Entity;
|
||||
+import net.minecraft.server.EntitySlice;
|
||||
+import net.minecraft.server.MathHelper;
|
||||
+import net.minecraft.server.World;
|
||||
+
|
||||
+public class WorldHelper {
|
||||
+
|
||||
+ /**
|
||||
+ * Method that allows getting entities of a class group.
|
||||
+ * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity
|
||||
+ */
|
||||
+ public static List<Entity> getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, AxisAlignedBB box_1, Predicate<Entity> predicate_1) {
|
||||
+ int int_1 = MathHelper.floor((box_1.minX - 2.0D) / 16.0D);
|
||||
+ int int_2 = MathHelper.f((box_1.maxX + 2.0D) / 16.0D);
|
||||
+ int int_3 = MathHelper.floor((box_1.minZ - 2.0D) / 16.0D);
|
||||
+ int int_4 = MathHelper.f((box_1.maxZ + 2.0D) / 16.0D);
|
||||
+ List<Entity> list_1 = Lists.newArrayList();
|
||||
+
|
||||
+ for (int int_5 = int_1; int_5 < int_2; ++int_5) {
|
||||
+ for (int int_6 = int_3; int_6 < int_4; ++int_6) {
|
||||
+ Chunk worldChunk_1 = world.getChunkIfLoaded(int_5, int_6);
|
||||
+ if (worldChunk_1 != null) {
|
||||
+ WorldHelper.getEntitiesOfClassGroup(worldChunk_1, excluded, type, box_1, list_1, predicate_1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return list_1;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Method that allows getting entities of a class group.
|
||||
+ * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity
|
||||
+ */
|
||||
+ public static void getEntitiesOfClassGroup(Chunk worldChunk, Entity excluded, EntityClassGroup type, AxisAlignedBB box_1, List<Entity> list_1, Predicate<Entity> predicate_1) {
|
||||
+ EntitySlice<Entity>[] entitySections = worldChunk.getEntitySlices();
|
||||
+ int int_1 = MathHelper.floor((box_1.minY - 2.0D) / 16.0D);
|
||||
+ int int_2 = MathHelper.floor((box_1.maxY + 2.0D) / 16.0D);
|
||||
+ int_1 = MathHelper.clamp(int_1, 0, entitySections.length - 1);
|
||||
+ int_2 = MathHelper.clamp(int_2, 0, entitySections.length - 1);
|
||||
+
|
||||
+ for (int int_3 = int_1; int_3 <= int_2; ++int_3) {
|
||||
+ //noinspection rawtypes
|
||||
+ for (Object entity_1 : ((ClassGroupFilterableList) entitySections[int_3]).getAllOfGroupType(type)) {
|
||||
+ if (entity_1 != excluded && ((Entity) entity_1).getBoundingBox().intersects(box_1) && (predicate_1 == null || predicate_1.test((Entity) entity_1))) {
|
||||
+ list_1.add((Entity) entity_1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+package me.jellysquid.mods.lithium.common.world;
|
||||
+
|
||||
+import com.google.common.collect.Lists;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Predicate;
|
||||
+import me.jellysquid.mods.lithium.common.entity.EntityClassGroup;
|
||||
+import me.jellysquid.mods.lithium.common.world.chunk.ClassGroupFilterableList;
|
||||
+import net.minecraft.server.AxisAlignedBB;
|
||||
+import net.minecraft.server.Chunk;
|
||||
+import net.minecraft.server.Entity;
|
||||
+import net.minecraft.server.EntitySlice;
|
||||
+import net.minecraft.server.MathHelper;
|
||||
+import net.minecraft.server.World;
|
||||
+
|
||||
+public class WorldHelper {
|
||||
+
|
||||
+ /**
|
||||
+ * Method that allows getting entities of a class group.
|
||||
+ * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity
|
||||
+ */
|
||||
+ public static List<Entity> getEntitiesOfClassGroup(World world, Entity excluded, EntityClassGroup type, AxisAlignedBB box_1, Predicate<Entity> predicate_1) {
|
||||
+ int int_1 = MathHelper.floor((box_1.minX - 2.0D) / 16.0D);
|
||||
+ int int_2 = MathHelper.f((box_1.maxX + 2.0D) / 16.0D);
|
||||
+ int int_3 = MathHelper.floor((box_1.minZ - 2.0D) / 16.0D);
|
||||
+ int int_4 = MathHelper.f((box_1.maxZ + 2.0D) / 16.0D);
|
||||
+ List<Entity> list_1 = Lists.newArrayList();
|
||||
+
|
||||
+ for (int int_5 = int_1; int_5 < int_2; ++int_5) {
|
||||
+ for (int int_6 = int_3; int_6 < int_4; ++int_6) {
|
||||
+ Chunk worldChunk_1 = world.getChunkIfLoaded(int_5, int_6);
|
||||
+ if (worldChunk_1 != null) {
|
||||
+ WorldHelper.getEntitiesOfClassGroup(worldChunk_1, excluded, type, box_1, list_1, predicate_1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return list_1;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Method that allows getting entities of a class group.
|
||||
+ * [VanillaCopy] but custom combination of: get class filtered entities together with excluding one entity
|
||||
+ */
|
||||
+ public static void getEntitiesOfClassGroup(Chunk worldChunk, Entity excluded, EntityClassGroup type, AxisAlignedBB box_1, List<Entity> list_1, Predicate<Entity> predicate_1) {
|
||||
+ EntitySlice<Entity>[] entitySections = worldChunk.getEntitySlices();
|
||||
+ int int_1 = MathHelper.floor((box_1.minY - 2.0D) / 16.0D);
|
||||
+ int int_2 = MathHelper.floor((box_1.maxY + 2.0D) / 16.0D);
|
||||
+ int_1 = MathHelper.clamp(int_1, 0, entitySections.length - 1);
|
||||
+ int_2 = MathHelper.clamp(int_2, 0, entitySections.length - 1);
|
||||
+
|
||||
+ for (int int_3 = int_1; int_3 <= int_2; ++int_3) {
|
||||
+ //noinspection rawtypes
|
||||
+ for (Object entity_1 : ((ClassGroupFilterableList) entitySections[int_3]).getAllOfGroupType(type)) {
|
||||
+ if (entity_1 != excluded && ((Entity) entity_1).getBoundingBox().intersects(box_1) && (predicate_1 == null || predicate_1.test((Entity) entity_1))) {
|
||||
+ list_1.add((Entity) entity_1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/ClassGroupFilterableList.java b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/ClassGroupFilterableList.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a019cf5cb497e57d747fe53b5d0f912a37c41c9b
|
||||
index 0000000000000000000000000000000000000000..493103d755c222f2c6031ffb8f5c0b7a2e3fde77
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/world/chunk/ClassGroupFilterableList.java
|
||||
@@ -0,0 +1,8 @@
|
||||
+package me.jellysquid.mods.lithium.common.world.chunk;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import me.jellysquid.mods.lithium.common.entity.EntityClassGroup;
|
||||
+
|
||||
+public interface ClassGroupFilterableList<T> {
|
||||
+ Collection<T> getAllOfGroupType(EntityClassGroup type);
|
||||
+}
|
||||
+package me.jellysquid.mods.lithium.common.world.chunk;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import me.jellysquid.mods.lithium.common.entity.EntityClassGroup;
|
||||
+
|
||||
+public interface ClassGroupFilterableList<T> {
|
||||
+ Collection<T> getAllOfGroupType(EntityClassGroup type);
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index ac6e5e3309affc830d4db07fd9b8d809c3085033..37a3b26cdeb02acb8051f0a99313de7923ebae3b 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
@ -778,7 +778,7 @@ index ac6e5e3309affc830d4db07fd9b8d809c3085033..37a3b26cdeb02acb8051f0a99313de79
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 03849c7709a5ea4852b23e828030dad2220523d3..d7341889b91c2319d89c1480a003166ec5069d82 100644
|
||||
index ba06f9ac8663f33959f6e39d145bbb48a68b0225..c754c34b7d2c3d47a7af6642fc57b8061ac1c2d6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -75,7 +75,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
@ -35,7 +35,7 @@ for D in ${searchtxts[@]}; do
|
||||
# Abort previous applying operation
|
||||
git am --abort >/dev/null 2>&1
|
||||
# Apply our patches on top Paper in our dirs
|
||||
git am --reject --whitespace=fix --no-utf8 --3way --ignore-whitespace $filename || (
|
||||
git am --reject --3way --whitespace=fix $filename || (
|
||||
#files=`$gitcmd diff --name-only | grep -E '.rej$' `
|
||||
#if [[ files != null ]]; then
|
||||
# for filerej in files; do
|
||||
|
Loading…
Reference in New Issue
Block a user