mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
e1adb82073
Minecraft now ticks signs in order to validate the playerWhoMayEdit field. This is a horrible idea, as this means that even waxed signs are ticked for essentially no reason. This moves the logic lazily onto the getter.
284 lines
18 KiB
Diff
284 lines
18 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 30 Mar 2016 19:36:20 -0400
|
|
Subject: [PATCH] MC Dev fixes
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
|
@@ -0,0 +0,0 @@ public class Util {
|
|
}
|
|
|
|
public static <K> Hash.Strategy<K> identityStrategy() {
|
|
- return Util.IdentityStrategy.INSTANCE;
|
|
+ return (Hash.Strategy<K>) Util.IdentityStrategy.INSTANCE; // Paper - decompile fix
|
|
}
|
|
|
|
public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) {
|
|
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
|
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
|
@@ -0,0 +0,0 @@ public class BlockPos extends Vec3i {
|
|
if (this.index == l) {
|
|
return this.endOfData();
|
|
} else {
|
|
- int i = this.index % i;
|
|
- int j = this.index / i;
|
|
- int k = j % j;
|
|
- int l = j / j;
|
|
+ int offsetX = this.index % i; // Paper - decomp fix
|
|
+ int u = this.index / i; // Paper - decomp fix
|
|
+ int offsetY = u % j; // Paper - decomp fix
|
|
+ int offsetZ = u / j; // Paper - decomp fix
|
|
++this.index;
|
|
- return this.cursor.set(startX + i, startY + k, startZ + l);
|
|
+ return this.cursor.set(startX + offsetX, startY + offsetY, startZ + offsetZ); // Paper - decomp fix
|
|
}
|
|
}
|
|
};
|
|
diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
|
+++ b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
|
@@ -0,0 +0,0 @@ public class BuiltInRegistries {
|
|
LOADERS.put(resourceLocation, () -> {
|
|
return initializer.run(registry);
|
|
});
|
|
- WRITABLE_REGISTRY.register(key, registry, lifecycle);
|
|
+ WRITABLE_REGISTRY.register((ResourceKey) key, registry, lifecycle); // Paper - decompile fix
|
|
return registry;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/ConnectionProtocol.java b/src/main/java/net/minecraft/network/ConnectionProtocol.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/network/ConnectionProtocol.java
|
|
+++ b/src/main/java/net/minecraft/network/ConnectionProtocol.java
|
|
@@ -0,0 +0,0 @@ public enum ConnectionProtocol implements BundlerInfo.Provider {
|
|
|
|
public void listAllPackets(Consumer<Class<? extends Packet<?>>> consumer) {
|
|
this.classToId.keySet().stream().filter((type) -> {
|
|
- return type != BundleDelimiterPacket.class;
|
|
+ return !type.equals(BundleDelimiterPacket.class); // Paper - fix of some kind
|
|
}).forEach(consumer);
|
|
this.extraClasses.forEach(consumer);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
|
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
|
@@ -0,0 +0,0 @@ public class ComponentUtils {
|
|
ComponentContents string = text.getContents();
|
|
if (string instanceof TranslatableContents) {
|
|
TranslatableContents translatableContents = (TranslatableContents)string;
|
|
- String string = translatableContents.getKey();
|
|
String string2 = translatableContents.getFallback();
|
|
- return string2 != null || Language.getInstance().has(string);
|
|
+ return string2 != null || Language.getInstance().has(translatableContents.getKey()); // Paper - decompile fix
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java
|
|
+++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
|
|
@@ -0,0 +0,0 @@ public class RegistryDataLoader {
|
|
return new RegistryOps.RegistryInfoLookup() {
|
|
@Override
|
|
public <T> Optional<RegistryOps.RegistryInfo<T>> lookup(ResourceKey<? extends Registry<? extends T>> registryRef) {
|
|
- return Optional.ofNullable(map.get(registryRef));
|
|
+ return Optional.ofNullable((RegistryOps.RegistryInfo<T>) map.get(registryRef)); // Paper - decompile fix
|
|
}
|
|
};
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
PackRepository resourcepackrepository = this.packRepository;
|
|
|
|
Objects.requireNonNull(this.packRepository);
|
|
- return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error
|
|
+ return stream.<Pack>map(resourcepackrepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error // Paper - decompile error // todo: is this needed anymore?
|
|
}, this).thenCompose((immutablelist) -> {
|
|
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/Ticket.java b/src/main/java/net/minecraft/server/level/Ticket.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/level/Ticket.java
|
|
+++ b/src/main/java/net/minecraft/server/level/Ticket.java
|
|
@@ -0,0 +0,0 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
|
|
return i;
|
|
} else {
|
|
int j = Integer.compare(System.identityHashCode(this.type), System.identityHashCode(ticket.type));
|
|
- return j != 0 ? j : this.type.getComparator().compare(this.key, ticket.key);
|
|
+ return j != 0 ? j : this.type.getComparator().compare(this.key, (T)ticket.key); // Paper - decompile fix
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/util/SortedArraySet.java b/src/main/java/net/minecraft/util/SortedArraySet.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/util/SortedArraySet.java
|
|
+++ b/src/main/java/net/minecraft/util/SortedArraySet.java
|
|
@@ -0,0 +0,0 @@ public class SortedArraySet<T> extends AbstractSet<T> {
|
|
}
|
|
|
|
public static <T extends Comparable<T>> SortedArraySet<T> create(int initialCapacity) {
|
|
- return new SortedArraySet<>(initialCapacity, Comparator.naturalOrder());
|
|
+ return new SortedArraySet<>(initialCapacity, Comparator.<T>naturalOrder()); // Paper - decompile fix
|
|
}
|
|
|
|
public static <T> SortedArraySet<T> create(Comparator<T> comparator) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
@@ -0,0 +0,0 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("camelBrain");
|
|
- Brain<?> brain = this.getBrain();
|
|
+ Brain<Camel> brain = (Brain<Camel>) this.getBrain(); // Paper - decompile fix
|
|
brain.tick((ServerLevel)this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("camelActivityUpdate");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
@@ -0,0 +0,0 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
|
|
|
@Override
|
|
public Brain<Frog> getBrain() {
|
|
- return super.getBrain();
|
|
+ return (Brain<Frog>) super.getBrain(); // Paper - decompile fix
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
@@ -0,0 +0,0 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
|
|
|
@Override
|
|
public Brain<Hoglin> getBrain() {
|
|
- return super.getBrain();
|
|
+ return (Brain<Hoglin>) super.getBrain(); // Paper - decompile fix
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
|
@@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
|
}
|
|
|
|
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
|
|
- return (entry1.getValue()); // CraftBukkit
|
|
+ return entry1.getValue(); // CraftBukkit // Paper - decompile fix - *shrugs internally* // todo: is this needed anymore?
|
|
}));
|
|
this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
|
RecipeManager.LOGGER.info("Loaded {} recipes", map1.size());
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/CeilingHangingSignBlock.java b/src/main/java/net/minecraft/world/level/block/CeilingHangingSignBlock.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/CeilingHangingSignBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/CeilingHangingSignBlock.java
|
|
@@ -0,0 +0,0 @@ public class CeilingHangingSignBlock extends SignBlock {
|
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
BlockEntity itemStack = world.getBlockEntity(pos);
|
|
if (itemStack instanceof SignBlockEntity signBlockEntity) {
|
|
- ItemStack itemStack = player.getItemInHand(hand);
|
|
- if (this.shouldTryToChainAnotherHangingSign(player, hit, signBlockEntity, itemStack)) {
|
|
+ // Paper start - decompile fixes
|
|
+ ItemStack itemStack0 = player.getItemInHand(hand);
|
|
+ if (this.shouldTryToChainAnotherHangingSign(player, hit, signBlockEntity, itemStack0)) {
|
|
+ // Paper end - decompile fixes
|
|
return InteractionResult.PASS;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
|
@@ -0,0 +0,0 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
ItemStack itemStack = player.getItemInHand(hand);
|
|
Item item = itemStack.getItem();
|
|
- Item signBlockEntity = itemStack.getItem();
|
|
- SignApplicator var10000;
|
|
- if (signBlockEntity instanceof SignApplicator signApplicator) {
|
|
- var10000 = signApplicator;
|
|
- } else {
|
|
- var10000 = null;
|
|
- }
|
|
-
|
|
- SignApplicator signApplicator2 = var10000;
|
|
+ SignApplicator signApplicator2 = item instanceof SignApplicator signApplicator ? signApplicator : null; // Paper - decompile fixes
|
|
boolean bl = signApplicator2 != null && player.mayBuild();
|
|
- BlockEntity bl2 = world.getBlockEntity(pos);
|
|
- if (bl2 instanceof SignBlockEntity signBlockEntity) {
|
|
+ if (world.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity) { // Paper - decompile fixes
|
|
if (!world.isClientSide) {
|
|
boolean bl2 = signBlockEntity.isFacingFrontText(player);
|
|
SignText signText = signBlockEntity.getText(bl2);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/WallHangingSignBlock.java b/src/main/java/net/minecraft/world/level/block/WallHangingSignBlock.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/WallHangingSignBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/WallHangingSignBlock.java
|
|
@@ -0,0 +0,0 @@ public class WallHangingSignBlock extends SignBlock {
|
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
|
BlockEntity itemStack = world.getBlockEntity(pos);
|
|
if (itemStack instanceof SignBlockEntity signBlockEntity) {
|
|
- ItemStack itemStack = player.getItemInHand(hand);
|
|
- if (this.shouldTryToChainAnotherHangingSign(state, player, hit, signBlockEntity, itemStack)) {
|
|
+ // Paper start - decompile fixes
|
|
+ ItemStack itemStack0 = player.getItemInHand(hand);
|
|
+ if (this.shouldTryToChainAnotherHangingSign(state, player, hit, signBlockEntity, itemStack0)) {
|
|
+ // Paper end
|
|
return InteractionResult.PASS;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
@@ -0,0 +0,0 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
|
}
|
|
|
|
private static <T, C extends PalettedContainerRO<T>> Codec<C> codec(IdMap<T> idList, Codec<T> entryCodec, PalettedContainer.Strategy provider, T defaultValue, PalettedContainerRO.Unpacker<T, C> reader) {
|
|
- return RecordCodecBuilder.<PalettedContainerRO.PackedData>create((instance) -> {
|
|
+ return RecordCodecBuilder.<PalettedContainerRO.PackedData<T>>create((instance) -> { // Paper - decompile fix
|
|
return instance.group(entryCodec.mapResult(ExtraCodecs.orElsePartial(defaultValue)).listOf().fieldOf("palette").forGetter(PalettedContainerRO.PackedData::paletteEntries), Codec.LONG_STREAM.optionalFieldOf("data").forGetter(PalettedContainerRO.PackedData::storage)).apply(instance, PalettedContainerRO.PackedData::new);
|
|
}).comapFlatMap((serialized) -> {
|
|
return reader.read(idList, provider, serialized);
|
|
diff --git a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
|
+++ b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
|
@@ -0,0 +0,0 @@ public class EntityLookup<T extends EntityAccess> {
|
|
public <U extends T> void getEntities(EntityTypeTest<T, U> filter, AbortableIterationConsumer<U> consumer) {
|
|
for(T entityAccess : this.byId.values()) {
|
|
U entityAccess2 = (U)((EntityAccess)filter.tryCast(entityAccess));
|
|
- if (entityAccess2 != null && consumer.accept((T)entityAccess2).shouldAbort()) {
|
|
+ if (entityAccess2 != null && consumer.accept(entityAccess2).shouldAbort()) { // Paper - decompile fix
|
|
return;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/entity/EntitySection.java b/src/main/java/net/minecraft/world/level/entity/EntitySection.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/entity/EntitySection.java
|
|
+++ b/src/main/java/net/minecraft/world/level/entity/EntitySection.java
|
|
@@ -0,0 +0,0 @@ public class EntitySection<T extends EntityAccess> {
|
|
} else {
|
|
for(T entityAccess : collection) {
|
|
U entityAccess2 = (U)((EntityAccess)type.tryCast(entityAccess));
|
|
- if (entityAccess2 != null && entityAccess.getBoundingBox().intersects(box) && consumer.accept((T)entityAccess2).shouldAbort()) {
|
|
+ if (entityAccess2 != null && entityAccess.getBoundingBox().intersects(box) && consumer.accept(entityAccess2).shouldAbort()) { // Paper - decompile fix
|
|
return AbortableIterationConsumer.Continuation.ABORT;
|
|
}
|
|
}
|