Skip to content

Commit

Permalink
1.21 Update 2
Browse files Browse the repository at this point in the history
- Added Datagen to the Fabric side for Tags and Enchantments; the intention is to generate data on the Fabric side and manually copy them to the NeoForge side
- Refactored Artifact classes to no longer need the enums that created their IDs
- Added the support necessary for basic cooldown functionality
- Added proper registry checks for mixins that were using enums
- Corrected Artifact Lootpools in config values
- Began basic refactoring of configs to allow for tag usage for artifact grouping
- Removed pluralisations of package names to bring mod into 1.21 package expectations
- Removed `enchantments` package and contents as they are no longer necessary
- Removed `enums` package and contents as they are no longer necessary
- Removed `EnchantsRegistry` as it is no longer necessary
- Removed `McdarEnchantmentHelper` as it was only helping with cooldown implementation, which has been moved to the `EnchantmentEffects` class
- Current Issue: When attempting to generate the tag files via Datagen, it is unable to complete because of the following IllegalStateException: "This registry can't create intrusive holders"
  • Loading branch information
chronosacaria committed Nov 18, 2024
1 parent d812ff5 commit e889a9d
Show file tree
Hide file tree
Showing 86 changed files with 606 additions and 1,409 deletions.
7 changes: 2 additions & 5 deletions common/src/main/java/dev/timefall/mcdar/McdarCommon.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package dev.timefall.mcdar;

import dev.timefall.mcdar.registries.ArtifactsRegistry;
import dev.timefall.mcdar.registries.ItemGroupRegistry;
import dev.timefall.mcdar.registries.StatusEffectRegistry;
import dev.timefall.mcdar.registries.SummonedEntityAttributeRegistry;
import dev.timefall.mcdar.registry.*;

public class McdarCommon {

public static void initialize() {
//CONFIG = AutoConfig.getConfigHolder(McdarConfig.class).getConfig();
ArtifactsRegistry.register();
ItemGroupRegistry.register();
//EnchantsRegistry.register();
EnchantmentRegistry.register();
StatusEffectRegistry.register();
SummonedEntityAttributeRegistry.register();
//SummonedEntityRegistry.register();
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/dev/timefall/mcdar/api/AOEHelper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.timefall.mcdar.api;

import dev.timefall.mcdar.mixin.CreeperEntityAccessor;
import dev.timefall.mcdar.registries.StatusEffectRegistry;
import dev.timefall.mcdar.registry.StatusEffectRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
Expand Down
19 changes: 13 additions & 6 deletions common/src/main/java/dev/timefall/mcdar/api/CleanlinessHelper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.timefall.mcdar.api;

import dev.timefall.mcdar.config.McdarArtifactsStatsConfig;
import dev.timefall.mcdar.enums.*;
import dev.timefall.mcdar.effects.EnchantmentEffects;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
Expand Down Expand Up @@ -109,7 +108,7 @@ public static boolean isCoolingDown(PlayerEntity player, Item item) {
EquipmentSlot equipmentSlot = hand == Hand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND;
itemStack.damage(1, player, equipmentSlot);
}
McdarEnchantmentHelper.mcdar$cooldownHelper(player, artifact, maxCooldown);
EnchantmentEffects.mcdar$cooldownHelper(player, artifact, maxCooldown);
return new TypedActionResult<>(ActionResult.SUCCESS, itemStack);
}

Expand All @@ -133,7 +132,7 @@ public static boolean isCoolingDown(PlayerEntity player, Item item) {
itemUsageContext.getStack().damage(1, itemUsageContextPlayer, equipmentSlot);
}

McdarEnchantmentHelper.mcdar$cooldownHelper(
EnchantmentEffects.mcdar$cooldownHelper(
itemUsageContextPlayer,
artifact,
cooldown);
Expand All @@ -144,9 +143,15 @@ public static boolean isCoolingDown(PlayerEntity player, Item item) {
return ActionResult.SUCCESS;
}

public static ItemStack mcdar$getEitherHandItemStack(PlayerEntity playerEntity) {
return !playerEntity.getOffHandStack().isEmpty()
? playerEntity.getOffHandStack()
: playerEntity.getMainHandStack();
}
/*
public static int mcdar$artifactIDToItemCooldownTime(Item artifactItem) {
int cooldownLevel = 1/*EnchantmentHelper.getLevel(RegistryEntry.of(EnchantsRegistry.COOLDOWN), artifactItem.getDefaultStack())*/;
//if (artifactItem instanceof IArtifactItem) {
int cooldownLevel = EnchantmentHelper.getLevel(RegistryEntry.of(EnchantsRegistry.COOLDOWN), artifactItem.getDefaultStack());
if (artifactItem instanceof IArtifactItem) {
for (AgilityArtifactID agilityArtifactID : AgilityArtifactID.values())
if (artifactItem.asItem() == agilityArtifactID.mcdar$getItem()
&& McdarArtifactsStatsConfig.CONFIG.AGILITY_ARTIFACT_STATS.get(agilityArtifactID)
Expand Down Expand Up @@ -186,4 +191,6 @@ public static boolean isCoolingDown(PlayerEntity player, Item item) {
//}
return 0;
}
*/
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package dev.timefall.mcdar.api;

import dev.timefall.mcdar.enums.*;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.registry.RegistryKey;

import java.util.List;
import java.util.Set;

public class GroupedObjectsHelper {
Expand All @@ -24,6 +22,7 @@ public class GroupedObjectsHelper {
public static final Set<RegistryKey<LootTable>> ALL_ARTIFACTS_DUNGEON_LOOT_TABLES =
Set.of(LootTables.ABANDONED_MINESHAFT_CHEST, LootTables.SIMPLE_DUNGEON_CHEST, LootTables.SHIPWRECK_TREASURE_CHEST);

/*
public static final List<IArtifactItem> illagerArtifacts = List.of(
AgilityArtifactID.DEATH_CAP_MUSHROOM,
DamagingArtifactID.BLAST_FUNGUS,
Expand Down Expand Up @@ -90,4 +89,5 @@ public class GroupedObjectsHelper {
SummoningArtifactID.GOLEM_KIT,
SummoningArtifactID.TASTY_BONE,
SummoningArtifactID.WONDERFUL_WHEAT);
*/
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.timefall.mcdar.artifacts;

import dev.timefall.mcdar.enums.AgilityArtifactID;
import net.minecraft.item.Item;

public class ArtifactAgilityItem extends Item {

public final AgilityArtifactID id;

public ArtifactAgilityItem(AgilityArtifactID id, int artifactDurability) {
public ArtifactAgilityItem(int artifactDurability) {
super(new Settings().maxCount(1).maxDamage(artifactDurability));
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.timefall.mcdar.artifacts;

import dev.timefall.mcdar.enums.DamagingArtifactID;
import net.minecraft.item.Item;

public class ArtifactDamagingItem extends Item {

public final DamagingArtifactID id;

public ArtifactDamagingItem(DamagingArtifactID id, int artifactDurability) {
public ArtifactDamagingItem(int artifactDurability) {
super(new Settings().maxCount(1).maxDamage(artifactDurability));
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.timefall.mcdar.artifacts;

import dev.timefall.mcdar.enums.DefensiveArtifactID;
import net.minecraft.item.Item;

public class ArtifactDefensiveItem extends Item {

public final DefensiveArtifactID id;

public ArtifactDefensiveItem(DefensiveArtifactID id, int artifactDurability) {
public ArtifactDefensiveItem(int artifactDurability) {
super(new Settings().maxCount(1).maxDamage(artifactDurability));
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.timefall.mcdar.artifacts;

import dev.timefall.mcdar.enums.QuiverArtifactID;
import net.minecraft.item.Item;

public class ArtifactQuiverItem extends Item {

public final QuiverArtifactID id;

public ArtifactQuiverItem(QuiverArtifactID id, int artifactDurability) {
public ArtifactQuiverItem(int artifactDurability) {
super(new Settings().maxCount(1).maxDamage(artifactDurability));
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.timefall.mcdar.artifacts;

import dev.timefall.mcdar.enums.StatusInflictingArtifactID;
import net.minecraft.item.Item;

public class ArtifactStatusInflictingItem extends Item {

public final StatusInflictingArtifactID id;

public ArtifactStatusInflictingItem(StatusInflictingArtifactID id, int artifactDurability) {
public ArtifactStatusInflictingItem(int artifactDurability) {
super(new Settings().maxCount(1).maxDamage(artifactDurability));
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.timefall.mcdar.artifacts;

import dev.timefall.mcdar.enums.SummoningArtifactID;
import net.minecraft.item.Item;

public class ArtifactSummoningItem extends Item {

public final SummoningArtifactID id;

public ArtifactSummoningItem(SummoningArtifactID id, int artifactDurability) {
public ArtifactSummoningItem(int artifactDurability) {
super(new Settings().maxCount(1).maxDamage(artifactDurability));
this.id = id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.timefall.mcdar.api.CleanlinessHelper;
import dev.timefall.mcdar.config.McdarArtifactsStatsConfig;
import dev.timefall.mcdar.effects.ArtifactEffects;
import dev.timefall.mcdar.enums.DamagingArtifactID;
import dev.timefall.mcdar.effects.EnchantmentEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
Expand All @@ -22,7 +22,6 @@ public class BlastFungusItem extends ArtifactDamagingItem{

public BlastFungusItem() {
super(
DamagingArtifactID.BLAST_FUNGUS,
McdarArtifactsStatsConfig.CONFIG.mcdar$getDamagingArtifactStats().BLAST_FUNGUS_STATS.mcdar$getDurability()
);
}
Expand All @@ -33,14 +32,16 @@ public TypedActionResult<ItemStack> use (World world, PlayerEntity user, Hand ha
float range = McdarArtifactsStatsConfig.CONFIG.mcdar$getDamagingArtifactStats().BLAST_FUNGUS_STATS.mcdar$getInnerStat().mcdar$getRange();
float damage = McdarArtifactsStatsConfig.CONFIG.mcdar$getDamagingArtifactStats().BLAST_FUNGUS_STATS.mcdar$getInnerStat().mcdar$getDamage();
int maxCooldownEnchantmentTime = McdarArtifactsStatsConfig.CONFIG.mcdar$getDamagingArtifactStats().BLAST_FUNGUS_STATS.mcdar$getMaxCooldownEnchantmentTime();
int modifiedCooldownEnchantmentTime = EnchantmentEffects.cooldownEffect(maxCooldownEnchantmentTime, user, world);


CleanlinessHelper.playCenteredSound(user, SoundEvents.ENTITY_GENERIC_EXPLODE.value(), 1.0F, 1.0F);
ArtifactEffects.causeBlastFungusExplosions(user, range, damage);
if (!user.isCreative()) {
EquipmentSlot equipmentSlot = hand == Hand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND;
itemStack.damage(1, user, equipmentSlot);
}
user.getItemCooldownManager().set(this, maxCooldownEnchantmentTime);
user.getItemCooldownManager().set(this, modifiedCooldownEnchantmentTime);

return new TypedActionResult<>(ActionResult.SUCCESS, itemStack);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import dev.timefall.mcdar.api.CleanlinessHelper;
import dev.timefall.mcdar.config.McdarArtifactsStatsConfig;
import dev.timefall.mcdar.enums.AgilityArtifactID;
import dev.timefall.mcdar.effects.EnchantmentEffects;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
Expand All @@ -17,7 +17,6 @@
public class BootsOfSwiftnessItem extends ArtifactAgilityItem{
public BootsOfSwiftnessItem() {
super(
AgilityArtifactID.BOOTS_OF_SWIFTNESS,
McdarArtifactsStatsConfig.CONFIG.mcdar$getAgilityArtifactStats().BOOTS_OF_SWIFTNESS_STATS.mcdar$getDurability()
);
}
Expand All @@ -26,12 +25,13 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han
int duration = McdarArtifactsStatsConfig.CONFIG.mcdar$getAgilityArtifactStats().BOOTS_OF_SWIFTNESS_STATS.mcdar$getInnerStat().mcdar$getDuration();
int amplifier = McdarArtifactsStatsConfig.CONFIG.mcdar$getAgilityArtifactStats().BOOTS_OF_SWIFTNESS_STATS.mcdar$getInnerStat().mcdar$getAmplifier();
int maxCooldownEnchantmentTime = McdarArtifactsStatsConfig.CONFIG.mcdar$getAgilityArtifactStats().BOOTS_OF_SWIFTNESS_STATS.mcdar$getMaxCooldownEnchantmentTime();
int modifiedCooldownEnchantmentTime = EnchantmentEffects.cooldownEffect(maxCooldownEnchantmentTime, user, world);

return CleanlinessHelper.mcdar$cleanUseWithOptionalStatus(
user,
hand,
this,
maxCooldownEnchantmentTime,
modifiedCooldownEnchantmentTime,
StatusEffects.SPEED,
duration,
amplifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import dev.timefall.mcdar.api.CleanlinessHelper;
import dev.timefall.mcdar.config.McdarArtifactsStatsConfig;
import dev.timefall.mcdar.effects.EnchantmentEffects;
import dev.timefall.mcdar.entities.SummonedEntityType;
import dev.timefall.mcdar.enums.SummoningArtifactID;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.tooltip.TooltipType;
Expand All @@ -15,19 +15,19 @@
public class BuzzyNestItem extends ArtifactSummoningItem{
public BuzzyNestItem() {
super(
SummoningArtifactID.BUZZY_NEST,
McdarArtifactsStatsConfig.CONFIG.mcdar$getSummoningArtifactStats().BUZZY_NEST_STATS.mcdar$getDurability()
);
}

public ActionResult useOnBlock(ItemUsageContext itemUsageContext) {
int maxCooldownEnchantmentTime = McdarArtifactsStatsConfig.CONFIG.mcdar$getSummoningArtifactStats().BUZZY_NEST_STATS.mcdar$getMaxCooldownEnchantmentTime();
int modifiedCooldownEnchantmentTime = EnchantmentEffects.cooldownEffect(maxCooldownEnchantmentTime, itemUsageContext.getPlayer(), itemUsageContext.getWorld());

return CleanlinessHelper.mcdar$cleanUseSummon(
itemUsageContext,
this,
SummonedEntityType.BUZZY_NEST_BEE_ENTITY,
maxCooldownEnchantmentTime
modifiedCooldownEnchantmentTime
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.timefall.mcdar.api.AOEHelper;
import dev.timefall.mcdar.api.CleanlinessHelper;
import dev.timefall.mcdar.config.McdarArtifactsStatsConfig;
import dev.timefall.mcdar.enums.StatusInflictingArtifactID;
import dev.timefall.mcdar.effects.EnchantmentEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
Expand All @@ -21,7 +21,6 @@
public class CorruptedSeedsItem extends ArtifactStatusInflictingItem{
public CorruptedSeedsItem() {
super(
StatusInflictingArtifactID.CORRUPTED_SEEDS,
McdarArtifactsStatsConfig.CONFIG.mcdar$getStatusInflictingArtifactStats().CORRUPTED_SEEDS_STATS.mcdar$getDurability()
);
}
Expand All @@ -33,6 +32,7 @@ public TypedActionResult<ItemStack> use (World world, PlayerEntity user, Hand ha
int amplifier = McdarArtifactsStatsConfig.CONFIG.mcdar$getStatusInflictingArtifactStats().CORRUPTED_SEEDS_STATS.mcdar$getInnerStat().mcdar$getAmplifier();
int amplifier2 = McdarArtifactsStatsConfig.CONFIG.mcdar$getStatusInflictingArtifactStats().CORRUPTED_SEEDS_STATS.mcdar$getInnerStat().mcdar$getAmplifier2();
int maxCooldownEnchantmentTime = McdarArtifactsStatsConfig.CONFIG.mcdar$getStatusInflictingArtifactStats().CORRUPTED_SEEDS_STATS.mcdar$getMaxCooldownEnchantmentTime();
int modifiedCooldownEnchantmentTime = EnchantmentEffects.cooldownEffect(maxCooldownEnchantmentTime, user, world);

AOEHelper.afflictNearbyEntities(user,range, new StatusEffectInstance(StatusEffects.SLOWNESS, duration, amplifier),
new StatusEffectInstance(StatusEffects.POISON, duration, amplifier2));
Expand All @@ -43,7 +43,7 @@ public TypedActionResult<ItemStack> use (World world, PlayerEntity user, Hand ha
}


user.getItemCooldownManager().set(this, maxCooldownEnchantmentTime);
user.getItemCooldownManager().set(this, modifiedCooldownEnchantmentTime);

return new TypedActionResult<>(ActionResult.SUCCESS, itemStack);
}
Expand Down
Loading

0 comments on commit e889a9d

Please sign in to comment.