Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonEggBedrockBreaking committed Jun 13, 2024
1 parent 7101915 commit f2f70a4
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 139 deletions.
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ val MAVEN_GROUP by extra { "uk.debb" }
val LICENSE by extra { "MPL-2.0" }
val MOD_VERSION by extra { "3.3.4" }

val MINECRAFT_VERSION by extra { "1.20.6" }
val MINECRAFT_VERSION_RANGE_FABRIC by extra { ">=1.20.5" }
val MINECRAFT_VERSION_RANGE_NEOFORGE by extra { "(1.20.4, 1.21)" }
val MINECRAFT_VERSION by extra { "1.21" }
val MINECRAFT_VERSION_RANGE_FABRIC by extra { ">=1.21" }
val MINECRAFT_VERSION_RANGE_NEOFORGE by extra { "[1.21,1.22)" }
val H2_VERSION by extra { "2.2.224" }
val ASM_VERSION by extra { "9.7" }
val PARCHMENT_MC_VERSION by extra { "1.20.6" }
Expand All @@ -25,9 +25,9 @@ val MIXIN_EXTRAS_VERSION by extra { "0.3.6" }
val FABRIC_MIXIN_VERSION by extra { "0.14.0+mixin.0.8.6" }
val FABRIC_LOADER_VERSION by extra { "0.15.11" }
val FABRIC_LOADER_VERSION_RANGE by extra { ">=0.15.10" }
val MODMENU_VERSION by extra { "10.0.0-beta.1" }
val NEOFORGE_VERSION by extra { "20.6.115"}
val NEOFORGE_LOADER_VERSION_RANGE by extra { ">=20.6.0-beta" }
val MODMENU_VERSION by extra { "11.0.0-beta.1" }
val NEOFORGE_VERSION by extra { "21.0.0-beta"}
val NEOFORGE_LOADER_VERSION_RANGE by extra { ">=21.0.0-beta" }

allprojects {
apply(plugin = "java")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

public class WorldgenConfigScreen extends Screen {
private final CreateWorldScreen lastScreen;
private final String[] extraPlacedFeatures = {"obsidian_platform", "end_spike_cage"};
private Set<ResourceLocation> biomes;
private Set<ResourceLocation> structures;
private Set<ResourceLocation> placedFeatures;
Expand Down Expand Up @@ -59,14 +58,14 @@ protected void init() {
this.biomes.forEach(biome -> WorldgenDataHandler.biomeMap.put(WorldgenDataHandler.cleanup(biome), true));
this.structures.forEach(structure -> WorldgenDataHandler.structureMap.put(WorldgenDataHandler.cleanup(structure), true));
this.placedFeatures.forEach(placedFeature -> WorldgenDataHandler.placedFeatureMap.put(WorldgenDataHandler.cleanup(placedFeature), true));
Arrays.stream(extraPlacedFeatures).forEach(placedFeature -> WorldgenDataHandler.placedFeatureMap.put(placedFeature, true));
WorldgenDataHandler.placedFeatureMap.put("end_spike_cage", true);
worldgenConfigList.refreshEntries();
}).width(80).build();
Button disableButton = Button.builder(Component.translatable("vd.worldgen_config.disable_all"), (button) -> {
this.biomes.forEach(biome -> WorldgenDataHandler.biomeMap.put(WorldgenDataHandler.cleanup(biome), false));
this.structures.forEach(structure -> WorldgenDataHandler.structureMap.put(WorldgenDataHandler.cleanup(structure), false));
this.placedFeatures.forEach(placedFeature -> WorldgenDataHandler.placedFeatureMap.put(WorldgenDataHandler.cleanup(placedFeature), false));
Arrays.stream(extraPlacedFeatures).forEach(placedFeature -> WorldgenDataHandler.placedFeatureMap.put(placedFeature, false));
WorldgenDataHandler.placedFeatureMap.put("end_spike_cage", false);
worldgenConfigList.refreshEntries();
}).width(80).build();
Button doneButton = Button.builder(Component.translatable("vd.worldgen_config.done"), (button) -> {
Expand Down Expand Up @@ -133,7 +132,7 @@ class WorldgenConfigCategoryEntry extends WorldgenConfigScreen.WorldgenConfigEnt
case PLACED_FEATURE -> {
boolean val = Collections.frequency(WorldgenDataHandler.placedFeatureMap.values(), false) < WorldgenConfigScreen.this.placedFeatures.size() / 2;
WorldgenConfigScreen.this.placedFeatures.forEach(placedFeature -> WorldgenDataHandler.placedFeatureMap.put(WorldgenDataHandler.cleanup(placedFeature), !val));
Arrays.stream(extraPlacedFeatures).forEach(placedFeature -> WorldgenDataHandler.placedFeatureMap.put(placedFeature, !val));
WorldgenDataHandler.placedFeatureMap.put("end_spike_cage", !val);
}
}
list.refreshEntries();
Expand Down Expand Up @@ -203,12 +202,9 @@ class WorldgenConfigList extends ContainerObjectSelectionList<WorldgenConfigScre
this.addEntry(new WorldgenConfigToggleEntry(placedFeature.toString(), WorldgenConfigType.PLACED_FEATURE));
}
});
Arrays.stream(extraPlacedFeatures).sorted().forEach(placedFeature -> {
String adjustedPlacedFeature = "minecraft_unofficial:" + placedFeature;
if (adjustedPlacedFeature.contains(WorldgenConfigScreen.this.search)) {
this.addEntry(new WorldgenConfigToggleEntry(adjustedPlacedFeature, WorldgenConfigType.PLACED_FEATURE));
}
});
if ("minecraft_unofficial:end_spike_cage".contains(WorldgenConfigScreen.this.search)) {
this.addEntry(new WorldgenConfigToggleEntry("minecraft_unofficial:end_spike_cage", WorldgenConfigType.PLACED_FEATURE));
}
}

public void refreshEntries() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import it.unimi.dsi.fastutil.objects.*;
import net.minecraft.commands.Commands;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.cauldron.CauldronInteraction;
Expand Down Expand Up @@ -563,6 +564,10 @@ public static void populate() {
put("nutrition", String.valueOf(foodProperties.nutrition()));
put("saturation", String.valueOf(foodProperties.saturation()));
}
if (item.equals(Items.CAKE)) {
put("nutrition", "2");
put("saturation", "0.1");
}

if (item.equals(Items.POTION) || item.equals(Items.SPLASH_POTION) ||
item.equals(Items.LINGERING_POTION) || item.equals(Items.TIPPED_ARROW)) {
Expand Down Expand Up @@ -605,7 +610,7 @@ public static void populate() {
enchantmentRegistry.forEach(enchantment1 -> {
if (enchantment1.equals(enchantment)) return;
put("compatible_with_" + lightCleanup(Objects.requireNonNull(enchantmentRegistry.getKey(enchantment1))),
String.valueOf(enchantment.isCompatibleWith(enchantment1) && enchantment1.isCompatibleWith(enchantment)));
String.valueOf(Enchantment.areCompatible(new Holder.Direct<>(enchantment), new Holder.Direct<>(enchantment1))));
});
}}));

Expand Down Expand Up @@ -1279,7 +1284,7 @@ private static List<ItemStack> getBreedingItems(String row) {
String columnName = resultSetMetaData.getColumnName(i);
if (columnName.startsWith("can_breed_with_")) {
if (resultSet.getBoolean(columnName)) {
items.add(Objects.requireNonNull(itemRegistry.get(ResourceLocation.of(
items.add(Objects.requireNonNull(itemRegistry.get(ResourceLocation.bySeparator(
columnName.replace("can_breed_with_", "minecraft:"), ':'))));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ private static void createConfig(boolean write) {
String clean = cleanup(placedFeature);
properties.put("placed_features." + clean, placedFeatureMap.getOrDefault(clean, true));
});
ImmutableList.of("obsidian_platform", "end_spike_cage").forEach(placedFeature ->
properties.put("placed_features." + placedFeature, placedFeatureMap.getOrDefault(placedFeature, true)));
properties.put("placed_features.end_spike_cage", placedFeatureMap.getOrDefault("end_spike_cage", true));

if (write) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package uk.debb.vanilla_disable.mixin.command.enchantment;

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.ItemEnchantments;
import net.minecraft.world.level.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import uk.debb.vanilla_disable.data.command.CommandDataHandler;

@Mixin(Block.class)
public abstract class MixinBlock {
@ModifyArg(
method = "getDrops(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)Ljava/util/List;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/storage/loot/LootParams$Builder;withParameter(Lnet/minecraft/world/level/storage/loot/parameters/LootContextParam;Ljava/lang/Object;)Lnet/minecraft/world/level/storage/loot/LootParams$Builder;",
ordinal = 1
),
index = 1
)
private static Object vanillaDisable$getDrops(Object value) {
if (value instanceof ItemStack itemStack) {
String item = "can_enchant_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromItemRegistry(itemStack.getItem()));
ItemEnchantments itemEnchantments = itemStack.getEnchantments();
itemEnchantments.enchantments = itemEnchantments.enchantments.object2IntEntrySet().stream()
.filter(e -> CommandDataHandler.getCachedBoolean("enchantments", CommandDataHandler.getKeyFromEnchantmentRegistry(e.getKey().value()), item))
.collect(Object2IntOpenHashMap::new, (m, e) -> m.put(e.getKey(), e.getIntValue()), Object2IntOpenHashMap::putAll);
EnchantmentHelper.setEnchantments(itemStack, itemEnchantments);
return itemStack;
}
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package uk.debb.vanilla_disable.mixin.command.enchantment;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import uk.debb.vanilla_disable.data.command.CommandDataHandler;

@Mixin(Enchantment.class)
public abstract class MixinEnchantment {
@ModifyReturnValue(method = "canEnchant", at = @At("RETURN"))
private boolean vanillaDisable$canEnchant(boolean original, ItemStack stack) {
if (CommandDataHandler.isConnectionNull()) return original;
if (stack.getMaxDamage() == 0) return original;
String item = "can_enchant_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromItemRegistry(stack.getItem()));
ResourceLocation enchantment = CommandDataHandler.enchantmentRegistry.getKey((Enchantment) (Object) this);
if (enchantment == null) return original;
return CommandDataHandler.getCachedBoolean("enchantments", enchantment.toString(), item);
}

@ModifyReturnValue(method = "areCompatible", at = @At("RETURN"))
private static boolean vanillaDisable$areCompatible(boolean original, Holder<Enchantment> holder, Holder<Enchantment> holder2) {
if (CommandDataHandler.isConnectionNull()) return original;
ResourceLocation enchantmentRL = CommandDataHandler.enchantmentRegistry.getKey(holder.value());
ResourceLocation otherEnchantmentRL = CommandDataHandler.enchantmentRegistry.getKey(holder2.value());
if (enchantmentRL == null || otherEnchantmentRL == null) return original;
String enchantment = enchantmentRL.toString();
String otherEnchantment = "compatible_with_" + CommandDataHandler.lightCleanup(otherEnchantmentRL);
String reversedEnchantment = enchantment.replace("minecraft:", "compatible_with_");
String reversedOtherEnchantment = otherEnchantment.replace("compatible_with_", "minecraft:");
return CommandDataHandler.getCachedBoolean("enchantments", enchantment, otherEnchantment) ||
CommandDataHandler.getCachedBoolean("enchantments", reversedOtherEnchantment, reversedEnchantment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package uk.debb.vanilla_disable.mixin.command.enchantment.item;
package uk.debb.vanilla_disable.mixin.command.enchantment;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.core.Holder;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
Expand All @@ -19,14 +20,14 @@
@Mixin(EnchantmentHelper.class)
public abstract class MixinEnchantmentHelper {
@ModifyReturnValue(method = "getItemEnchantmentLevel", at = @At("RETURN"))
private static int vanillaDisable$getItemEnchantmentLevel(int original, Enchantment enchantment, ItemStack stack) {
String item = "can_enchant_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromItemRegistry(stack.getItem()));
if (!CommandDataHandler.getCachedBoolean("enchantments", CommandDataHandler.getKeyFromEnchantmentRegistry(enchantment), item)) {
ItemEnchantments itemEnchantments = stack.getEnchantments();
private static int vanillaDisable$getItemEnchantmentLevel(int original, Holder<Enchantment> holder, ItemStack itemStack) {
String item = "can_enchant_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromItemRegistry(itemStack.getItem()));
if (!CommandDataHandler.getCachedBoolean("enchantments", CommandDataHandler.getKeyFromEnchantmentRegistry(holder.value()), item)) {
ItemEnchantments itemEnchantments = itemStack.getEnchantments();
itemEnchantments.enchantments = itemEnchantments.enchantments.object2IntEntrySet().stream()
.filter(e -> CommandDataHandler.getCachedBoolean("enchantments", CommandDataHandler.getKeyFromEnchantmentRegistry(e.getKey().value()), item))
.collect(Object2IntOpenHashMap::new, (m, e) -> m.put(e.getKey(), e.getIntValue()), Object2IntOpenHashMap::putAll);
EnchantmentHelper.setEnchantments(stack, itemEnchantments);
EnchantmentHelper.setEnchantments(itemStack, itemEnchantments);
return 0;
}
return original;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,21 @@

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.decoration.Painting;
import net.minecraft.world.entity.decoration.PaintingVariant;
import org.spongepowered.asm.mixin.Final;
import net.minecraft.world.entity.decoration.PaintingVariants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import uk.debb.vanilla_disable.data.command.CommandDataHandler;

import java.util.Objects;

@Mixin(Painting.class)
public abstract class MixinPainting {
@Shadow
@Final
private static ResourceKey<PaintingVariant> DEFAULT_VARIANT;

@ModifyReturnValue(method = "getVariant()Lnet/minecraft/core/Holder;", at = @At("RETURN"))
private Holder<PaintingVariant> vanillaDisable$getVariant(Holder<PaintingVariant> original) {
if (!CommandDataHandler.getCachedBoolean("entities", "minecraft:painting",
CommandDataHandler.lightCleanup(Objects.requireNonNull(CommandDataHandler.paintingVariantRegistry.getKey(original.value()))) + "_painting")) {
return BuiltInRegistries.PAINTING_VARIANT.getHolderOrThrow(DEFAULT_VARIANT);
if (!CommandDataHandler.getCachedBoolean("entities", "minecraft:painting", CommandDataHandler.lightCleanup(original.value().assetId()) + "_painting")) {
return new Holder.Direct<>(Objects.requireNonNull(CommandDataHandler.paintingVariantRegistry.get(PaintingVariants.KEBAB)));
}
return original;
}
Expand Down
Loading

0 comments on commit f2f70a4

Please sign in to comment.