Skip to content

Commit

Permalink
Config Refactoring, Update to TDL 1.2, Version Bump
Browse files Browse the repository at this point in the history
 - Refactored configs to allow for enabling and disabling to be in the same place the stats
 - TODO: Add enchantability to the config
  • Loading branch information
chronosacaria committed Apr 14, 2024
1 parent 3148878 commit 9a1bd1d
Show file tree
Hide file tree
Showing 34 changed files with 664 additions and 641 deletions.
60 changes: 44 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,32 +1,60 @@
Timefall Development License 1.1
Timefall Development License 1.2

Copyright (c) 2020-2023 Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved.
Copyright (c) 2020-2024 Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved.

Permissions are hereby granted, below, to any person having a copy of this software and/or its associated files:

Usage - You may use this software for private and public use. You may use this software as a library or integrate it with your code. This software may not be bundled with your code in any way, shape or form.
Copying - You may copy this software for private use or to contribute to this software.
Modification - You may modify this software for private use or to contribute to this software.
Publishing - You may not publish copies of this software.
Distributing - You may not distribute this software.
Sublicensing - You may not sublicense this software.
Selling - You may not sell this software, any part of this software, or restrict its access behind any paywall to monetised link.
Usage - You may use this software for private and public use. You may use this software as a library or
integrate it with your code. This software may not be bundled with your code in any way, shape or
form.
Copying - You may copy this software for private use or to contribute to this software.
Modification - You may modify this software for private use or to contribute to this software.
Publishing - You may not publish copies of this software.
Distributing - You may not distribute this software.
Sublicensing - You may not sublicense this software.
Selling - You may not sell this software, any part of this software, or restrict its access behind any paywall
to monetised link.

Special Cases and Commercial Usage Clarification:
In the cases of special or commercial use, including, but not limited to the production of other Minecraft mods, any
member of Timefall Development who are noted as the copyright holders of this software may provide written consent to
grant you a non-exclusive, non-transferable, world-wide license usage of any aspect of this software. This consent can
be revoked at any time by any member of Timefall Development.

Modpack Clarification:
Permission is granted for Modpacks to include this software as long as the copy of this software in the pack is done via a manifest which would download this software from its respective CurseForge or Modrinth page. In the case of explicit written permission by a copyright holder, this software may permitted to be used as an override, allowing for the direct integration with the Modpack in question. In the case of a resource pack, it may be added directly to a modpack's download.
Permission is granted for Modpacks to include this software as long as the copy of this software in the pack is done
via a manifest which would download this software from its respective CurseForge or Modrinth page. In the case of
explicit written permission by a copyright holder, this software may permitted to be used as an override, allowing for
the direct integration with the Modpack in question. In the case of a resource pack, it may be added directly to a
modpack's download.

Content Creator Clarification:
Permission is granted to Content Creators to make use of and monetise content that is created using this software. Whilst not required of a Content Creator, a link back to the CurseForge or Modrinth page of this software is greatly appreciated and encouraged.
Permission is granted to Content Creators to make use of and monetise content that is created using this software.
Whilst not required of a Content Creator, a link back to the CurseForge or Modrinth page of this software is greatly
appreciated and encouraged.

Porting Clarification:
Permission is not granted to any user of this software to make ports of this software to another mod loader. This means that if this software was created for the Fabric Mod Loader, it may not be ported to the Forge Mod Loader or Quilt Mod Loader without express written permission from the copyright holders. Permission is granted to any user to fork the repository of this software and create a port to a different mod loader if, and only if, the port is to be submitted to the copyright holders as a Pull Request wherever this software's source code is hosted by the copyright holders. The submitter of the Pull Request containing the porting code agrees that Timefall Development is free to negotiate the terms for the use of the submitted code. This includes, but will often not be the case that, submissions are used without compensation of any kind.
Permission is not granted to any user of this software to make ports of this software to another mod loader. This means
that if this software was created for the Fabric Mod Loader, it may not be ported to the Forge Mod Loader or Quilt Mod
Loader without express written permission from the copyright holders. Permission is granted to any user to fork the
repository of this software and create a port to a different mod loader if, and only if, the port is to be submitted to
the copyright holders as a Pull Request wherever this software's source code is hosted by the copyright holders. The
submitter of the Pull Request containing the porting code agrees that Timefall Development is free to negotiate the
terms for the use of the submitted code. This includes, but will often not be the case that, submissions are used
without compensation of any kind.

Definition of 'Our Sources' in this license:
Our Sources in this license means a copy of this software or its associated files that come directly from the owners of this software, an example are the files uploaded by us on our CurseForge or Modrinth Pages.
Our Sources in this license means a copy of this software or its associated files that come directly from the owners of
this software, an example are the files uploaded by us on our CurseForge or Modrinth Pages.

Definition of "Content Creator" in this license:
Content Creator, in this license, means anyone who creates content on YouTube or Twitch regardless of affiliation or partner status.
Content Creator, in this license, means anyone who creates content on YouTube or Twitch regardless of affiliation or
partner status.

The above copyright notice and these permission notices shall be included in all copies or substantial portions of the Software.
The above copyright notice and these permission notices shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.14.21

# Mod Properties
mod_version=9.0.1
mod_version=9.0.2
maven_group=chronosacaria
archives_base_name=mcdw

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

Expand All @@ -30,14 +29,13 @@ public interface IInnateEnchantment {
* The following code is from Spectrum and can be found here:<br/>
* <a href = "https://github.com/DaFuqs/Spectrum/blob/1.19-deeper-down/src/main/java/de/dafuqs/spectrum/items/Preenchanted.java#L13">Preenchanted#getDefaultEnchantedStack</a>
*/
default @Nullable ItemStack getInnateEnchantedStack(Item item) {
default ItemStack getInnateEnchantedStack(Item item) {
ItemStack itemStack = new ItemStack(item);
if (Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) {
Map<Enchantment, Integer> map = getInnateEnchantments();
if (map != null) {
if (Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS))
for (Enchantment enchantment : map.keySet())
itemStack.addEnchantment(enchantment, map.get(enchantment));
for (Enchantment enchantment : map.keySet())
itemStack.addEnchantment(enchantment, map.get(enchantment));
}
}
return itemStack;
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import chronosacaria.mcdw.bases.McdwShortbow;
import chronosacaria.mcdw.configs.CompatibilityFlags;
import chronosacaria.mcdw.enums.EnchantmentsID;
import chronosacaria.mcdw.enums.SettingsID;
import chronosacaria.mcdw.registries.EnchantsRegistry;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
import net.minecraft.registry.Registries;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.sound.SoundCategory;
Expand All @@ -24,6 +28,8 @@
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;

import static chronosacaria.mcdw.Mcdw.CONFIG;

public class CleanlinessHelper {
static final Random random = new Random();

Expand Down Expand Up @@ -186,4 +192,48 @@ public static void addPPEEnchantments(ItemStack itemStack, IMcdwEnchantedArrow p
ppe.mcdw$setWildRageLevel(wildRageLevel);
}
}

public static Map<Enchantment, Integer> mcdw$checkInnateEnchantmentEnabled(int level, Object... enchantments) {
LinkedHashMap<Enchantment, Integer> enchantmentIntegerLinkedHashMap = new LinkedHashMap<>();
for (Object enchantment : enchantments) {
if (enchantment instanceof EnchantmentsID id) {
if (CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(id).mcdw$getIsEnabled()
&& CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) {
enchantmentIntegerLinkedHashMap.put(EnchantsRegistry.enchantments.get(id), level);
}
} else if (enchantment instanceof Enchantment vanillaEnchantment
&& CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) {
enchantmentIntegerLinkedHashMap.put(vanillaEnchantment, level);
}
}
return enchantmentIntegerLinkedHashMap;
}

public static String materialToString(ToolMaterial toolMaterial) {
if (toolMaterial == ToolMaterials.WOOD)
return "wood";
else if (toolMaterial == ToolMaterials.STONE)
return "stone";
else if (toolMaterial == ToolMaterials.GOLD)
return "gold";
else if (toolMaterial == ToolMaterials.IRON)
return "iron";
else if (toolMaterial == ToolMaterials.DIAMOND)
return "diamond";
else if (toolMaterial == ToolMaterials.NETHERITE)
return "netherite";
else
return "none";
}

public static ToolMaterial stringToMaterial(String material) {
return switch (material) {
case "wood" -> ToolMaterials.WOOD;
case "stone" -> ToolMaterials.STONE;
case "gold" -> ToolMaterials.GOLD;
case "diamond" -> ToolMaterials.DIAMOND;
case "netherite" -> ToolMaterials.NETHERITE;
default -> ToolMaterials.IRON;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,9 @@

@Config(name = "mcdw_items_registry")
public class McdwEnableItemsConfig implements ConfigData {

public final LinkedHashMap<SwordsID, Boolean> SWORDS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<AxesID, Boolean> AXES_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<DoubleAxesID, Boolean> DOUBLE_AXES_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<DaggersID, Boolean> DAGGERS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<SoulDaggersID, Boolean> SOUL_DAGGERS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<HammersID, Boolean> HAMMERS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<GauntletsID, Boolean> GAUNTLETS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<SicklesID, Boolean> SICKLES_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<ScythesID, Boolean> SCYTHES_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<PicksID, Boolean> PICKS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<GlaivesID, Boolean> GLAIVES_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<SpearsID, Boolean> SPEARS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<StavesID, Boolean> STAVES_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<WhipsID, Boolean> WHIPS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<BowsID, Boolean> BOWS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<ShortbowsID, Boolean> SHORTBOWS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<LongbowsID, Boolean> LONGBOWS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<CrossbowsID, Boolean> CROSSBOWS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<ShieldsID, Boolean> SHIELDS_ENABLED = new LinkedHashMap<>();
public final LinkedHashMap<ItemsID, Boolean> ITEMS_ENABLED = new LinkedHashMap<>();

public McdwEnableItemsConfig() {
for (SwordsID swordsID : SwordsID.values())
SWORDS_ENABLED.put(swordsID, true);

for (AxesID axesID : AxesID.values())
AXES_ENABLED.put(axesID, true);

for (DoubleAxesID doubleAxesID : DoubleAxesID.values())
DOUBLE_AXES_ENABLED.put(doubleAxesID, true);

for (DaggersID daggersID : DaggersID.values())
DAGGERS_ENABLED.put(daggersID, true);

for (SoulDaggersID soulDaggersID : SoulDaggersID.values())
SOUL_DAGGERS_ENABLED.put(soulDaggersID, true);

for (HammersID hammersID : HammersID.values())
HAMMERS_ENABLED.put(hammersID, true);

for (GauntletsID gauntletsID : GauntletsID.values())
GAUNTLETS_ENABLED.put(gauntletsID, true);

for (SicklesID sicklesID : SicklesID.values())
SICKLES_ENABLED.put(sicklesID, true);

for (ScythesID scythesID : ScythesID.values())
SCYTHES_ENABLED.put(scythesID, true);

for (PicksID picksID : PicksID.values())
PICKS_ENABLED.put(picksID, true);

for (GlaivesID glaivesID : GlaivesID.values())
GLAIVES_ENABLED.put(glaivesID, true);

for (SpearsID spearsID : SpearsID.values())
SPEARS_ENABLED.put(spearsID, true);

for (StavesID stavesID : StavesID.values())
STAVES_ENABLED.put(stavesID, true);

for (WhipsID whipsID : WhipsID.values())
WHIPS_ENABLED.put(whipsID, true);

for (BowsID bowsID : BowsID.values())
BOWS_ENABLED.put(bowsID, true);

for (ShortbowsID shortBowsID : ShortbowsID.values())
SHORTBOWS_ENABLED.put(shortBowsID, true);

for (LongbowsID longBowsID : LongbowsID.values())
LONGBOWS_ENABLED.put(longBowsID, true);

for (CrossbowsID crossbowsID : CrossbowsID.values())
CROSSBOWS_ENABLED.put(crossbowsID, true);

for (ShieldsID shieldsID : ShieldsID.values())
SHIELDS_ENABLED.put(shieldsID, true);

for (ItemsID itemsID : ItemsID.values())
ITEMS_ENABLED.put(itemsID, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class McdwNewLootConfig implements ConfigData {
public final LinkedHashMap<ShieldsID, Integer> SHIELD_SPAWN_RATES = new LinkedHashMap<>();

public McdwNewLootConfig(){
WEAPONS_ENABLED_IN_LOOTTABLES.put(SettingsID.ENABLE_WEAPONS_IN_LOOTTABLES, true);
WEAPONS_ENABLED_IN_LOOTTABLES.put(SettingsID.ENABLE_WEAPONS_IN_LOOT_TABLES, true);

/* LOOT TABLES */

Expand Down
Loading

0 comments on commit 9a1bd1d

Please sign in to comment.