mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 12:13:54 -07:00
Update patches to handle vineflower decompiler (#10406)
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
This commit is contained in:
@@ -23,11 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
@Override
|
||||
public final void tickOrStop(ServerLevel world, E entity, long time) {
|
||||
- this.behaviors.stream().filter((task) -> {
|
||||
- return task.getStatus() == Behavior.Status.RUNNING;
|
||||
- }).forEach((task) -> {
|
||||
- task.tickOrStop(world, entity, time);
|
||||
- });
|
||||
- this.behaviors.stream().filter(task -> task.getStatus() == Behavior.Status.RUNNING).forEach(task -> task.tickOrStop(world, entity, time));
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
+ for (final BehaviorControl<? super E> task : this.behaviors) {
|
||||
+ if (task.getStatus() == Behavior.Status.RUNNING) {
|
||||
@@ -35,18 +31,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Perf: Remove streams from hot code
|
||||
if (this.behaviors.stream().noneMatch((task) -> {
|
||||
return task.getStatus() == Behavior.Status.RUNNING;
|
||||
})) {
|
||||
if (this.behaviors.stream().noneMatch(task -> task.getStatus() == Behavior.Status.RUNNING)) {
|
||||
this.doStop(world, entity, time);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E>
|
||||
@Override
|
||||
public final void doStop(ServerLevel world, E entity, long time) {
|
||||
this.status = Behavior.Status.STOPPED;
|
||||
- this.behaviors.stream().filter((task) -> {
|
||||
- return task.getStatus() == Behavior.Status.RUNNING;
|
||||
- }).forEach((task) -> {
|
||||
- task.doStop(world, entity, time);
|
||||
- });
|
||||
- this.behaviors.stream().filter(task -> task.getStatus() == Behavior.Status.RUNNING).forEach(task -> task.doStop(world, entity, time));
|
||||
- this.exitErasedMemories.forEach(entity.getBrain()::eraseMemory);
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
+ for (final BehaviorControl<? super E> task : this.behaviors) {
|
||||
@@ -68,11 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
@Override
|
||||
- public <E extends LivingEntity> void apply(Stream<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) {
|
||||
- tasks.filter((task) -> {
|
||||
- return task.getStatus() == Behavior.Status.STOPPED;
|
||||
- }).filter((task) -> {
|
||||
- return task.tryStart(world, entity, time);
|
||||
- }).findFirst();
|
||||
- tasks.filter(task -> task.getStatus() == Behavior.Status.STOPPED).filter(task -> task.tryStart(world, entity, time)).findFirst();
|
||||
+ public <E extends LivingEntity> void apply(ShufflingList<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) {
|
||||
+ for (final BehaviorControl<? super E> task : tasks) {
|
||||
+ if (task.getStatus() == Behavior.Status.STOPPED && task.tryStart(world, entity, time)) {
|
||||
@@ -86,11 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
@Override
|
||||
- public <E extends LivingEntity> void apply(Stream<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) {
|
||||
- tasks.filter((task) -> {
|
||||
- return task.getStatus() == Behavior.Status.STOPPED;
|
||||
- }).forEach((task) -> {
|
||||
- task.tryStart(world, entity, time);
|
||||
- });
|
||||
- tasks.filter(task -> task.getStatus() == Behavior.Status.STOPPED).forEach(task -> task.tryStart(world, entity, time));
|
||||
+ public <E extends LivingEntity> void apply(ShufflingList<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) {
|
||||
+ for (final BehaviorControl<? super E> task : tasks) {
|
||||
+ if (task.getStatus() == Behavior.Status.STOPPED) {
|
||||
@@ -110,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
@@ -0,0 +0,0 @@ public class GossipContainer {
|
||||
});
|
||||
return this.gossips.entrySet().stream().flatMap(entry -> entry.getValue().unpack(entry.getKey()));
|
||||
}
|
||||
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
@@ -134,23 +118,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
@@ -0,0 +0,0 @@ public class GossipContainer {
|
||||
}
|
||||
|
||||
public <T> T store(DynamicOps<T> ops) {
|
||||
- return GossipContainer.GossipEntry.LIST_CODEC.encodeStart(ops, this.unpack().toList()).resultOrPartial((error) -> {
|
||||
+ return GossipContainer.GossipEntry.LIST_CODEC.encodeStart(ops, this.decompress()).resultOrPartial((error) -> { // Paper - Perf: Remove streams from hot code
|
||||
LOGGER.warn("Failed to serialize gossips: {}", (Object)error);
|
||||
}).orElseGet(ops::emptyList);
|
||||
return GossipContainer.GossipEntry.LIST_CODEC
|
||||
- .encodeStart(ops, this.unpack().toList())
|
||||
+ .encodeStart(ops, this.decompress()) // Paper - Perf: Remove streams from hot code
|
||||
.resultOrPartial(error -> LOGGER.warn("Failed to serialize gossips: {}", error))
|
||||
.orElseGet(ops::emptyList);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class GossipContainer {
|
||||
final Object2IntMap<GossipType> entries = new Object2IntOpenHashMap<>();
|
||||
|
||||
public int weightedValue(Predicate<GossipType> gossipTypeFilter) {
|
||||
- return this.entries.object2IntEntrySet().stream().filter((entry) -> {
|
||||
- return gossipTypeFilter.test(entry.getKey());
|
||||
- }).mapToInt((entry) -> {
|
||||
- return entry.getIntValue() * (entry.getKey()).weight;
|
||||
- }).sum();
|
||||
- return this.entries
|
||||
- .object2IntEntrySet()
|
||||
- .stream()
|
||||
- .filter(entry -> gossipTypeFilter.test(entry.getKey()))
|
||||
- .mapToInt(entry -> entry.getIntValue() * entry.getKey().weight)
|
||||
- .sum();
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
+ int weight = 0;
|
||||
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
||||
@@ -176,18 +161,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
|
||||
@@ -0,0 +0,0 @@ public class NearestItemSensor extends Sensor<Mob> {
|
||||
@Override
|
||||
protected void doTick(ServerLevel world, Mob entity) {
|
||||
Brain<?> brain = entity.getBrain();
|
||||
List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0D, 16.0D, 32.0D), (itemEntity) -> {
|
||||
- return true;
|
||||
+ return itemEntity.closerThan(entity, MAX_DISTANCE_TO_WANTED_ITEM) && entity.wantsToPickUp(itemEntity.getItem()); // Paper - Perf: Move predicate into getEntities
|
||||
});
|
||||
- List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> true);
|
||||
+ List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> itemEntity.closerThan(entity, MAX_DISTANCE_TO_WANTED_ITEM) && entity.wantsToPickUp(itemEntity.getItem())); // Paper - Perf: Move predicate into getEntities
|
||||
list.sort(Comparator.comparingDouble(entity::distanceToSqr));
|
||||
- Optional<ItemEntity> optional = list.stream().filter((itemEntity) -> {
|
||||
- return entity.wantsToPickUp(itemEntity.getItem());
|
||||
- }).filter((itemEntity) -> {
|
||||
- return itemEntity.closerThan(entity, 32.0D);
|
||||
- }).filter(entity::hasLineOfSight).findFirst();
|
||||
- Optional<ItemEntity> optional = list.stream()
|
||||
- .filter(itemEntity -> entity.wantsToPickUp(itemEntity.getItem()))
|
||||
- .filter(itemEntity -> itemEntity.closerThan(entity, 32.0))
|
||||
- .filter(entity::hasLineOfSight)
|
||||
- .findFirst();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional);
|
||||
+ // Paper start - Perf: remove streams from hot code
|
||||
+ ItemEntity nearest = null;
|
||||
@@ -209,35 +193,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
int j = pos.getMinBlockZ();
|
||||
ObjectList<Beardifier.Rigid> objectList = new ObjectArrayList<>(10);
|
||||
ObjectList<JigsawJunction> objectList2 = new ObjectArrayList<>(32);
|
||||
- world.startsForStructure(pos, (structure) -> {
|
||||
- world.startsForStructure(pos, structure -> structure.terrainAdaptation() != TerrainAdjustment.NONE)
|
||||
- .forEach(
|
||||
- start -> {
|
||||
+ // Paper start - Perf: Remove streams from hot code
|
||||
+ for (net.minecraft.world.level.levelgen.structure.StructureStart start : world.startsForStructure(pos, (structure) -> {
|
||||
return structure.terrainAdaptation() != TerrainAdjustment.NONE;
|
||||
- }).forEach((start) -> {
|
||||
+ return structure.terrainAdaptation() != TerrainAdjustment.NONE;
|
||||
+ })) { // Paper end - Perf: Remove streams from hot code
|
||||
TerrainAdjustment terrainAdjustment = start.getStructure().terrainAdaptation();
|
||||
TerrainAdjustment terrainAdjustment = start.getStructure().terrainAdaptation();
|
||||
|
||||
for(StructurePiece structurePiece : start.getPieces()) {
|
||||
for (StructurePiece structurePiece : start.getPieces()) {
|
||||
@@ -0,0 +0,0 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
|
||||
}
|
||||
|
||||
for(JigsawJunction jigsawJunction : poolElementStructurePiece.getJunctions()) {
|
||||
- int i = jigsawJunction.getSourceX();
|
||||
- int j = jigsawJunction.getSourceZ();
|
||||
- if (i > i - 12 && j > j - 12 && i < i + 15 + 12 && j < j + 15 + 12) {
|
||||
+ // Paper start - decompile fix
|
||||
+ int i2 = jigsawJunction.getSourceX();
|
||||
+ int j2 = jigsawJunction.getSourceZ();
|
||||
+ if (i2 > i - 12 && j2 > j - 12 && i2 < i + 15 + 12 && j2 < j + 15 + 12) {
|
||||
+ // Paper end - decompile fix
|
||||
objectList2.add(jigsawJunction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
|
||||
}
|
||||
}
|
||||
|
||||
- });
|
||||
}
|
||||
- }
|
||||
- );
|
||||
+ } // Paper - Perf: Remove streams from hot code
|
||||
return new Beardifier(objectList.iterator(), objectList2.iterator());
|
||||
}
|
||||
|
Reference in New Issue
Block a user