Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rei_version=16.0.799
emi_version=1.1.24+1.21.1
architectury_version=13.0.8
# https://cloudsmith.io/~klikli-dev/repos/mods/groups/
modonomicon_version=1.120.4
modonomicon_version=1.120.7
modonomicon_version_range=[1.117.4,)
# https://maven.is-immensely.gay/#/releases/de/dafuqs/additionalentityattributes
additional_entity_attributes_version=2.0.2+1.21.1-neoforge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static void clearCurrentlyRenderedMultiBlock(Level world) {
ModonomiconHelper.clearRenderedMultiblock(SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_SIMPLE));
ModonomiconHelper.clearRenderedMultiblock(SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_ADVANCED));
ModonomiconHelper.clearRenderedMultiblock(SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_COMPLEX));
ModonomiconHelper.clearRenderedMultiblock(SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_COMPLEX_WITHOUT_MOONSTONE));
ModonomiconHelper.clearRenderedMultiblock(SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_COMPLEX_WITHOUT_ENGRAVINGS));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ private PedestalRecipeTier getStructureTier() {
return PedestalRecipeTier.COMPLEX;
}

multiblock = SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_COMPLEX_WITHOUT_MOONSTONE);
multiblock = SpectrumMultiblocks.get(SpectrumMultiblocks.PEDESTAL_COMPLEX_WITHOUT_ENGRAVINGS);
if (multiblock.validate(level, worldPosition.below(), Rotation.NONE)) {
SpectrumAdvancementCriteria.COMPLETED_MULTIBLOCK.trigger((ServerPlayer) this.getOwnerIfOnline(level), multiblock);
return PedestalRecipeTier.ADVANCED;
Expand Down
86 changes: 51 additions & 35 deletions src/main/java/de/dafuqs/spectrum/commands/SanityCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import net.minecraft.world.level.block.state.*;
import net.minecraft.world.level.storage.loot.*;
import org.apache.commons.lang3.*;
import org.jspecify.annotations.*;

import java.util.*;

Expand Down Expand Up @@ -109,14 +108,18 @@ private static int execute(CommandSourceStack source, String modId) {
if (registryKey.location().getNamespace().equals(modId)) {
Block block = entry.getValue();

if (block instanceof PlacedItemBlock) {
continue; // that one always drops itself via code
}
if (block instanceof SpectrumBuddingBlock) {
continue; // does not have any drop by default
}
if (block instanceof WeepingGalaFrondsBlock) {
continue; // Fronds do not drop anything by default
switch (block) {
case PlacedItemBlock ignored -> {
continue; // that one always drops itself via code
}
case SpectrumBuddingBlock ignored -> {
continue; // does not have any drop by default
}
case WeepingGalaFrondsBlock ignored -> {
continue; // Fronds do not drop anything by default
}
default -> {
}
}

BlockState blockState = entry.getValue().defaultBlockState();
Expand Down Expand Up @@ -233,6 +236,36 @@ private static int execute(CommandSourceStack source, String modId) {
}
}

Set<Item> modItems = new HashSet<>();

// Items that are meant to be enchantable but not really
for (Map.Entry<ResourceKey<Item>, Item> item : BuiltInRegistries.ITEM.entrySet()) {
if (!item.getKey().location().getNamespace().equals(modId)) {
continue;
}

Item i = item.getValue();
modItems.add(i);

ItemStack defaultStack = i.getDefaultInstance();
boolean isEnchantable = i.isEnchantable(defaultStack);
int enchantmentValue = i.getEnchantmentValue(defaultStack);
if(isEnchantable) {
if(enchantmentValue <= 0) {
SpectrumCommon.logWarning("[SANITY: Enchantability] " + item.getValue().getDescriptionId() + " is enchantable, but has an enchantment value of " + enchantmentValue);
}
}
if(enchantmentValue > 0) {
if(!isEnchantable) {
if(i == SpectrumItems.GILDED_BOOK.get()) {
continue;
}
SpectrumCommon.logWarning("[SANITY: Enchantability] " + item.getValue().getDescriptionId() + " is has a positive enchantment value, but its default instance is not enchantable");
}
}
}


// recipe groups without localization
Set<String> recipeGroups = new HashSet<>();
recipeManager.getRecipeIds().forEach(identifier -> {
Expand All @@ -245,6 +278,8 @@ private static int execute(CommandSourceStack source, String modId) {
}
}
}

modItems.remove(recipe.get().value().getResultItem(source.registryAccess()).getItem());
});
for (String recipeGroup : recipeGroups) {
if (!Language.getInstance().has("recipeGroup.spectrum." + recipeGroup)) {
Expand All @@ -269,41 +304,22 @@ private static int execute(CommandSourceStack source, String modId) {
testIngredientsAndOutputInColorRegistry(SpectrumRecipeTypes.ENCHANTMENT_UPGRADE, "Enchantment Upgrade", recipeManager, registryManager);
testIngredientsAndOutputInColorRegistry(SpectrumRecipeTypes.SPIRIT_INSTILLING, "Spirit Instiller", recipeManager, registryManager);

// Items that are meant to be enchantable but not really
for (Map.Entry<ResourceKey<Item>, Item> item : BuiltInRegistries.ITEM.entrySet()) {
if (!item.getKey().location().getNamespace().equals(modId)) {
continue;
}

Item i = item.getValue();

ItemStack defaultStack = i.getDefaultInstance();
boolean isEnchantable = i.isEnchantable(defaultStack);
int enchantmentValue = i.getEnchantmentValue(defaultStack);
if(isEnchantable) {
if(enchantmentValue <= 0) {
SpectrumCommon.logWarning("[SANITY: Enchantability] " + item.getValue().getDescriptionId() + " is enchantable, but has an enchantment value of " + enchantmentValue);
}
}
if(enchantmentValue > 0) {
if(!isEnchantable) {
if(i == SpectrumItems.GILDED_BOOK.get()) {
continue;
}
SpectrumCommon.logWarning("[SANITY: Enchantability] " + item.getValue().getDescriptionId() + " is has a positive enchantment value, but its default instance is not enchantable");
}
// Items without crafting recipes
for(Item itemWithoutRecipe : modItems) {
if(!itemWithoutRecipe.builtInRegistryHolder().is(SpectrumItemTags.EXEMPT_FROM_RECIPE_DEBUG_CHECK)) {
SpectrumCommon.logWarning("[SANITY: Recipes] " + itemWithoutRecipe.getDescriptionId() + " does not have a recipe");
}
}

// Impossible to unlock block cloaks
for (Map.Entry<ResourceLocation, List<BlockState>> cloaks : RevelationRegistry.getBlockStateEntries().entrySet()) {
if (advancementLoader.get(cloaks.getKey()) == null) {
SpectrumCommon.logWarning("[SANITY: Block Cloaks] Advancement '" + cloaks.getKey().toString() + "' for block cloaking does not exist. Registered cloaks: " + cloaks.getValue().size());
SpectrumCommon.logWarning("[SANITY: Block Cloaks] Advancement '" + cloaks.getKey() + "' for block cloaking does not exist. Registered cloaks: " + cloaks.getValue().size());
}
}
for (Map.Entry<ResourceLocation, List<Item>> cloaks : RevelationRegistry.getItemEntries().entrySet()) {
if (advancementLoader.get(cloaks.getKey()) == null) {
SpectrumCommon.logWarning("[SANITY: Item Cloaks] Advancement '" + cloaks.getKey().toString() + "' for item cloaking does not exist. Registered cloaks: " + cloaks.getValue().size());
SpectrumCommon.logWarning("[SANITY: Item Cloaks] Advancement '" + cloaks.getKey() + "' for item cloaking does not exist. Registered cloaks: " + cloaks.getValue().size());
}
}

Expand Down Expand Up @@ -466,7 +482,7 @@ private static int execute(CommandSourceStack source, String modId) {
for (Map.Entry<ResourceKey<Item>, Item> item : BuiltInRegistries.ITEM.entrySet()) {
if (item.getValue() instanceof SpectrumCurioItem trinketItem) {
ResourceLocation advancementIdentifier = trinketItem.getUnlockIdentifier();
@Nullable AdvancementHolder advancementCriterionAdvancement = advancementLoader.get(advancementIdentifier);
AdvancementHolder advancementCriterionAdvancement = advancementLoader.get(advancementIdentifier);
if (advancementCriterionAdvancement == null) {
SpectrumCommon.logWarning("[SANITY: Trinkets] Trinket '" + item.getKey().location() + "' references advancement '" + advancementIdentifier + "' that does not exist");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class EnchanterRecipe extends GatedSpectrumRecipe<RecipeInput> {
protected final List<Ingredient> inputs; // first input is the center, all others around clockwise
protected final ItemStack output;

protected final int requiredExperience;
protected final int craftingTime;
protected final int requiredExperience;
protected final boolean noBenefitsFromYieldAndEfficiencyUpgrades;
// copy all modified components from the first stack in the ingredients to the output stack
protected final boolean copyComponents;
Expand All @@ -35,8 +35,8 @@ public EnchanterRecipe(String group, Optional<ResourceLocation> requiredAdvancem

this.inputs = inputs;
this.output = output;
this.requiredExperience = requiredExperience;
this.craftingTime = craftingTime;
this.requiredExperience = requiredExperience;
this.noBenefitsFromYieldAndEfficiencyUpgrades = noBenefitsFromYieldAndEfficiencyUpgrades;
this.copyComponents = copyComponents;

Expand Down Expand Up @@ -145,8 +145,8 @@ public static class Serializer implements RecipeSerializer<EnchanterRecipe> {
ItemStack.CODEC.listOf().optionalFieldOf("additional_recipe_viewer_results", List.of()).forGetter(recipe -> recipe.additionalResults),
Ingredient.CODEC_NONEMPTY.listOf().optionalFieldOf("ingredients", List.of()).forGetter(recipe -> recipe.inputs),
ItemStack.CODEC.fieldOf("result").forGetter(recipe -> recipe.output),
Codec.INT.optionalFieldOf("required_experience", 0).forGetter(recipe -> recipe.requiredExperience),
Codec.INT.optionalFieldOf("time", 200).forGetter(recipe -> recipe.craftingTime),
Codec.INT.optionalFieldOf("required_experience", 0).forGetter(recipe -> recipe.requiredExperience),
Codec.BOOL.optionalFieldOf("disable_yield_and_efficiency_upgrades", false).forGetter(recipe -> recipe.noBenefitsFromYieldAndEfficiencyUpgrades),
Codec.BOOL.optionalFieldOf("copy_components", false).forGetter(recipe -> recipe.copyComponents)
).apply(i, EnchanterRecipe::new));
Expand All @@ -158,8 +158,8 @@ public static class Serializer implements RecipeSerializer<EnchanterRecipe> {
ItemStack.STREAM_CODEC.apply(ByteBufCodecs.list()), recipe -> recipe.additionalResults,
Ingredient.CONTENTS_STREAM_CODEC.apply(ByteBufCodecs.list()), recipe -> recipe.inputs,
ItemStack.STREAM_CODEC, recipe -> recipe.output,
ByteBufCodecs.VAR_INT, recipe -> recipe.requiredExperience,
ByteBufCodecs.VAR_INT, recipe -> recipe.craftingTime,
ByteBufCodecs.VAR_INT, recipe -> recipe.requiredExperience,
ByteBufCodecs.BOOL, recipe -> recipe.noBenefitsFromYieldAndEfficiencyUpgrades,
ByteBufCodecs.BOOL, recipe -> recipe.copyComponents,
EnchanterRecipe::new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static Optional<PedestalRecipeTier> hasJustUnlockedANewRecipeTier(Resourc
if (AdvancementHelper.hasAdvancement(player, SpectrumAdvancements.BUILD_COMPLEX_PEDESTAL_STRUCTURE_WITHOUT_MOONSTONE)) {
return SpectrumMultiblocks.PEDESTAL_COMPLEX;
} else {
return SpectrumMultiblocks.PEDESTAL_COMPLEX_WITHOUT_MOONSTONE;
return SpectrumMultiblocks.PEDESTAL_COMPLEX_WITHOUT_ENGRAVINGS;
}
}
case ADVANCED -> {
Expand Down
Loading
Loading