Skip to content

Commit

Permalink
Update to 1.21-pre4
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonEggBedrockBreaking committed Jun 8, 2024
1 parent a00dd03 commit 20b5fd6
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 127 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ val MAVEN_GROUP by extra { "uk.debb" }
val LICENSE by extra { "MPL-2.0" }
val MOD_VERSION by extra { "3.3.3" }

val MINECRAFT_VERSION by extra { "1.20.6" }
val MINECRAFT_VERSION_RANGE_FABRIC by extra { ">=1.20.5" }
val MINECRAFT_VERSION by extra { "1.21-pre4" }
val MINECRAFT_VERSION_RANGE_FABRIC by extra { "*" }
val MINECRAFT_VERSION_RANGE_NEOFORGE by extra { "(1.20.4, 1.21)" }
val H2_VERSION by extra { "2.2.224" }
val ASM_VERSION by extra { "9.7" }
Expand All @@ -25,7 +25,7 @@ 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 MODMENU_VERSION by extra { "11.0.0-beta.1" }
val NEOFORGE_VERSION by extra { "20.6.111-beta"}
val NEOFORGE_LOADER_VERSION_RANGE by extra { ">=20.6.0-beta" }

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 @@ -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
Expand Up @@ -4,21 +4,31 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

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

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.core.Holder;
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 = "isCompatibleWith", at = @At("RETURN"))
private boolean vanillaDisable$isCompatibleWith(boolean original, Enchantment other) {
@ModifyReturnValue(method = "canEnchant", at = @At("RETURN"))
private boolean vanillaDisable$canEnchant(boolean original, ItemStack stack) {
if (CommandDataHandler.isConnectionNull()) return original;
String enchantment = CommandDataHandler.getKeyFromEnchantmentRegistry((Enchantment) (Object) this);
String otherEnchantment = "compatible_with_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromEnchantmentRegistry(other));
if (stack.getMaxDamage() == 0) return original;
String item = "can_enchant_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromItemRegistry(stack.getItem()));
return CommandDataHandler.getCachedBoolean("enchantments", CommandDataHandler.getKeyFromEnchantmentRegistry((Enchantment) (Object) this), 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;
String enchantment = CommandDataHandler.getKeyFromEnchantmentRegistry(holder.value());
String otherEnchantment = "compatible_with_" + CommandDataHandler.lightCleanup(CommandDataHandler.getKeyFromEnchantmentRegistry(holder2.value()));
String reversedEnchantment = enchantment.replace("minecraft:", "compatible_with_");
String reversedOtherEnchantment = otherEnchantment.replace("compatible_with_", "minecraft:");
return CommandDataHandler.getCachedBoolean("enchantments", enchantment, otherEnchantment) ||
Expand Down
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.

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 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);
return CommandDataHandler.paintingVariantRegistry.getHolderOrThrow(DEFAULT_VARIANT);
}
return original;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
package uk.debb.vanilla_disable.mixin.command.entity.player.hunger;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -21,9 +21,9 @@
@Mixin(Player.class)
public abstract class MixinPlayer {
@Inject(method = "eat", at = @At("HEAD"))
private void vanillaDisable$eat(Level level, ItemStack food, CallbackInfoReturnable<ItemStack> cir) {
private void vanillaDisable$eat(Level level, ItemStack food, FoodProperties foodProperties, CallbackInfoReturnable<ItemStack> cir) {
LivingEntity livingEntity = (LivingEntity) (Object) this;
if (food.get(DataComponents.FOOD) != null && CommandDataHandler.getCachedBoolean("entities", "minecraft:player", "beta_hunger")) {
if (foodProperties != null && CommandDataHandler.getCachedBoolean("entities", "minecraft:player", "beta_hunger")) {
int nutrition = CommandDataHandler.getCachedInt("items", CommandDataHandler.getKeyFromItemRegistry(food.getItem()), "nutrition");
livingEntity.setHealth(livingEntity.getHealth() + nutrition);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.item.food;

import net.minecraft.world.level.block.CakeBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import uk.debb.vanilla_disable.data.command.CommandDataHandler;

@Mixin(CakeBlock.class)
public abstract class MixinCakeBlock {
@ModifyArgs(
method = "eat",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/food/FoodData;eat(IF)V"
)
)
private static void vanillaDisable$eat(Args args) {
int nutrition = CommandDataHandler.getCachedInt("items", "minecraft:cake", "nutrition");
float saturation = (float) CommandDataHandler.getCachedDouble("items", "minecraft:cake", "saturation");
args.set(0, nutrition);
args.set(1, saturation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.item.food;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import uk.debb.vanilla_disable.data.command.CommandDataHandler;

@Mixin(Player.class)
public abstract class MixinPlayer {
@Shadow public abstract FoodData getFoodData();

@Inject(method = "eat", at = @At("HEAD"))
private void vanillaDisable$eat(Level level, ItemStack itemStack, FoodProperties foodProperties, CallbackInfoReturnable<ItemStack> cir) {
String name = CommandDataHandler.getKeyFromItemRegistry(itemStack.getItem());
int nutrition = CommandDataHandler.getCachedInt("items", name, "nutrition");
float saturation = (float) CommandDataHandler.getCachedDouble("items", name, "saturation");
this.getFoodData().eat(nutrition, saturation);
}

@WrapWithCondition(
method = "eat",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/food/FoodData;eat(Lnet/minecraft/world/food/FoodProperties;)V"
)
)
private boolean vanillaDisable$eat1(FoodData instance, FoodProperties foodProperties) {
return false;
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 20b5fd6

Please sign in to comment.