mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
more work uwu
This commit is contained in:
parent
97f581f459
commit
52bc694983
@ -1,153 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aikar <aikar@aikar.co>
|
|
||||||
Date: Mon, 6 Jul 2020 18:36:41 -0400
|
|
||||||
Subject: [PATCH] Fix Concurrency issue in WeightedList
|
|
||||||
|
|
||||||
if multiple threads from worldgen sort at same time, it will crash.
|
|
||||||
So make a copy of the list for sorting purposes.
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
|
||||||
@@ -0,0 +0,0 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
|
||||||
private final Set<MemoryModuleType<?>> exitErasedMemories;
|
|
||||||
private final GateBehavior.OrderPolicy orderPolicy;
|
|
||||||
private final GateBehavior.RunningPolicy runningPolicy;
|
|
||||||
- private final WeightedList<Behavior<? super E>> behaviors = new WeightedList<>();
|
|
||||||
+ private final WeightedList<Behavior<? super E>> behaviors = new WeightedList<>(false); // Paper - don't use a clone
|
|
||||||
|
|
||||||
public GateBehavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState, Set<MemoryModuleType<?>> memoriesToForgetWhenStopped, GateBehavior.OrderPolicy order, GateBehavior.RunningPolicy runMode, List<Pair<Behavior<? super E>, Integer>> tasks) {
|
|
||||||
super(requiredMemoryState);
|
|
||||||
@@ -0,0 +0,0 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
|
||||||
}).forEach((behavior) -> {
|
|
||||||
behavior.g(world, entity, time);
|
|
||||||
});
|
|
||||||
- Set set = this.exitErasedMemories;
|
|
||||||
Brain behaviorcontroller = entity.getBrain();
|
|
||||||
|
|
||||||
- set.forEach(behaviorcontroller::removeMemory);
|
|
||||||
+ this.exitErasedMemories.forEach(behaviorcontroller::eraseMemory); // Paper - decomp fix
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@@ -0,0 +0,0 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
|
||||||
static enum OrderPolicy {
|
|
||||||
|
|
||||||
ORDERED((weightedlist) -> {
|
|
||||||
- }), SHUFFLED(WeightedList::a);
|
|
||||||
+ }), SHUFFLED(WeightedList::shuffle);
|
|
||||||
|
|
||||||
private final Consumer<WeightedList<?>> consumer;
|
|
||||||
|
|
||||||
- private OrderPolicy(Consumer consumer) {
|
|
||||||
+ private OrderPolicy(Consumer<WeightedList<?>> consumer) { // Paper - decomp fix
|
|
||||||
this.consumer = consumer;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java
|
|
||||||
@@ -0,0 +0,0 @@ import com.mojang.serialization.Codec;
|
|
||||||
import com.mojang.serialization.DataResult;
|
|
||||||
import com.mojang.serialization.Dynamic;
|
|
||||||
import com.mojang.serialization.DynamicOps;
|
|
||||||
-import com.mojang.serialization.OptionalDynamic;
|
|
||||||
+
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
@@ -0,0 +0,0 @@ import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class WeightedList<U> {
|
|
||||||
|
|
||||||
- protected final List<WeightedList.WeightedEntry<U>> entries;
|
|
||||||
+ protected final List<WeightedList.WeightedEntry<U>> list; // Paper - decompile conflict
|
|
||||||
private final Random random;
|
|
||||||
+ private final boolean isUnsafe; // Paper
|
|
||||||
|
|
||||||
- public WeightedList() {
|
|
||||||
- this(Lists.newArrayList());
|
|
||||||
+ // Paper start - add useClone option
|
|
||||||
+ public WeightedList() { this(true); }
|
|
||||||
+ public WeightedList(boolean isUnsafe) {
|
|
||||||
+ this(Lists.newArrayList(), isUnsafe);
|
|
||||||
}
|
|
||||||
|
|
||||||
- private WeightedList(List<WeightedList.WeightedEntry<U>> entries) {
|
|
||||||
+ private WeightedList(List<WeightedList.WeightedEntry<U>> entries) { this(entries, true); }
|
|
||||||
+ private WeightedList(List<WeightedList.WeightedEntry<U>> list, boolean isUnsafe) {
|
|
||||||
+ this.isUnsafe = isUnsafe;
|
|
||||||
+ // Paper end
|
|
||||||
this.random = new Random();
|
|
||||||
- this.entries = Lists.newArrayList(entries);
|
|
||||||
+ this.list = Lists.newArrayList(list); // Paper - decompile conflict
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <U> Codec<WeightedList<U>> codec(Codec<U> codec) {
|
|
||||||
- return WeightedList.entries.a(codec).listOf().xmap(WeightedList::new, (weightedlist) -> {
|
|
||||||
- return weightedlist.a;
|
|
||||||
+ return WeightedList.WeightedEntry.codec(codec).listOf().xmap(WeightedList::new, (weightedlist) -> { // Paper - decompile conflict
|
|
||||||
+ return weightedlist.list; // Paper - decompile conflict
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeightedList<U> add(U item, int weight) {
|
|
||||||
- this.entries.add(new WeightedList.WeightedEntry<>(item, weight));
|
|
||||||
+ this.list.add(new WeightedList.WeightedEntry<>(item, weight)); // Paper - decompile conflict
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class WeightedList<U> {
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeightedList<U> shuffle(Random random) {
|
|
||||||
- this.entries.forEach((weightedlist_a) -> {
|
|
||||||
- weightedlist_a.setRandom(random.nextFloat());
|
|
||||||
- });
|
|
||||||
- this.entries.sort(Comparator.comparingDouble((object) -> {
|
|
||||||
- return ((WeightedList.WeightedEntry) object).getRandWeight();
|
|
||||||
- }));
|
|
||||||
- return this;
|
|
||||||
+ // Paper start - make concurrent safe, work off a clone of the list
|
|
||||||
+ List<WeightedList.WeightedEntry<U>> list = isUnsafe ? new java.util.ArrayList<WeightedList.WeightedEntry<U>>(this.list) : this.list;
|
|
||||||
+ list.forEach((weightedlist_a) -> weightedlist_a.setRandom(random.nextFloat()));
|
|
||||||
+ list.sort(Comparator.comparingDouble(WeightedEntry::getRandWeight));
|
|
||||||
+ return isUnsafe ? new WeightedList<>(list, isUnsafe) : this;
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
- return this.entries.isEmpty();
|
|
||||||
+ return this.list.isEmpty(); // Paper - decompile conflict
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stream<U> stream() {
|
|
||||||
- return this.entries.stream().map(WeightedList.entries::a);
|
|
||||||
+ return this.list.stream().map(WeightedList.WeightedEntry::getData); // Paper - decompile conflict
|
|
||||||
}
|
|
||||||
|
|
||||||
public U getOne(Random random) {
|
|
||||||
@@ -0,0 +0,0 @@ public class WeightedList<U> {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
- return "WeightedList[" + this.entries + "]";
|
|
||||||
+ return "WeightedList[" + this.list + "]"; // Paper - decompile conflict
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class WeightedEntry<T> {
|
|
||||||
@@ -0,0 +0,0 @@ public class WeightedList<U> {
|
|
||||||
return new Codec<WeightedList.WeightedEntry<E>>() {
|
|
||||||
public <T> DataResult<Pair<WeightedList.WeightedEntry<E>, T>> decode(DynamicOps<T> dynamicops, T t0) {
|
|
||||||
Dynamic<T> dynamic = new Dynamic(dynamicops, t0);
|
|
||||||
- OptionalDynamic optionaldynamic = dynamic.get("data");
|
|
||||||
- Codec codec1 = codec;
|
|
||||||
-
|
|
||||||
- codec.getClass();
|
|
||||||
- return optionaldynamic.flatMap(codec1::parse).map((object) -> {
|
|
||||||
+ return dynamic.get("data").flatMap(codec::parse).map((object) -> { // Paper - decompile error
|
|
||||||
return new WeightedList.WeightedEntry<>(object, dynamic.get("weight").asInt(1));
|
|
||||||
}).map((weightedlist_a) -> {
|
|
||||||
return Pair.of(weightedlist_a, dynamicops.empty());
|
|
@ -1,143 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Josh Roy <10731363+JRoy@users.noreply.github.com>
|
|
||||||
Date: Mon, 29 Jun 2020 17:03:06 -0400
|
|
||||||
Subject: [PATCH] Remove some streams from structures
|
|
||||||
|
|
||||||
This showed up a lot in the spark profiler, should have a low-medium performance improvement.
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/StructureFeatureManager.java b/src/main/java/net/minecraft/world/level/StructureFeatureManager.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/StructureFeatureManager.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/StructureFeatureManager.java
|
|
||||||
@@ -0,0 +0,0 @@
|
|
||||||
package net.minecraft.world.level;
|
|
||||||
|
|
||||||
import com.mojang.datafixers.DataFixUtils;
|
|
||||||
+import it.unimi.dsi.fastutil.objects.ObjectArrayList; // Paper
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.SectionPos;
|
|
||||||
-import net.minecraft.core.Vec3i;
|
|
||||||
import net.minecraft.server.level.WorldGenRegion;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
|
||||||
import net.minecraft.world.level.chunk.FeatureAccess;
|
|
||||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
|
||||||
+import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
|
||||||
|
|
||||||
public class StructureFeatureManager {
|
|
||||||
|
|
||||||
- private final LevelAccessor level;
|
|
||||||
+ private final LevelAccessor level; public LevelAccessor getLevel() { return level; } // Paper - OBFHELPER
|
|
||||||
private final WorldGenSettings worldGenSettings;
|
|
||||||
|
|
||||||
public StructureFeatureManager(LevelAccessor world, WorldGenSettings options) {
|
|
||||||
@@ -0,0 +0,0 @@ public class StructureFeatureManager {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start - remove structure streams
|
|
||||||
+ public java.util.List<StructureStart<?>> getFeatureStarts(SectionPos sectionPosition, StructureFeature<?> structureGenerator) {
|
|
||||||
+ java.util.List<StructureStart<?>> list = new ObjectArrayList<>();
|
|
||||||
+ for (Long curLong: getLevel().getChunk(sectionPosition.x(), sectionPosition.z(), ChunkStatus.STRUCTURE_REFERENCES).getReferencesForFeature(structureGenerator)) {
|
|
||||||
+ SectionPos sectionPosition1 = SectionPos.of(new ChunkPos(curLong), 0);
|
|
||||||
+ StructureStart<?> structurestart = getStartForFeature(sectionPosition1, structureGenerator, getLevel().getChunk(sectionPosition1.x(), sectionPosition1.z(), ChunkStatus.STRUCTURE_STARTS));
|
|
||||||
+ if (structurestart != null && structurestart.e()) {
|
|
||||||
+ list.add(structurestart);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ return list;
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
@Nullable
|
|
||||||
public StructureStart<?> getStartForFeature(SectionPos pos, StructureFeature<?> feature, FeatureAccess holder) {
|
|
||||||
return holder.getStartForFeature(feature);
|
|
||||||
@@ -0,0 +0,0 @@ public class StructureFeatureManager {
|
|
||||||
}
|
|
||||||
|
|
||||||
public StructureStart<?> getStructureAt(BlockPos pos, boolean matchChildren, StructureFeature<?> feature) {
|
|
||||||
- return (StructureStart) DataFixUtils.orElse(this.startsForFeature(SectionPos.of(pos), feature).filter((structurestart) -> {
|
|
||||||
- return structurestart.c().b((Vec3i) pos);
|
|
||||||
- }).filter((structurestart) -> {
|
|
||||||
- return !matchChildren || structurestart.d().stream().anyMatch((structurepiece) -> {
|
|
||||||
- return structurepiece.g().b((BaseBlockPosition) blockposition);
|
|
||||||
- });
|
|
||||||
- }).findFirst(), StructureStart.a);
|
|
||||||
+ // Paper start - remove structure streams
|
|
||||||
+ for (StructureStart<?> structurestart : getFeatureStarts(SectionPos.of(pos), feature)) {
|
|
||||||
+ if (structurestart.c().b(pos)) {
|
|
||||||
+ if (!matchChildren) {
|
|
||||||
+ return structurestart;
|
|
||||||
+ }
|
|
||||||
+ for (StructurePiece structurepiece : structurestart.d()) {
|
|
||||||
+ if (structurepiece.g().b(pos)) {
|
|
||||||
+ return structurestart;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ return StructureStart.a;
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spigot start
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
|
||||||
+import net.minecraft.world.level.levelgen.structure.StructureStart;
|
|
||||||
import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder;
|
|
||||||
import net.minecraft.world.level.levelgen.synth.PerlinSimplexNoise;
|
|
||||||
import net.minecraft.world.level.material.FluidState;
|
|
||||||
@@ -0,0 +0,0 @@ public final class Biome {
|
|
||||||
int l1 = j1 << 4;
|
|
||||||
|
|
||||||
try {
|
|
||||||
- structureAccessor.startsForFeature(SectionPos.of(pos), structuregenerator).forEach((structurestart) -> {
|
|
||||||
- structurestart.a(region, structureAccessor, chunkGenerator, random, new BoundingBox(k1, l1, k1 + 15, l1 + 15), new ChunkPos(i1, j1));
|
|
||||||
- });
|
|
||||||
+ // Paper start - remove structure streams
|
|
||||||
+ for (StructureStart<?> structureStart : structureAccessor.getFeatureStarts(SectionPos.of(pos), structuregenerator)) {
|
|
||||||
+ structureStart.a(region, structureAccessor, chunkGenerator, random, new BoundingBox(k1, l1, k1 + 15, l1 + 15), new ChunkPos(i1, j1));
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
} catch (Exception exception) {
|
|
||||||
CrashReport crashreport = CrashReport.forThrowable(exception, "Feature placement");
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.feature.structures.StructureTemplatePo
|
|
||||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
|
||||||
+import net.minecraft.world.level.levelgen.structure.StructureStart;
|
|
||||||
import net.minecraft.world.level.levelgen.synth.ImprovedNoise;
|
|
||||||
import net.minecraft.world.level.levelgen.synth.PerlinNoise;
|
|
||||||
import net.minecraft.world.level.levelgen.synth.PerlinSimplexNoise;
|
|
||||||
@@ -0,0 +0,0 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
StructureFeature<?> structuregenerator = (StructureFeature) iterator.next();
|
|
||||||
|
|
||||||
- accessor.startsForFeature(SectionPos.of(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) -> {
|
|
||||||
+ for (StructureStart<?> structurestart : accessor.getFeatureStarts(SectionPos.of(chunkcoordintpair, 0), structuregenerator)) { // Paper - remove structure streams
|
|
||||||
Iterator iterator1 = structurestart.d().iterator();
|
|
||||||
|
|
||||||
while (iterator1.hasNext()) {
|
|
||||||
@@ -0,0 +0,0 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- });
|
|
||||||
+ } // Paper - remove structure streams
|
|
||||||
}
|
|
||||||
|
|
||||||
double[][][] adouble = new double[2][this.chunkCountZ + 1][this.chunkCountY + 1];
|
|
@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start
|
public int getCost() {
|
||||||
diff --git a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
diff --git a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
--- a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||||
@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 3); // Paper
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 3); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void registerUpdateListener(Runnable inventoryChangeListener) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
diff --git a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
--- a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||||
return this.wasTouchingWater;
|
return this.wasTouchingWater;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private boolean isInBubbleColumn() {
|
private boolean isInBubbleColumn() {
|
||||||
return this.level.getBlockState(this.blockPosition()).is(Blocks.BUBBLE_COLUMN);
|
return this.level.getBlockState(this.blockPosition()).is(Blocks.BUBBLE_COLUMN);
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||||
return this.isInWater() || this.isInRain() || this.isInBubbleColumn();
|
return this.isInWater() || this.isInRain() || this.isInBubbleColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
public boolean isInWaterOrBubble() {
|
public boolean isInWaterOrBubble() {
|
||||||
return this.isInWater() || this.isInBubbleColumn();
|
return this.isInWater() || this.isInBubbleColumn();
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||||
return this.fluidOnEyes == tag;
|
return this.fluidOnEyes == fluidTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ public final boolean isInLava() { return isInLava(); } // Paper - OBFHELPER
|
+ public final boolean isInLava() { return isInLava(); } // Paper - OBFHELPER
|
@ -4,28 +4,6 @@ Date: Wed, 29 Apr 2020 02:10:32 +0200
|
|||||||
Subject: [PATCH] Allow delegation to vanilla chunk gen
|
Subject: [PATCH] Allow delegation to vanilla chunk gen
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
||||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
|
||||||
public class UpgradeData {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
- public static final UpgradeData EMPTY = new UpgradeData();
|
|
||||||
+ public static final UpgradeData EMPTY = new UpgradeData(); public static UpgradeData getEmptyConverter() { return EMPTY; } // Paper - obfhelper
|
|
||||||
private static final Direction8[] DIRECTIONS = Direction8.values();
|
|
||||||
private final EnumSet<Direction8> sides;
|
|
||||||
private final int[][] index;
|
|
||||||
@@ -0,0 +0,0 @@ public class UpgradeData {
|
|
||||||
if ((Integer) iblockdata.getValue(BlockStateProperties.DISTANCE) >= j) {
|
|
||||||
world.setBlock(blockposition, (BlockState) iblockdata.setValue(BlockStateProperties.DISTANCE, j), 18);
|
|
||||||
if (i != 7) {
|
|
||||||
- Direction[] aenumdirection = null.f;
|
|
||||||
+ Direction[] aenumdirection = DIRECTIONS; // Paper - decomp fix
|
|
||||||
int k = aenumdirection.length;
|
|
||||||
|
|
||||||
for (int l = 0; l < k; ++l) {
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@ -68,16 +46,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
||||||
@@ -0,0 +0,0 @@ import org.bukkit.material.MaterialData;
|
@@ -0,0 +0,0 @@ import org.bukkit.material.MaterialData;
|
||||||
*/
|
|
||||||
public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
||||||
|
private final int minHeight;
|
||||||
private final int maxHeight;
|
private final int maxHeight;
|
||||||
- private final LevelChunkSection[] sections;
|
- private final LevelChunkSection[] sections;
|
||||||
+ private LevelChunkSection[] sections; // Paper - remove final
|
+ private LevelChunkSection[] sections; // Paper - remove final
|
||||||
private Set<BlockPos> tiles;
|
private Set<BlockPos> tiles;
|
||||||
private World world; // Paper - Anti-Xray - Add world
|
|
||||||
|
|
||||||
|
public CraftChunkData(World world) {
|
||||||
@@ -0,0 +0,0 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
@@ -0,0 +0,0 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
||||||
return sections;
|
return this.sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
@ -87,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
Set<BlockPos> getTiles() {
|
Set<BlockPos> getTiles() {
|
||||||
return tiles;
|
return this.tiles;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
@ -11,23 +11,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
||||||
@@ -0,0 +0,0 @@ public class StopAttackingIfTargetInvalid<E extends Mob> extends Behavior<E> {
|
@@ -0,0 +0,0 @@ public class StopAttackingIfTargetInvalid<E extends Mob> extends Behavior<E> {
|
||||||
|
LivingEntity entityliving = this.getAttackTarget(entity);
|
||||||
|
|
||||||
protected void start(ServerLevel world, E entity, long time) {
|
if (!entity.canAttack(entityliving)) {
|
||||||
if (isTiredOfTryingToReachTarget((LivingEntity) entity)) {
|
|
||||||
- this.clearAttackTarget(entity);
|
- this.clearAttackTarget(entity);
|
||||||
+ this.d(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // Paper
|
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper
|
||||||
|
} else if (StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget((LivingEntity) entity)) {
|
||||||
|
- this.clearAttackTarget(entity);
|
||||||
|
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // Paper
|
||||||
} else if (this.isCurrentTargetDeadOrRemoved(entity)) {
|
} else if (this.isCurrentTargetDeadOrRemoved(entity)) {
|
||||||
- this.clearAttackTarget(entity);
|
- this.clearAttackTarget(entity);
|
||||||
+ this.d(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED); // Paper
|
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED); // Paper
|
||||||
} else if (this.isCurrentTargetInDifferentLevel(entity)) {
|
} else if (this.isCurrentTargetInDifferentLevel(entity)) {
|
||||||
- this.clearAttackTarget(entity);
|
- this.clearAttackTarget(entity);
|
||||||
+ this.d(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_OTHER_LEVEL); // Paper
|
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_OTHER_LEVEL); // Paper
|
||||||
} else if (!EntitySelector.ATTACK_ALLOWED.test(this.getAttackTarget(entity))) {
|
|
||||||
- this.clearAttackTarget(entity);
|
|
||||||
+ this.d(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper
|
|
||||||
} else if (this.stopAttackingWhen.test(this.getAttackTarget(entity))) {
|
} else if (this.stopAttackingWhen.test(this.getAttackTarget(entity))) {
|
||||||
- this.clearAttackTarget(entity);
|
- this.clearAttackTarget(entity);
|
||||||
+ this.d(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper
|
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
return optional.isPresent() && !((LivingEntity) optional.get()).isAlive();
|
return optional.isPresent() && !((LivingEntity) optional.get()).isAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
- private void clearAttackTarget(E entity) {
|
- protected void clearAttackTarget(E entity) {
|
||||||
+ private void d(E e0, EntityTargetEvent.TargetReason reason) {
|
+ protected void clearAttackTarget(E e0, EntityTargetEvent.TargetReason reason) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
- LivingEntity old = entity.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
|
- LivingEntity old = entity.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
|
||||||
- EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entity, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
- EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entity, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
||||||
@ -56,7 +56,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }*/
|
+ }*/
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
- this.onTargetErased.accept(entity);
|
||||||
- entity.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET);
|
- entity.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET);
|
||||||
+ e0.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET);
|
+ this.onTargetErased.accept(e0);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,25 +8,27 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||||
Direction enumdirection = movingobjectpositionblock.getDirection();
|
Direction enumdirection = movingobjectpositionblock.getDirection();
|
||||||
|
|
||||||
+ // Paper start - move check up
|
+ // Paper start - move check up
|
||||||
+ Location eyeLoc = this.getPlayer().getEyeLocation();
|
+ Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
||||||
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
||||||
+ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
+ if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - move check up
|
+ // Paper end - move check up
|
||||||
+
|
+
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
if (blockposition.getY() < this.server.getMaxBuildHeight()) {
|
int i = this.player.level.getMaxBuildHeight();
|
||||||
|
|
||||||
|
if (blockposition.getY() < i) {
|
||||||
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition)) {
|
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition)) {
|
||||||
// CraftBukkit start - Check if we can actually do something over this large a distance
|
// CraftBukkit start - Check if we can actually do something over this large a distance
|
||||||
- Location eyeLoc = this.getPlayer().getEyeLocation();
|
- Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
||||||
- double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
- double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
||||||
- if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
- if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? ServerGamePacketListenerImpl.CREATIVE_PLACE_DISTANCE_SQUARED : ServerGamePacketListenerImpl.SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
||||||
- return;
|
- return;
|
||||||
- }
|
- }
|
||||||
+ // Paper - move check up
|
+ // Paper - move check up
|
@ -11,74 +11,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ public enum ConnectionProtocol {
|
@@ -0,0 +0,0 @@ public enum ConnectionProtocol {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Packet<?> createPacket(int id) {
|
public Packet<?> createPacket(int id, FriendlyByteBuf buf) {
|
||||||
+ if (id < 0 || id >= this.idToConstructor.size()) return null; // Paper
|
+ if (id < 0 || id >= this.idToDeserializer.size()) return null; // Paper
|
||||||
Supplier<? extends Packet<T>> supplier = (Supplier) this.idToConstructor.get(id);
|
Function<FriendlyByteBuf, ? extends Packet<T>> function = this.idToDeserializer.get(id);
|
||||||
|
return function != null ? function.apply(buf) : null;
|
||||||
return supplier != null ? (Packet) supplier.get() : null;
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/network/Varint21FrameDecoder.java b/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
diff --git a/src/main/java/net/minecraft/network/Varint21FrameDecoder.java b/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
--- a/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
||||||
+++ b/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
+++ b/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
||||||
@@ -0,0 +0,0 @@ import java.util.List;
|
@@ -0,0 +0,0 @@ import io.netty.handler.codec.CorruptedFrameException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Varint21FrameDecoder extends ByteToMessageDecoder {
|
public class Varint21FrameDecoder extends ByteToMessageDecoder {
|
||||||
|
|
||||||
+ private final byte[] lenBuf = new byte[3]; // Paper
|
+ private final byte[] lenBuf = new byte[3]; // Paper
|
||||||
public Varint21FrameDecoder() {}
|
@Override
|
||||||
|
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) {
|
||||||
protected void decode(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf, List<Object> list) throws Exception {
|
|
||||||
+ // Paper start - if channel is not active just discard the packet
|
+ // Paper start - if channel is not active just discard the packet
|
||||||
+ if (!channelhandlercontext.channel().isActive()) {
|
+ if (!channelHandlerContext.channel().isActive()) {
|
||||||
+ bytebuf.skipBytes(bytebuf.readableBytes());
|
+ byteBuf.skipBytes(byteBuf.readableBytes());
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
bytebuf.markReaderIndex();
|
byteBuf.markReaderIndex();
|
||||||
- byte[] abyte = new byte[3];
|
|
||||||
+ // Paper start - reuse temporary length buffer
|
+ // Paper start - reuse temporary length buffer
|
||||||
+ byte[] abyte = lenBuf;
|
+ byte[] abyte = lenBuf;
|
||||||
+ java.util.Arrays.fill(abyte, (byte) 0);
|
+ java.util.Arrays.fill(abyte, (byte) 0);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
byte[] bs = new byte[3];
|
||||||
|
|
||||||
for (int i = 0; i < abyte.length; ++i) {
|
for(int i = 0; i < bs.length; ++i) {
|
||||||
if (!bytebuf.isReadable()) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/protocol/Packet.java b/src/main/java/net/minecraft/network/protocol/Packet.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/protocol/Packet.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/protocol/Packet.java
|
|
||||||
@@ -0,0 +0,0 @@ package net.minecraft.network.protocol;
|
|
||||||
|
|
||||||
import io.netty.channel.ChannelFuture; // Paper
|
|
||||||
import java.io.IOException;
|
|
||||||
+import net.minecraft.network.Connection;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.network.PacketListener;
|
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
public interface Packet<T extends PacketListener> {
|
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public interface Packet<T extends PacketListener> {
|
|
||||||
/**
|
|
||||||
* @param player Null if not at PLAY stage yet
|
|
||||||
*/
|
|
||||||
- default void onPacketDispatch(@javax.annotation.Nullable EntityPlayer player) {}
|
|
||||||
+ default void onPacketDispatch(@javax.annotation.Nullable ServerPlayer player) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player Null if not at PLAY stage yet
|
|
||||||
* @param future Can be null if packet was cancelled
|
|
||||||
*/
|
|
||||||
- default void onPacketDispatchFinish(@javax.annotation.Nullable EntityPlayer player, @javax.annotation.Nullable ChannelFuture future) {}
|
|
||||||
+ default void onPacketDispatchFinish(@javax.annotation.Nullable ServerPlayer player, @javax.annotation.Nullable ChannelFuture future) {}
|
|
||||||
default boolean hasFinishListener() { return false; }
|
|
||||||
default boolean isReady() { return true; }
|
|
||||||
default java.util.List<Packet> getExtraPackets() { return null; }
|
|
||||||
- default boolean packetTooLarge(NetworkManager manager) {
|
|
||||||
+ default boolean packetTooLarge(Connection manager) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Paper end
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||||
@ -113,5 +75,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
} else {
|
} else {
|
||||||
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: " + packet);
|
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
||||||
}
|
}
|
@ -8,14 +8,14 @@ diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||||
+++ b/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 @@ import com.mojang.serialization.DynamicOps;
|
@@ -0,0 +0,0 @@ import com.mojang.serialization.Dynamic;
|
||||||
|
import com.mojang.serialization.DynamicOps;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
+import it.unimi.dsi.fastutil.objects.ObjectArrayList; // Paper
|
+import it.unimi.dsi.fastutil.objects.ObjectArrayList; // Paper
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
@@ -0,0 +0,0 @@ public class GossipContainer {
|
@@ -0,0 +0,0 @@ public class GossipContainer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -34,40 +34,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
private Collection<GossipContainer.GossipEntry> selectGossipsForTransfer(Random random, int count) {
|
private Collection<GossipContainer.GossipEntry> selectGossipsForTransfer(Random random, int count) {
|
||||||
- List<GossipContainer.GossipEntry> list = (List) this.unpack().collect(Collectors.toList());
|
- List<GossipContainer.GossipEntry> list = this.unpack().collect(Collectors.toList());
|
||||||
+ List<GossipContainer.GossipEntry> list = decompress(); // Paper - Remove streams from reputation
|
+ List<GossipContainer.GossipEntry> list = decompress(); // Paper - Remove streams from reputation
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
@@ -0,0 +0,0 @@ public class GossipContainer {
|
@@ -0,0 +0,0 @@ public class GossipContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> Dynamic<T> store(DynamicOps<T> dynamicops) {
|
- public <T> Dynamic<T> store(DynamicOps<T> dynamicOps) {
|
||||||
- return new Dynamic(dynamicops, dynamicops.createList(this.unpack().map((reputation_b) -> {
|
- return new Dynamic<>(dynamicOps, dynamicOps.createList(this.unpack().map((gossipEntry) -> {
|
||||||
|
- return gossipEntry.store(dynamicOps);
|
||||||
|
+ public <T> Dynamic<T> store(DynamicOps<T> dynamicops) {
|
||||||
+ return new Dynamic(dynamicops, dynamicops.createList(this.decompress().stream().map((reputation_b) -> {
|
+ return new Dynamic(dynamicops, dynamicops.createList(this.decompress().stream().map((reputation_b) -> {
|
||||||
return reputation_b.store(dynamicops);
|
+ return reputation_b.store(dynamicops);
|
||||||
}).map(Dynamic::getValue)));
|
}).map(Dynamic::getValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public class GossipContainer {
|
@@ -0,0 +0,0 @@ public class GossipContainer {
|
||||||
|
final Object2IntMap<GossipType> entries = new Object2IntOpenHashMap<>();
|
||||||
public static class EntityGossips { // Paper - make public
|
|
||||||
|
|
||||||
- private final Object2IntMap<GossipType> entries;
|
|
||||||
+ private final Object2IntMap<GossipType> entries; private Object2IntMap<GossipType> getEntries() { return entries; } // Paper - OBFHELPER
|
|
||||||
|
|
||||||
public EntityGossips() { // Paper - make public - update CraftVillager setReputation on change
|
|
||||||
this.entries = new Object2IntOpenHashMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int weightedValue(Predicate<GossipType> gossipTypeFilter) {
|
public int weightedValue(Predicate<GossipType> gossipTypeFilter) {
|
||||||
- return this.entries.object2IntEntrySet().stream().filter((entry) -> {
|
- return this.entries.object2IntEntrySet().stream().filter((entry) -> {
|
||||||
- return gossipTypeFilter.test(entry.getKey());
|
- return gossipTypeFilter.test(entry.getKey());
|
||||||
- }).mapToInt((entry) -> {
|
- }).mapToInt((entry) -> {
|
||||||
- return entry.getIntValue() * ((GossipType) entry.getKey()).weight;
|
- return entry.getIntValue() * (entry.getKey()).weight;
|
||||||
- }).sum();
|
- }).sum();
|
||||||
+ // Paper start - Remove streams from reputation
|
+ // Paper start - Remove streams from reputation
|
||||||
+ int weight = 0;
|
+ int weight = 0;
|
||||||
+ for (Object2IntMap.Entry<GossipType> entry : getEntries().object2IntEntrySet()) {
|
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
||||||
+ if (gossipTypeFilter.test(entry.getKey())) {
|
+ if (gossipTypeFilter.test(entry.getKey())) {
|
||||||
+ weight += entry.getIntValue() * entry.getKey().getWeight();
|
+ weight += entry.getIntValue() * entry.getKey().getWeight();
|
||||||
+ }
|
+ }
|
||||||
@ -77,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ public List<GossipContainer.GossipEntry> decompress(UUID uuid) {
|
+ public List<GossipContainer.GossipEntry> decompress(UUID uuid) {
|
||||||
+ List<GossipContainer.GossipEntry> list = new ObjectArrayList<>();
|
+ List<GossipContainer.GossipEntry> list = new ObjectArrayList<>();
|
||||||
+ for (Object2IntMap.Entry<GossipType> entry : getEntries().object2IntEntrySet()) {
|
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
||||||
+ list.add(new GossipContainer.GossipEntry(uuid, entry.getKey(), entry.getIntValue()));
|
+ list.add(new GossipContainer.GossipEntry(uuid, entry.getKey(), entry.getIntValue()));
|
||||||
+ }
|
+ }
|
||||||
+ return list;
|
+ return list;
|
||||||
@ -90,8 +86,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java
|
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java
|
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java
|
||||||
@@ -0,0 +0,0 @@ public enum GossipType {
|
@@ -0,0 +0,0 @@ public enum GossipType {
|
||||||
MAJOR_NEGATIVE("major_negative", -5, 100, 10, 10), MINOR_NEGATIVE("minor_negative", -1, 200, 20, 20), MINOR_POSITIVE("minor_positive", 1, 200, 1, 5), MAJOR_POSITIVE("major_positive", 5, 100, 0, 100), TRADING("trading", 1, 25, 2, 20);
|
public static final int REPUTATION_CHANGE_PER_EVERLASTING_MEMORY = 20;
|
||||||
|
public static final int REPUTATION_CHANGE_PER_TRADE = 2;
|
||||||
public final String id;
|
public final String id;
|
||||||
- public final int weight;
|
- public final int weight;
|
||||||
+ public final int weight; public int getWeight() { return weight; } // Paper - OBFHELPER
|
+ public final int weight; public int getWeight() { return weight; } // Paper - OBFHELPER
|
@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDisplayName() {
|
public boolean hasDisplayName() {
|
||||||
return displayName != null;
|
return this.displayName != null;
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromJSONComponent));
|
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromJSONComponent));
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCustomModelData() {
|
public boolean hasCustomModelData() {
|
||||||
return customModelData != null;
|
return this.customModelData != null;
|
||||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
}
|
}
|
||||||
|
|
@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
try {
|
try {
|
||||||
- ((CommandSourceStack) source).currentCommand = this;
|
- ((CommandSourceStack) source).currentCommand = this;
|
||||||
+ ((CommandSourceStack) source).currentCommand.set(this); // Paper
|
+ ((CommandSourceStack) source).currentCommand.set(this); // Paper
|
||||||
return requirement.test(source);
|
return this.requirement.test(source);
|
||||||
} finally {
|
} finally {
|
||||||
- ((CommandSourceStack) source).currentCommand = null;
|
- ((CommandSourceStack) source).currentCommand = null;
|
||||||
+ ((CommandSourceStack) source).currentCommand.set(null); // Paper
|
+ ((CommandSourceStack) source).currentCommand.set(null); // Paper
|
||||||
@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper start - fix concurrency issue
|
+ // Paper start - fix concurrency issue
|
||||||
+ CommandNode currentCommand = this.currentCommand.get();
|
+ CommandNode currentCommand = this.currentCommand.get();
|
||||||
if (currentCommand != null) {
|
if (currentCommand != null) {
|
||||||
return hasPermission(level, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
|
return this.hasPermission(level, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
@ -8,16 +8,8 @@ diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/ja
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.ListTag;
|
|
||||||
import net.minecraft.nbt.NbtOps;
|
|
||||||
+import net.minecraft.nbt.StringTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.ComponentUtils;
|
|
||||||
@@ -0,0 +0,0 @@ public final class ItemStack {
|
@@ -0,0 +0,0 @@ public final class ItemStack {
|
||||||
list.sort((Comparator<? super Tag>) enchantSorter); // Paper
|
list.sort((Comparator<? super net.minecraft.nbt.Tag>) enchantSorter); // Paper
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
@ -42,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ try {
|
+ try {
|
||||||
+ list.set(index, convert(json));
|
+ list.set(index, convert(json));
|
||||||
+ } catch (JsonParseException e) {
|
+ } catch (JsonParseException e) {
|
||||||
+ list.set(index, StringTag.create(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(new TextComponent(""))));
|
+ list.set(index, net.minecraft.nbt.StringTag.create(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(new TextComponent(""))));
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
@ -50,25 +42,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private StringTag convert(String json) {
|
+ private net.minecraft.nbt.StringTag convert(String json) {
|
||||||
+ Component component = Component.Serializer.jsonToComponent(json);
|
+ Component component = Component.Serializer.jsonToComponent(json);
|
||||||
+ if (component instanceof TextComponent && component.getContents().contains("\u00A7") && component.getSiblings().isEmpty()) {
|
+ if (component instanceof TextComponent && component.getContents().contains("\u00A7") && component.getSiblings().isEmpty()) {
|
||||||
+ // Only convert if the root component is a single comp with legacy in it, don't convert already normal components
|
+ // Only convert if the root component is a single comp with legacy in it, don't convert already normal components
|
||||||
+ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(component.getContents())[0];
|
+ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(component.getContents())[0];
|
||||||
+ }
|
+ }
|
||||||
+ return StringTag.create(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
|
+ return net.minecraft.nbt.StringTag.create(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
|
||||||
+ }
|
+ }
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
public ItemStack(ItemLike item) {
|
public ItemStack(ItemLike item) {
|
||||||
@@ -0,0 +0,0 @@ public final class ItemStack {
|
@@ -0,0 +0,0 @@ public final class ItemStack {
|
||||||
// CraftBukkit start - make defensive copy as this data may be coming from the save thread
|
|
||||||
this.tag = (CompoundTag) nbttagcompound.getCompound("tag").copy();
|
this.tag = (CompoundTag) nbttagcompound.getCompound("tag").copy();
|
||||||
processEnchantOrder(this.tag); // Paper
|
|
||||||
+ processText(); // Paper
|
|
||||||
this.getItem().verifyTagAfterLoad(this.tag);
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
this.processEnchantOrder(this.tag); // Paper
|
||||||
|
+ this.processText(); // Paper
|
||||||
|
this.getItem().verifyTagAfterLoad(this.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +0,0 @@ public final class ItemStack {
|
@@ -0,0 +0,0 @@ public final class ItemStack {
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user