mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-26 12:45:52 +01:00
Entities fall through Hoppers, Slabs and Stairs
Fixes #212 Additionally lowered the ram allocated and changed the work directory for the intellij run config.
This commit is contained in:
parent
083fea00f3
commit
435f17de1c
@ -12,6 +12,7 @@ # Patches
|
||||
| api | Add ChatColor.getById | Aikar | |
|
||||
| api | Add GameProfileLookupEvent | tr7zw | |
|
||||
| server | Add GameProfileLookupEvent | tr7zw | |
|
||||
| server | Add IntelliJ IDEA runnable | Bud Gidiere | |
|
||||
| api | Add NBT API as a first-class lib | tr7zw | |
|
||||
| server | Add NBT API as a first-class lib | tr7zw | |
|
||||
| api | Add StructureLocateEvent | dfsek | |
|
||||
|
@ -155,14 +155,15 @@ index 0000000000000000000000000000000000000000..20f80ae80de91615ea02f0771f7c020c
|
||||
+}
|
||||
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..a0b4ed7aa0e5227649758b093d3177e461d4cc03
|
||||
index 0000000000000000000000000000000000000000..ef9c294c986df8f1b19df79bdb3f88ab314c561b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/LithiumEntityCollisions.java
|
||||
@@ -0,0 +1,179 @@
|
||||
@@ -0,0 +1,188 @@
|
||||
+package me.jellysquid.mods.lithium.common.entity;
|
||||
+
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import java.util.function.BiConsumer;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Predicate;
|
||||
+import java.util.stream.Stream;
|
||||
@ -191,7 +192,7 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+ return Stream.empty();
|
||||
+ }
|
||||
+
|
||||
+ return Producer.asStream(getBlockCollisionProducerAABB(world, entity, box).map(VoxelShapes::of));
|
||||
+ return Producer.asStream(getBlockCollisionProducer(world, entity, box));
|
||||
+ }
|
||||
+
|
||||
+ public static void fillBlockCollisionsList(ICollisionAccess world, List<AxisAlignedBB> filled, Entity entity, AxisAlignedBB box) {
|
||||
@ -199,16 +200,20 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Producer.fillList(getBlockCollisionProducerAABB(world, entity, box), filled);
|
||||
+ Producer.fillList2(
|
||||
+ getBlockCollisionProducer(world, entity, box),
|
||||
+ filled,
|
||||
+ (voxelShape, axisAlignedBBS) -> VoxelShapes.addBoxesToIfIntersects(voxelShape, box, axisAlignedBBS)
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ public static Producer<AxisAlignedBB> getBlockCollisionProducerAABB(ICollisionAccess world, Entity entity, AxisAlignedBB box) {
|
||||
+ public static Producer<VoxelShape> getBlockCollisionProducer(ICollisionAccess world, Entity entity, AxisAlignedBB box) {
|
||||
+ final ChunkAwareBlockCollisionSweeper sweeper = new ChunkAwareBlockCollisionSweeper(world, entity, box);
|
||||
+
|
||||
+ return consumer -> {
|
||||
+ VoxelShape shape = sweeper.getNextCollidedShape();
|
||||
+ if (shape != null) {
|
||||
+ consumer.accept(shape.getBoundingBox());
|
||||
+ consumer.accept(shape);
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
@ -252,7 +257,7 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+ return Stream.empty();
|
||||
+ }
|
||||
+
|
||||
+ return Producer.asStream(getEntityCollisionProducer(view, entity, box.grow(EPSILON), predicate, false).map(VoxelShapes::of));
|
||||
+ return Producer.asStream(getEntityCollisionProducer(view, entity, box.grow(EPSILON), predicate, false));
|
||||
+ }
|
||||
+
|
||||
+ public static void fillEntityCollisionsList(IEntityAccess view, Entity entity, List<AxisAlignedBB> filled, AxisAlignedBB box, boolean loadChunks) {
|
||||
@ -260,7 +265,11 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Producer.fillList(getEntityCollisionProducer(view, entity, box.grow(EPSILON), EntityFilter.getFilter(entity), loadChunks), filled);
|
||||
+ Producer.fillList2(
|
||||
+ getEntityCollisionProducer(view, entity, box.grow(EPSILON), EntityFilter.getFilter(entity), loadChunks),
|
||||
+ filled,
|
||||
+ (voxelShape, axisAlignedBBS) -> axisAlignedBBS.add(voxelShape.getBoundingBox())
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
@ -268,12 +277,12 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+ * Re-implements the function named above without stream code or unnecessary allocations. This can provide a small
|
||||
+ * boost in some situations (such as heavy entity crowding) and reduces the allocation rate significantly.
|
||||
+ */
|
||||
+ public static Producer<AxisAlignedBB> getEntityCollisionProducer(IEntityAccess view, Entity entity, AxisAlignedBB box, Predicate<Entity> predicate, boolean loadChunks) {
|
||||
+ return new Producer<AxisAlignedBB>() {
|
||||
+ public static Producer<VoxelShape> getEntityCollisionProducer(IEntityAccess view, Entity entity, AxisAlignedBB box, Predicate<Entity> predicate, boolean loadChunks) {
|
||||
+ return new Producer<VoxelShape>() {
|
||||
+ private Iterator<Entity> it;
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean computeNext(Consumer<? super AxisAlignedBB> consumer) {
|
||||
+ public boolean computeNext(Consumer<? super VoxelShape> consumer) {
|
||||
+ if (it == null) {
|
||||
+ /*
|
||||
+ * In case entity's class is overriding method_30949, all types of entities may be (=> are assumed to be) required.
|
||||
@ -298,7 +307,7 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+ }
|
||||
+
|
||||
+ if (consumer != null) {
|
||||
+ consumer.accept(otherEntity.getBoundingBox());
|
||||
+ consumer.accept(VoxelShapes.of(otherEntity.getBoundingBox()));
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
@ -340,10 +349,10 @@ index 0000000000000000000000000000000000000000..a0b4ed7aa0e5227649758b093d3177e4
|
||||
+}
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..508fe7cf5281cff7528b90e584c17e73fc5a2388
|
||||
index 0000000000000000000000000000000000000000..7ed343cfb3130446c85dab2ca04d60f91e2c94fb
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
|
||||
@@ -0,0 +1,279 @@
|
||||
@@ -0,0 +1,278 @@
|
||||
+package me.jellysquid.mods.lithium.common.entity.movement;
|
||||
+
|
||||
+import me.jellysquid.mods.lithium.common.entity.LithiumEntityCollisions;
|
||||
@ -408,7 +417,6 @@ index 0000000000000000000000000000000000000000..508fe7cf5281cff7528b90e584c17e73
|
||||
+ public ChunkAwareBlockCollisionSweeper(ICollisionAccess view, Entity entity, AxisAlignedBB box) {
|
||||
+ this.box = box;
|
||||
+ this.shape = VoxelShapes.of(box);
|
||||
+ // todo: ivan, make obfhelpers
|
||||
+ this.context = entity == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a(entity);
|
||||
+ this.view = view;
|
||||
+ this.entity = entity;
|
||||
@ -625,16 +633,16 @@ index 0000000000000000000000000000000000000000..508fe7cf5281cff7528b90e584c17e73
|
||||
+}
|
||||
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1ec2b7a9e0062ed4d45786167bd6c71b588da4d7
|
||||
index 0000000000000000000000000000000000000000..e1bd0d9282533b0236eb18c7287e9c0de40a7a6f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Producer.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,88 @@
|
||||
+package me.jellysquid.mods.lithium.common.util;
|
||||
+
|
||||
+import java.util.Comparator;
|
||||
+import java.util.List;
|
||||
+import java.util.Spliterator;
|
||||
+import java.util.Spliterators;
|
||||
+import java.util.function.BiConsumer;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Function;
|
||||
+import java.util.stream.Stream;
|
||||
@ -688,6 +696,28 @@ index 0000000000000000000000000000000000000000..1ec2b7a9e0062ed4d45786167bd6c71b
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // WARNING: does not check contains, you have to do that in the add function
|
||||
+ static <T, R> void fillList2(Producer<T> producer, List<R> list, BiConsumer<T, List<R>> addFunction) {
|
||||
+ HoldingConsumer<T> consumer = new HoldingConsumer<>();
|
||||
+ while (producer.computeNext(consumer)) {
|
||||
+ T value = consumer.getValue();
|
||||
+ if (value == null) { continue; }
|
||||
+ addFunction.accept(value, list);
|
||||
+ }
|
||||
+ if (!list.isEmpty()) {
|
||||
+ boolean allComparable = true;
|
||||
+ for (R value : list) {
|
||||
+ if (!(value instanceof Comparable)) {
|
||||
+ allComparable = false;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (allComparable) {
|
||||
+ list.sort((o1, o2) -> ((Comparable<R>)o1).compareTo(o2));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ Producer<?> EMPTY_PRODUCER = consumer -> false;
|
||||
+
|
||||
+ @SuppressWarnings("unchecked")
|
||||
@ -1057,6 +1087,20 @@ index fbb36229ce936e323619457b618627254cc2ade8..9b7e6d747b366f5967754f1a37ee362a
|
||||
int size = entities.size();
|
||||
sum += size;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
|
||||
index f9a1f5e92a7559a50dfb72d7455a8fc03dbad25f..3094ce00b3fa5b266f5d0ad0875f160e80c62e18 100644
|
||||
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
|
||||
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
|
||||
@@ -40,7 +40,9 @@ public final class VoxelShapes {
|
||||
if (shape instanceof com.tuinity.tuinity.voxel.AABBVoxelShape) {
|
||||
com.tuinity.tuinity.voxel.AABBVoxelShape shapeCasted = (com.tuinity.tuinity.voxel.AABBVoxelShape)shape;
|
||||
if (shapeCasted.aabb.voxelShapeIntersect(aabb)) {
|
||||
+ if (!list.contains(shapeCasted.aabb)) { // Yatopia start - make sure it doesn't contain already
|
||||
list.add(shapeCasted.aabb);
|
||||
+ } // Yatopia end
|
||||
}
|
||||
} else if (shape instanceof VoxelShapeArray) {
|
||||
VoxelShapeArray shapeCasted = (VoxelShapeArray)shape;
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 6610d2f0f852a2af93ab9a61d69a6862d11f1b19..619509cdb60c6236640fa9b85e9902235fa5aa27 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
|
@ -33,10 +33,10 @@ index 700660dd93b3090334bb3033d5f5fdd6ab684744..fd34dffa63995c1fc277eac28eb1cd23
|
||||
return this.a(EnumAxisCycle.a(enumdirection_enumaxis, EnumDirection.EnumAxis.X), axisalignedbb, d0);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
|
||||
index f9a1f5e92a7559a50dfb72d7455a8fc03dbad25f..ad53ee24717e4ceb857b8132bc9c147cf2317190 100644
|
||||
index 3094ce00b3fa5b266f5d0ad0875f160e80c62e18..10060c9a87ceb35b06bc00430cd4aceac1b6600f 100644
|
||||
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
|
||||
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
|
||||
@@ -276,6 +276,21 @@ public final class VoxelShapes {
|
||||
@@ -278,6 +278,21 @@ public final class VoxelShapes {
|
||||
return 0.0D;
|
||||
} else {
|
||||
EnumAxisCycle enumaxiscycle1 = enumaxiscycle.a();
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Add IntelliJ IDEA runnable
|
||||
|
||||
diff --git a/.run/Yatopia.run.xml b/.run/Yatopia.run.xml
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b387d63ce699a54d09bf5109e6439b2db8f26805
|
||||
index 0000000000000000000000000000000000000000..8bc8c24cc51f8cae8c44083b977772945eac51dd
|
||||
--- /dev/null
|
||||
+++ b/.run/Yatopia.run.xml
|
||||
@@ -0,0 +1,23 @@
|
||||
@ -26,8 +26,8 @@ index 0000000000000000000000000000000000000000..b387d63ce699a54d09bf5109e6439b2d
|
||||
+ <option name="vmParameters" />
|
||||
+ <option name="workingDirectory" />
|
||||
+ </selectedOptions>
|
||||
+ <option name="VM_PARAMETERS" value="-Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true" />
|
||||
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../testserver" />
|
||||
+ <option name="VM_PARAMETERS" value="-Xms2G -Xmx2G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true" />
|
||||
+ <option name="WORKING_DIRECTORY" value="testserver" />
|
||||
+ <method v="2">
|
||||
+ <option name="MakeProject" enabled="true" />
|
||||
+ </method>
|
||||
|
Loading…
Reference in New Issue
Block a user