Skip to content

Commit

Permalink
feat: add a bunch of patches
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Jul 21, 2023
1 parent e814289 commit 40e75b3
Show file tree
Hide file tree
Showing 165 changed files with 2,411 additions and 0 deletions.
11 changes: 11 additions & 0 deletions versions/1.20.1/patches/net/minecraft/Util.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/Util.java
+++ b/net/minecraft/Util.java
@@ -358,7 +358,7 @@
}

public static <K> Strategy<K> identityStrategy() {
- return Util.IdentityStrategy.INSTANCE;
+ return (Strategy<K>) Util.IdentityStrategy.INSTANCE;
}

public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) {
11 changes: 11 additions & 0 deletions versions/1.20.1/patches/net/minecraft/commands/Commands.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/commands/Commands.java
+++ b/net/minecraft/commands/Commands.java
@@ -317,7 +317,7 @@
) {
for(CommandNode<CommandSourceStack> commandnode : tree.getChildren()) {
if (commandnode.canUse(source)) {
- ArgumentBuilder<SharedSuggestionProvider, ?> argumentbuilder = commandnode.createBuilder();
+ ArgumentBuilder<SharedSuggestionProvider, ?> argumentbuilder = (ArgumentBuilder) commandnode.createBuilder();
argumentbuilder.requires(sourcex -> true);
if (argumentbuilder.getCommand() != null) {
argumentbuilder.executes(context -> 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/net/minecraft/commands/arguments/EntityArgument.java
+++ b/net/minecraft/commands/arguments/EntityArgument.java
@@ -117,9 +117,9 @@

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
- StringReader stringreader = context.getSource();
- if (stringreader instanceof SharedSuggestionProvider sharedsuggestionprovider) {
- stringreader = new StringReader(builder.getInput());
+ S s = context.getSource();
+ if (s instanceof SharedSuggestionProvider sharedsuggestionprovider) {
+ StringReader stringreader = new StringReader(builder.getInput());
stringreader.setCursor(builder.getStart());
EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader, sharedsuggestionprovider.hasPermission(2));

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/commands/arguments/OperationArgument.java
+++ b/net/minecraft/commands/arguments/OperationArgument.java
@@ -57,7 +57,7 @@
}

private static OperationArgument.Operation getOperation(String operator) throws CommandSyntaxException {
- return (OperationArgument.Operation)(operator.equals("><") ? (a, b) -> {
+ return (operator.equals("><") ? (a, b) -> {
int i = a.getScore();
a.setScore(b.getScore());
b.setScore(i);
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/net/minecraft/commands/arguments/ResourceOrTagArgument.java
+++ b/net/minecraft/commands/arguments/ResourceOrTagArgument.java
@@ -150,7 +150,7 @@

@Override
public <E> Optional<ResourceOrTagArgument.Result<E>> cast(ResourceKey<? extends Registry<E>> registryRef) {
- return this.value.key().isFor(registryRef) ? Optional.of(this) : Optional.empty();
+ return this.value.key().isFor(registryRef) ? Optional.of((Result<E>) this) : Optional.empty();
}

@Override
@@ -180,7 +180,7 @@

@Override
public <E> Optional<ResourceOrTagArgument.Result<E>> cast(ResourceKey<? extends Registry<E>> registryRef) {
- return this.tag.key().isFor(registryRef) ? Optional.of(this) : Optional.empty();
+ return this.tag.key().isFor(registryRef) ? Optional.of((Result<E>) this) : Optional.empty();
}

@Override
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/net/minecraft/commands/arguments/item/ItemInput.java
+++ b/net/minecraft/commands/arguments/item/ItemInput.java
@@ -57,6 +57,6 @@
}

private String getItemName() {
- return this.item.unwrapKey().map(ResourceKey::location).orElseGet(() -> "unknown[" + this.item + "]").toString();
+ return this.item.unwrapKey().<Object>map(ResourceKey::location).orElseGet(() -> "unknown[" + this.item + "]").toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/net/minecraft/commands/synchronization/ArgumentTypeInfos.java
+++ b/net/minecraft/commands/synchronization/ArgumentTypeInfos.java
@@ -114,10 +114,10 @@
register(registry, "dimension", DimensionArgument.class, SingletonArgumentInfo.contextFree(DimensionArgument::dimension));
register(registry, "gamemode", GameModeArgument.class, SingletonArgumentInfo.contextFree(GameModeArgument::gameMode));
register(registry, "time", TimeArgument.class, new TimeArgument.Info());
- register(registry, "resource_or_tag", fixClassType(ResourceOrTagArgument.class), new ResourceOrTagArgument.Info());
- register(registry, "resource_or_tag_key", fixClassType(ResourceOrTagKeyArgument.class), new ResourceOrTagKeyArgument.Info());
- register(registry, "resource", fixClassType(ResourceArgument.class), new ResourceArgument.Info());
- register(registry, "resource_key", fixClassType(ResourceKeyArgument.class), new ResourceKeyArgument.Info());
+ register(registry, "resource_or_tag", fixClassType(ResourceOrTagArgument.class), new ResourceOrTagArgument.Info<>());
+ register(registry, "resource_or_tag_key", fixClassType(ResourceOrTagKeyArgument.class), new ResourceOrTagKeyArgument.Info<>());
+ register(registry, "resource", fixClassType(ResourceArgument.class), new ResourceArgument.Info<>());
+ register(registry, "resource_key", fixClassType(ResourceKeyArgument.class), new ResourceKeyArgument.Info<>());
register(registry, "template_mirror", TemplateMirrorArgument.class, SingletonArgumentInfo.contextFree(TemplateMirrorArgument::templateMirror));
register(registry, "template_rotation", TemplateRotationArgument.class, SingletonArgumentInfo.contextFree(TemplateRotationArgument::templateRotation));
register(registry, "heightmap", HeightmapTypeArgument.class, SingletonArgumentInfo.contextFree(HeightmapTypeArgument::heightmap));
@@ -142,7 +142,7 @@
if (argumenttypeinfo == null) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "Unrecognized argument type %s (%s)", argumentType, argumentType.getClass()));
} else {
- return argumenttypeinfo;
+ return (ArgumentTypeInfo<A, ?>) argumenttypeinfo;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/commands/synchronization/SuggestionProviders.java
+++ b/net/minecraft/commands/synchronization/SuggestionProviders.java
@@ -48,7 +48,7 @@
throw new IllegalArgumentException("A command suggestion provider is already registered with the name " + id);
} else {
PROVIDERS_BY_NAME.put(id, provider);
- return new SuggestionProviders.Wrapper(id, provider);
+ return (SuggestionProvider<S>) new Wrapper(id, provider);
}
}

11 changes: 11 additions & 0 deletions versions/1.20.1/patches/net/minecraft/core/HolderLookup.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/core/HolderLookup.java
+++ b/net/minecraft/core/HolderLookup.java
@@ -87,7 +87,7 @@
final Map<ResourceKey<? extends Registry<?>>, HolderLookup.RegistryLookup<?>> map = wrappers.collect(
Collectors.toUnmodifiableMap(
HolderLookup.RegistryLookup::key,
- (Function<? super HolderLookup.RegistryLookup, ? extends HolderLookup.RegistryLookup>)(wrapper -> wrapper)
+ (wrapper -> wrapper)
)
);
return new HolderLookup.Provider() {
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--- a/net/minecraft/core/RegistryAccess.java
+++ b/net/minecraft/core/RegistryAccess.java
@@ -34,8 +34,8 @@
return new RegistryAccess.Frozen() {
@Override
public <T> Optional<Registry<T>> registry(ResourceKey<? extends Registry<? extends T>> key) {
- Registry<Registry<T>> registry = registries;
- return registry.getOptional(key);
+ Registry<Registry<T>> registry = (Registry<Registry<T>>) registries;
+ return registry.getOptional((ResourceKey<Registry<T>>) key);
}

@Override
@@ -72,7 +72,7 @@

public ImmutableRegistryAccess(List<? extends Registry<?>> registries) {
this.registries = registries.stream()
- .collect(Collectors.toUnmodifiableMap(Registry::key, (Function<? super Registry, ? extends Registry>)(registry -> registry)));
+ .collect(Collectors.toUnmodifiableMap(Registry::key, (registry -> registry)));
}

public ImmutableRegistryAccess(Map<? extends ResourceKey<? extends Registry<?>>, ? extends Registry<?>> registries) {
@@ -85,7 +85,7 @@

@Override
public <E> Optional<Registry<E>> registry(ResourceKey<? extends Registry<? extends E>> key) {
- return Optional.ofNullable(this.registries.get(key)).map((Function<? super Registry<?>, ? extends Registry<E>>)(registry -> registry));
+ return Optional.ofNullable(this.registries.get(key)).map((Function<? super Registry<?>, ? extends Registry<E>>)(registry -> (Registry<E>) registry));
}

@Override
@@ -102,7 +102,7 @@
}

private static <T> RegistryAccess.RegistryEntry<T> fromUntyped(ResourceKey<? extends Registry<?>> key, Registry<?> value) {
- return new RegistryAccess.RegistryEntry<>(key, value);
+ return new RegistryAccess.RegistryEntry<>((ResourceKey<? extends Registry<T>>) key, (Registry<T>) value);
}

private RegistryAccess.RegistryEntry<T> freeze() {
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/net/minecraft/core/RegistrySetBuilder.java
+++ b/net/minecraft/core/RegistrySetBuilder.java
@@ -270,8 +270,8 @@
ResourceKey<?> resourcekey = entry.getKey();
if (resourcekey.isFor(this.key)) {
RegistrySetBuilder.RegisteredValue<T> registeredvalue = (RegistrySetBuilder.RegisteredValue)entry.getValue();
- Holder.Reference<T> reference = registries.lookup.holders.remove(resourcekey);
- map.put(resourcekey, new RegistrySetBuilder.ValueAndHolder<>(registeredvalue, Optional.ofNullable(reference)));
+ Holder.Reference<T> reference = (Holder.Reference<T>) registries.lookup.holders.remove(resourcekey);
+ map.put((ResourceKey<T>) resourcekey, new RegistrySetBuilder.ValueAndHolder<>(registeredvalue, Optional.ofNullable(reference)));
iterator.remove();
}
}
@@ -293,7 +293,7 @@
}

<T> Holder.Reference<T> getOrCreate(ResourceKey<T> key) {
- return this.holders.computeIfAbsent(key, key2 -> Holder.Reference.createStandAlone(this.owner, key2));
+ return (Holder.Reference<T>) this.holders.computeIfAbsent((ResourceKey<Object>) key, key2 -> Holder.Reference.createStandAlone(this.owner, key2));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/net/minecraft/core/RegistrySynchronization.java
+++ b/net/minecraft/core/RegistrySynchronization.java
@@ -48,7 +48,7 @@

private static <E> DataResult<? extends Codec<E>> getNetworkCodec(ResourceKey<? extends Registry<E>> registryRef) {
return (DataResult<? extends Codec<E>>)Optional.ofNullable(NETWORKABLE_REGISTRIES.get(registryRef))
- .map(info -> info.networkCodec())
+ .map(info -> (Codec<E>) info.networkCodec())
.map(DataResult::success)
.orElseGet(() -> DataResult.error(() -> "Unknown or not serializable registry: " + registryRef));
}
@@ -67,7 +67,7 @@
private static <K extends ResourceKey<? extends Registry<?>>, V extends Registry<?>> Codec<RegistryAccess> captureMap(UnboundedMapCodec<K, V> networkCodec) {
return networkCodec.xmap(
RegistryAccess.ImmutableRegistryAccess::new,
- registryManager -> ownedNetworkableRegistries(registryManager).collect(ImmutableMap.toImmutableMap(entry -> entry.key(), entry -> entry.value()))
+ registryManager -> ownedNetworkableRegistries(registryManager).collect(ImmutableMap.toImmutableMap(entry -> (K) entry.key(), entry -> (V) entry.value()))
);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/core/registries/BuiltInRegistries.java
+++ b/net/minecraft/core/registries/BuiltInRegistries.java
@@ -284,7 +284,7 @@
) {
ResourceLocation resourcelocation = key.location();
LOADERS.put(resourcelocation, () -> initializer.run(registry));
- WRITABLE_REGISTRY.register(key, registry, lifecycle);
+ WRITABLE_REGISTRY.register((ResourceKey) key, registry, lifecycle);
return registry;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/data/info/RegistryDumpReport.java
+++ b/net/minecraft/data/info/RegistryDumpReport.java
@@ -34,7 +34,7 @@
jsonobject.addProperty("default", resourcelocation.toString());
}

- int i = BuiltInRegistries.REGISTRY.getId(registry);
+ int i = ((Registry) BuiltInRegistries.REGISTRY).getId(registry);
jsonobject.addProperty("protocol_id", i);
JsonObject jsonobject1 = new JsonObject();
registry.holders().forEach(entry -> {
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/net/minecraft/data/loot/BlockLootSubProvider.java
+++ b/net/minecraft/data/loot/BlockLootSubProvider.java
@@ -357,7 +357,7 @@
dropWithShears,
this.applyExplosionDecay(
dropWithShears,
- ((LootPoolSingletonContainer.Builder)LootItem.lootTableItem(Items.WHEAT_SEEDS).when(LootItemRandomChanceCondition.randomChance(0.125F)))
+ LootItem.lootTableItem(Items.WHEAT_SEEDS).when(LootItemRandomChanceCondition.randomChance(0.125F))
.apply(ApplyBonusCount.addUniformBonusCount(Enchantments.BLOCK_FORTUNE, 2))
)
);
@@ -408,7 +408,7 @@
.add(
this.applyExplosionDecay(
drop,
- ((LootPoolSingletonContainer.Builder)((LootPoolSingletonContainer.Builder)LootItem.lootTableItem(drop).when(condition))
+ ((LootItem.lootTableItem(drop).when(condition))
.apply(
Direction.values(),
direction -> SetItemCountFunction.setCount(ConstantValue.exactly(1.0F), true)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- a/net/minecraft/data/tags/TagsProvider.java
+++ b/net/minecraft/data/tags/TagsProvider.java
@@ -62,6 +62,8 @@

@Override
public CompletableFuture<?> run(CachedOutput writer) {
+ record CombinedData<T>(HolderLookup.Provider contents, TagsProvider.TagLookup<T> parent) {
+ }
return this.createContentsProvider()
.thenApply(registryLookupFuture -> {
this.contentsDone.complete(null);
@@ -106,8 +108,6 @@
}
);

- record CombinedData<T>(HolderLookup.Provider contents, TagsProvider.TagLookup<T> parent) {
- }

}

@@ -176,7 +176,7 @@
}

default boolean contains(TagKey<T> tag) {
- return this.apply((T)tag).isPresent();
+ return this.apply(tag).isPresent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/net/minecraft/gametest/framework/GameTestRegistry.java
+++ b/net/minecraft/gametest/framework/GameTestRegistry.java
@@ -53,7 +53,7 @@
T t = method.getAnnotation(clazz);
if (t != null) {
String s = batchIdFunction.apply(t);
- Consumer<ServerLevel> consumer = batchConsumerMap.putIfAbsent(s, turnMethodIntoConsumer(method));
+ Consumer<ServerLevel> consumer = batchConsumerMap.putIfAbsent(s, (Consumer<ServerLevel>) turnMethodIntoConsumer(method));
if (consumer != null) {
throw new RuntimeException("Hey, there should only be one " + clazz + " method per batch. Batch '" + s + "' has more than one!");
}
@@ -126,7 +126,7 @@
gametest.required(),
gametest.requiredSuccesses(),
gametest.attempts(),
- turnMethodIntoConsumer(method)
+ (Consumer<GameTestHelper>) turnMethodIntoConsumer(method)
);
}

17 changes: 17 additions & 0 deletions versions/1.20.1/patches/net/minecraft/nbt/TagParser.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/net/minecraft/nbt/TagParser.java
+++ b/net/minecraft/nbt/TagParser.java
@@ -242,11 +242,11 @@
}

if (typeReader == ByteTag.TYPE) {
- list.add((T)((NumericTag)tag).getAsByte());
+ list.add((T)(Byte)((NumericTag)tag).getAsByte());
} else if (typeReader == LongTag.TYPE) {
- list.add((T)((NumericTag)tag).getAsLong());
+ list.add((T)(Long)((NumericTag)tag).getAsLong());
} else {
- list.add((T)((NumericTag)tag).getAsInt());
+ list.add((T)(Integer)((NumericTag)tag).getAsInt());
}

if (!this.hasElementSeparator()) {
Loading

0 comments on commit 40e75b3

Please sign in to comment.