Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/VazkiiMods/Quark
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Sep 17, 2024
2 parents 27bbc2b + 6330fa7 commit 6f71d12
Show file tree
Hide file tree
Showing 7 changed files with 910 additions and 415 deletions.
6 changes: 6 additions & 0 deletions contributors.properties
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,9 @@ Grawlix=1
Milinen=2
ArzinistMC=2
fan_of_things=1
GreatLakesGirl=1
_Kushikime_=2
BhGxD=1
natashz=2
Herzog_Franko=1
Dubstep34=2
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,16 @@ private EnchantmentDataWrapper generateRandomEnchantment(Map<Enchantment, Intege

List<EnchantmentDataWrapper> validEnchants = new ArrayList<>();
BuiltInRegistries.ENCHANTMENT.forEach(enchantment -> {

String id = BuiltInRegistries.ENCHANTMENT.getKey(enchantment).toString();
boolean isValid = true;
if(enchantment.isTreasureOnly()) {

if (!enchantment.isDiscoverable()) {
isValid = MatrixEnchantingModule.allowUndiscoverableEnchantments ||
MatrixEnchantingModule.undiscoverableWhitelist.contains(id);
}

if(isValid && enchantment.isTreasureOnly()) {
isValid = MatrixEnchantingModule.allowTreasures ||
(isBook && MatrixEnchantingModule.treasureWhitelist.contains(id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ public class MatrixEnchantingModule extends ZetaModule {
@Config(description = "Set this to true to allow treasure enchantments to be rolled as pieces")
public static boolean allowTreasures = false;

@Config(description = "Set this to true to allow undiscoverable enchantments to be rolled as pieces")
public static boolean allowUndiscoverableEnchantments = false;

@Config(description = "Any treasure enchantment IDs here will be able to appear in books in matrix enchanting")
public static List<String> treasureWhitelist = Lists.newArrayList();

@Config(description = "Any undiscoverable enchantment IDs here will be able to appear in matrix enchanting")
public static List<String> undiscoverableWhitelist = Lists.newArrayList();

@Config(description = "Set to false to disable the tooltip for items with pending enchantments")
public static boolean showTooltip = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.ChestBlockEntity;

import org.jetbrains.annotations.Nullable;

import org.violetmoon.zeta.module.ZetaModule;

import java.util.Map;
import java.util.function.BooleanSupplier;

/**
Expand All @@ -33,6 +32,10 @@ default Block lootrVariant(Block base) {
return null;
}

default void populate(Map<Block, Block> map) {
// NO-OP
}

default void postRegister() {
// NO-OP
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;

import org.jetbrains.annotations.Nullable;

import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.util.BlockPropertyUtil;
import org.violetmoon.zeta.module.ZetaModule;
Expand Down Expand Up @@ -62,6 +59,11 @@ public Block lootrVariant(Block base) {
return chestMappings.get(base);
}

@Override
public void populate(Map<Block, Block> map) {
map.putAll(chestMappings);
}

@Override
public void postRegister() {
chestTEType = BlockEntityType.Builder.of(LootrVariantChestBlockEntity::new, lootrRegularChests.toArray(new Block[0])).build(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.violetmoon.quark.integration.mixin.lootr;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;

import noobanidus.mods.lootr.config.ConfigManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import org.violetmoon.quark.base.Quark;

import noobanidus.mods.lootr.config.ConfigManager;
import java.util.Map;

@Pseudo
@Mixin(value = ConfigManager.class, remap = false)
Expand All @@ -28,4 +28,10 @@ private static Block replacement(Block original, ResourceLocation location) {

return original;
}

@ModifyReturnValue(method = "replacement", at = @At(value = "NEW", target = "java/util/HashMap", remap = false), remap = false)
private static Map<Block, Block> addQuarkChests(Map<Block, Block> original) {
Quark.LOOTR_INTEGRATION.populate(original);
return original;
}
}
Loading

0 comments on commit 6f71d12

Please sign in to comment.