diff --git a/src/generated/resources/.cache/69ee5e809dff011efe049b68501078221ca37cb0 b/src/generated/resources/.cache/69ee5e809dff011efe049b68501078221ca37cb0 index 16c6b10d..2ea64b3e 100644 --- a/src/generated/resources/.cache/69ee5e809dff011efe049b68501078221ca37cb0 +++ b/src/generated/resources/.cache/69ee5e809dff011efe049b68501078221ca37cb0 @@ -1,4 +1,4 @@ -// 1.21.1 2024-12-07T12:22:16.5077405 Item Models: justdirethings +// 1.21.1 2024-12-08T14:36:24.9489547 Item Models: justdirethings c197a1b2a5ae31fcfabfe6cab9ab95a9dc0e1af6 assets/justdirethings/models/item/blazegold_axe.json dddf215922d40d92c2d8bce4229f2e2af8b3c7ba assets/justdirethings/models/item/blazegold_axe_active.json 6396fb6e503760080534bc26337236d4d09a4cb8 assets/justdirethings/models/item/blazegold_block.json @@ -293,6 +293,7 @@ b10bbca68270e48599af7174531b0235c8e7c9a4 assets/justdirethings/models/item/playe 6ac490fc1ca0a7b3663a770a09e3cd3ade652bb5 assets/justdirethings/models/item/polymorphic_catalyst.json c51b41b9c484aa6724dfe24732b06a196ee05ffe assets/justdirethings/models/item/polymorphic_fluid_bucket.json af285bda921f3fea66dd01b7b30fadfd8669ee14 assets/justdirethings/models/item/polymorphic_wand.json +481f0aeeff37a0ab6393bd83161537fd688e0a2e assets/justdirethings/models/item/polymorphic_wand_v2.json 403d14795debb89f422eefb10f3b8188e148190a assets/justdirethings/models/item/portal_fluid_bucket.json ea9b4416ff95371822cbc5808fd425323b170cc9 assets/justdirethings/models/item/portal_fluid_catalyst.json d8ea68a75b8b49f7765e715d62ad23c2f1939281 assets/justdirethings/models/item/raw_blazegold.json diff --git a/src/generated/resources/.cache/7e4928c403af173c11f4d1675461c34bf5d23056 b/src/generated/resources/.cache/7e4928c403af173c11f4d1675461c34bf5d23056 index e7945e0e..9099077c 100644 --- a/src/generated/resources/.cache/7e4928c403af173c11f4d1675461c34bf5d23056 +++ b/src/generated/resources/.cache/7e4928c403af173c11f4d1675461c34bf5d23056 @@ -1,4 +1,4 @@ -// 1.21.1 2024-12-07T15:14:23.6887728 Tags for minecraft:entity_type mod id justdirethings +// 1.21.1 2024-12-08T14:36:24.946453 Tags for minecraft:entity_type mod id justdirethings b7ee8eaecff151e619b9a22ecae620a5b3ce15a0 data/c/tags/entity_type/teleporting_not_supported.json e00f2931577049b9a4400a87ed9c249373be376c data/justdirethings/tags/entity_type/creature_catcher_deny.json 669025814936e708d42d9d0a5b88c11e62cf12ef data/justdirethings/tags/entity_type/no_ai_deny.json @@ -7,4 +7,5 @@ b7ee8eaecff151e619b9a22ecae620a5b3ce15a0 data/justdirethings/tags/entity_type/pa b7ee8eaecff151e619b9a22ecae620a5b3ce15a0 data/justdirethings/tags/entity_type/paradox_deny.json 263995270039da950f2e27b535f1b7c71a5f5423 data/justdirethings/tags/entity_type/polymorphic_hostile.json d53ddb5be22b17ec02beda6e2e3695f074abc70f data/justdirethings/tags/entity_type/polymorphic_peaceful.json +669025814936e708d42d9d0a5b88c11e62cf12ef data/justdirethings/tags/entity_type/polymorphic_target_deny.json 6a890ea62d03cc1110fa8d1fe5a0669082d9d96b data/minecraft/tags/entity_type/arrows.json diff --git a/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb b/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb index b8a522b2..c557f786 100644 --- a/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb +++ b/src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb @@ -1,2 +1,2 @@ -// 1.21.1 2024-12-07T15:35:26.0358297 Languages: en_us for mod: justdirethings -dc7bbea3a13870709a7bafccf7758ac21f7bffec assets/justdirethings/lang/en_us.json +// 1.21.1 2024-12-08T15:06:57.5943778 Languages: en_us for mod: justdirethings +95e97e5674d08f0f4e96cc7bef842e9923332325 assets/justdirethings/lang/en_us.json diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 534a7276..74c712af 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,4 +1,4 @@ -// 1.21.1 2024-12-07T15:39:40.3847313 Recipes +// 1.21.1 2024-12-08T14:36:24.9704735 Recipes 39cd44c838de7f56aeac73aec8b3bfb64ad7fec2 data/justdirethings/advancement/recipes/building_blocks/blazegold_ingot_9x9.json 2f2a0f948f272df9713010dbcb75beb81c328b01 data/justdirethings/advancement/recipes/building_blocks/celestigem_9x9.json 4c183b67eff4bc24117606cdc45ebcd987dd4138 data/justdirethings/advancement/recipes/building_blocks/charcoal_9x9.json @@ -308,6 +308,7 @@ dad2a7782e9a1e1d8e7099a6596640b309925ed9 data/justdirethings/advancement/recipes 858af81155eff55f8b4cff67f9bade9f64071902 data/justdirethings/advancement/recipes/misc/polymorphic_catalyst.json d028ad197c2078a4c30eafcbde2282aff17f1df1 data/justdirethings/advancement/recipes/misc/polymorphic_fluid_block-fluiddrop.json 8d77029166db109c5f6f34ecd68888bbb458b36f data/justdirethings/advancement/recipes/misc/polymorphic_wand.json +cbd75ef6a410d18537c75609ed9a8dc03e4eedf6 data/justdirethings/advancement/recipes/misc/polymorphic_wand_v2.json 5570c3f5f6bf47c6d6026ead547ac4516bad5da9 data/justdirethings/advancement/recipes/misc/portalgun.json f921713cd6dfa2ad74a0b7144f7778c2fe33bc72 data/justdirethings/advancement/recipes/misc/portalgun_v2.json c811419aba5aeaf1be214e7f29492a7ccb300ddd data/justdirethings/advancement/recipes/misc/portal_fluid_block-goospread.json @@ -698,6 +699,7 @@ cc73b7c24448814a0e8663c8065a6625cbd30072 data/justdirethings/recipe/pocket_gener 035ed5c68eac114352b166d38b7f8308e5db63c0 data/justdirethings/recipe/polymorphic_catalyst.json 6cfafeb9ae58abc121bd78f1c67b11aedec8297b data/justdirethings/recipe/polymorphic_fluid_block-fluiddrop.json 52f1c1f4d04ba53cc38b2dbfc49fb1d19a35b344 data/justdirethings/recipe/polymorphic_wand.json +f0837b24753abb981c18893958974a4306f8b4d8 data/justdirethings/recipe/polymorphic_wand_v2.json 1494fe69edb92207b18a251b9c4a4d7ef2487b45 data/justdirethings/recipe/portalgun.json 4ed1bcc18461694ef969bb8820a6a4433cec054f data/justdirethings/recipe/portalgun_v2.json 881053ecbb4f27590666128cfd52f2c212cf6a37 data/justdirethings/recipe/portal_fluid_block-goospread.json diff --git a/src/generated/resources/assets/justdirethings/lang/en_us.json b/src/generated/resources/assets/justdirethings/lang/en_us.json index dcefc0ca..f13db59e 100644 --- a/src/generated/resources/assets/justdirethings/lang/en_us.json +++ b/src/generated/resources/assets/justdirethings/lang/en_us.json @@ -145,6 +145,7 @@ "item.justdirethings.polymorphic_catalyst": "Polymorphic Catalyst", "item.justdirethings.polymorphic_fluid_bucket": "Polymorphic Fluid Bucket", "item.justdirethings.polymorphic_wand": "Polymorphic Wand", + "item.justdirethings.polymorphic_wand_v2": "Advanced Polymorphic Wand", "item.justdirethings.portal_fluid_bucket": "Portal Fluid Bucket", "item.justdirethings.portal_fluid_catalyst": "Portal Fluid Catalyst", "item.justdirethings.portalgun": "Portal Gun", @@ -254,6 +255,7 @@ "justdirethings.ability.orexray": "X-Ray", "justdirethings.ability.phase": "Phase", "justdirethings.ability.polymorph_random": "Random Polymorph", + "justdirethings.ability.polymorph_target": "Targeted Polymorph", "justdirethings.ability.potionarrow": "Potion Arrow", "justdirethings.ability.runspeed": "Run Speed", "justdirethings.ability.skysweeper": "Sky Sweeper", @@ -353,6 +355,7 @@ "justdirethings.pocketgeneratorfuelstack": "Fuel: %f %s", "justdirethings.pocketgeneratornofuel": "Fuel Empty", "justdirethings.polymorphicfluidamt": "Polymorphic Fluid: %s / %s", + "justdirethings.polymorphset": "Polymorph Target: %s", "justdirethings.portalfluidamt": "Portal Fluid: %s / %s", "justdirethings.potionarrow.detailtext": "Insert a Potion Canister to apply effects to enemies", "justdirethings.potionarrow.flavortext": "Like Vanilla, without inventory issues...", diff --git a/src/generated/resources/assets/justdirethings/models/item/polymorphic_wand_v2.json b/src/generated/resources/assets/justdirethings/models/item/polymorphic_wand_v2.json new file mode 100644 index 00000000..534cd032 --- /dev/null +++ b/src/generated/resources/assets/justdirethings/models/item/polymorphic_wand_v2.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "justdirethings:item/polymorphic_wand_v2" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/justdirethings/advancement/recipes/misc/polymorphic_wand_v2.json b/src/generated/resources/data/justdirethings/advancement/recipes/misc/polymorphic_wand_v2.json new file mode 100644 index 00000000..1a74824d --- /dev/null +++ b/src/generated/resources/data/justdirethings/advancement/recipes/misc/polymorphic_wand_v2.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_eclipsealloy_ingot": { + "conditions": { + "items": [ + { + "items": "justdirethings:eclipsealloy_ingot" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "justdirethings:polymorphic_wand_v2" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_eclipsealloy_ingot" + ] + ], + "rewards": { + "recipes": [ + "justdirethings:polymorphic_wand_v2" + ] + } +} \ No newline at end of file diff --git a/src/generated/resources/data/justdirethings/recipe/polymorphic_wand_v2.json b/src/generated/resources/data/justdirethings/recipe/polymorphic_wand_v2.json new file mode 100644 index 00000000..68f0bdf4 --- /dev/null +++ b/src/generated/resources/data/justdirethings/recipe/polymorphic_wand_v2.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "group": "justdirethings", + "key": { + "b": { + "item": "justdirethings:eclipsealloy_ingot" + }, + "i": { + "item": "justdirethings:celestigem" + }, + "r": { + "item": "justdirethings:polymorphic_wand" + } + }, + "pattern": [ + " b", + " r ", + "i " + ], + "result": { + "count": 1, + "id": "justdirethings:polymorphic_wand_v2" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/justdirethings/tags/entity_type/polymorphic_target_deny.json b/src/generated/resources/data/justdirethings/tags/entity_type/polymorphic_target_deny.json new file mode 100644 index 00000000..d48013b9 --- /dev/null +++ b/src/generated/resources/data/justdirethings/tags/entity_type/polymorphic_target_deny.json @@ -0,0 +1,7 @@ +{ + "values": [ + "minecraft:ender_dragon", + "minecraft:wither", + "minecraft:warden" + ] +} \ No newline at end of file diff --git a/src/main/java/com/direwolf20/justdirethings/JustDireThings.java b/src/main/java/com/direwolf20/justdirethings/JustDireThings.java index 87161baa..3cb80c0b 100644 --- a/src/main/java/com/direwolf20/justdirethings/JustDireThings.java +++ b/src/main/java/com/direwolf20/justdirethings/JustDireThings.java @@ -9,10 +9,7 @@ import com.direwolf20.justdirethings.common.capabilities.ExperienceHolderFluidTank; import com.direwolf20.justdirethings.common.containers.handlers.PotionCanisterHandler; import com.direwolf20.justdirethings.common.entities.DecoyEntity; -import com.direwolf20.justdirethings.common.items.FluidCanister; -import com.direwolf20.justdirethings.common.items.PolymorphicWand; -import com.direwolf20.justdirethings.common.items.PortalGunV2; -import com.direwolf20.justdirethings.common.items.TimeWand; +import com.direwolf20.justdirethings.common.items.*; import com.direwolf20.justdirethings.common.items.datacomponents.JustDireDataComponents; import com.direwolf20.justdirethings.common.items.interfaces.PoweredItem; import com.direwolf20.justdirethings.common.network.PacketHandler; @@ -137,7 +134,8 @@ private void registerCapabilities(RegisterCapabilitiesEvent event) { Registration.EclipseAlloyHelmet.get(), Registration.CelestigemBow.get(), Registration.EclipseAlloyBow.get(), - Registration.TimeWand.get() + Registration.TimeWand.get(), + Registration.PolymorphicWandV2.get() ); event.registerItem(Capabilities.FluidHandler.ITEM, (itemStack, context) -> { @@ -183,6 +181,20 @@ public boolean canFillFluidType(FluidStack fluid) { }; } + if (itemStack.getItem() instanceof PolymorphicWandV2 polymorphicWandv2) { + return new FluidHandlerItemStack(JustDireDataComponents.FLUID_CONTAINER, itemStack, polymorphicWandv2.getMaxMB()) { + @Override + public boolean isFluidValid(int tank, FluidStack stack) { + return stack.is(Registration.POLYMORPHIC_FLUID_TYPE.get()); + } + + @Override + public boolean canFillFluidType(FluidStack fluid) { + return fluid.is(Registration.POLYMORPHIC_FLUID_TYPE.get()); + } + + }; + } if (itemStack.getItem() instanceof FluidCanister fluidCanister) { return new FluidHandlerItemStack(JustDireDataComponents.FLUID_CONTAINER, itemStack, fluidCanister.getMaxMB()); } @@ -191,7 +203,8 @@ public boolean canFillFluidType(FluidStack fluid) { Registration.PortalGunV2.get(), Registration.FluidCanister.get(), Registration.TimeWand.get(), - Registration.PolymorphicWand.get() + Registration.PolymorphicWand.get(), + Registration.PolymorphicWandV2.get() ); //Blocks diff --git a/src/main/java/com/direwolf20/justdirethings/common/events/PlayerEvents.java b/src/main/java/com/direwolf20/justdirethings/common/events/PlayerEvents.java index 6dd31c75..a77196e4 100644 --- a/src/main/java/com/direwolf20/justdirethings/common/events/PlayerEvents.java +++ b/src/main/java/com/direwolf20/justdirethings/common/events/PlayerEvents.java @@ -1,6 +1,8 @@ package com.direwolf20.justdirethings.common.events; import com.direwolf20.justdirethings.JustDireThings; +import com.direwolf20.justdirethings.common.items.PolymorphicWand; +import com.direwolf20.justdirethings.common.items.PolymorphicWandV2; import com.direwolf20.justdirethings.common.items.interfaces.Ability; import com.direwolf20.justdirethings.common.items.interfaces.PoweredItem; import com.direwolf20.justdirethings.common.items.interfaces.PoweredTool; @@ -21,6 +23,7 @@ import net.neoforged.neoforge.event.ItemAttributeModifierEvent; import net.neoforged.neoforge.event.entity.player.PlayerDestroyItemEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import java.util.EnumSet; import java.util.Set; @@ -110,4 +113,11 @@ public static void BreakSpeed(PlayerEvent.BreakSpeed event) { if (targetSpeed != event.getNewSpeed()) event.setNewSpeed(targetSpeed); } + + @SubscribeEvent + public static void CancelEntityInteraction(PlayerInteractEvent.EntityInteract event) { + ItemStack itemStack = event.getItemStack(); + if (itemStack.getItem() instanceof PolymorphicWand || itemStack.getItem() instanceof PolymorphicWandV2) + event.setCanceled(true); + } } \ No newline at end of file diff --git a/src/main/java/com/direwolf20/justdirethings/common/items/PolymorphicWandV2.java b/src/main/java/com/direwolf20/justdirethings/common/items/PolymorphicWandV2.java new file mode 100644 index 00000000..a1979ec9 --- /dev/null +++ b/src/main/java/com/direwolf20/justdirethings/common/items/PolymorphicWandV2.java @@ -0,0 +1,132 @@ +package com.direwolf20.justdirethings.common.items; + +import com.direwolf20.justdirethings.common.items.interfaces.*; +import com.direwolf20.justdirethings.datagen.JustDireEntityTags; +import com.direwolf20.justdirethings.setup.Config; +import com.direwolf20.justdirethings.util.MagicHelpers; +import com.direwolf20.justdirethings.util.MiscTools; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.UseAnim; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.neoforge.capabilities.Capabilities; +import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem; + +import java.util.List; +import java.util.Set; + +import static com.direwolf20.justdirethings.common.items.datacomponents.JustDireDataComponents.ENTITIYTYPE; + +public class PolymorphicWandV2 extends BaseToggleableTool implements LeftClickableTool, FluidContainingItem, PoweredItem { + public PolymorphicWandV2() { + super(new Properties() + .fireResistant()); + registerAbility(Ability.POLYMORPH_RANDOM); + registerAbility(Ability.POLYMORPH_TARGET); + } + + @Override + public int getMaxMB() { + return Config.POLYMORPHIC_WAND_V2_MAX_FLUID.get(); + } + + @Override + public InteractionResult useOn(UseOnContext pContext) { + ItemStack itemStack = pContext.getItemInHand(); + Player player = pContext.getPlayer(); + if (player == null || itemStack.isEmpty()) return InteractionResult.FAIL; + BlockHitResult blockhitresult = getPlayerPOVHitResult(player.level(), player, ClipContext.Fluid.SOURCE_ONLY); + if (blockhitresult.getType() == HitResult.Type.BLOCK) { + if (FluidContainingItem.pickupFluid(player.level(), player, itemStack, blockhitresult)) + return InteractionResult.SUCCESS; + } + return super.useOn(pContext); + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { + Level level = player.level(); + if (level.isClientSide) return true; + ItemStack itemStack = player.getMainHandItem(); + Set abilities = LeftClickableTool.getLeftClickList(itemStack); + if (itemStack.getItem() instanceof ToggleableTool toggleableTool && !abilities.isEmpty()) { + toggleableTool.useAbility(player.level(), player, InteractionHand.MAIN_HAND, false); + } + return true; + } + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack itemStack = player.getItemInHand(hand); + BlockHitResult blockhitresult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY); + if (blockhitresult.getType() == HitResult.Type.BLOCK) { + if (FluidContainingItem.pickupFluid(level, player, itemStack, blockhitresult)) + return InteractionResultHolder.fail(itemStack); + } + Entity entity = MiscTools.getEntityLookedAt(player, 4); + if (!level.isClientSide && player.isShiftKeyDown() && entity instanceof LivingEntity livingEntity) { //Custom Handling due to shift-clicking mobs to set target + savePolymorphTarget(itemStack, player, livingEntity); + return InteractionResultHolder.pass(player.getItemInHand(hand)); + } + return super.use(level, player, hand); + } + + public static void savePolymorphTarget(ItemStack stack, Player player, LivingEntity interactionTarget) { + if (interactionTarget instanceof Mob && !interactionTarget.getType().is(JustDireEntityTags.POLYMORPHIC_TARGET_DENY)) { + stack.set(ENTITIYTYPE, EntityType.getKey(interactionTarget.getType()).toString()); + player.displayClientMessage(Component.translatable("justdirethings.polymorphset", interactionTarget.getType().getDescription()), true); + } else { + player.displayClientMessage(Component.translatable("justdirethings.invalidpolymorphentity"), true); + } + } + + @Override + public void appendHoverText(ItemStack stack, TooltipContext context, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, context, tooltip, flagIn); + Level level = context.level(); + if (level == null) { + return; + } + IFluidHandlerItem fluidHandler = stack.getCapability(Capabilities.FluidHandler.ITEM); + if (fluidHandler == null) { + return; + } + tooltip.add(Component.translatable("justdirethings.polymorphicfluidamt", MagicHelpers.formatted(fluidHandler.getFluidInTank(0).getAmount()), MagicHelpers.formatted(fluidHandler.getTankCapacity(0))).withStyle(ChatFormatting.GREEN)); + + if (!stack.has(ENTITIYTYPE)) return; + EntityType newType = EntityType.byString(stack.get(ENTITIYTYPE)).orElse(null); + if (newType == null) return; + tooltip.add(Component.translatable("justdirethings.polymorphset", newType.getDescription()) + .withStyle(ChatFormatting.AQUA)); + } + + @Override + public int getMaxEnergy() { + return Config.POLYMORPHIC_WAND_V2_FE_CAPACITY.get(); + } + + @Override + public UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; + } + + @Override + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return false; + } + +} diff --git a/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/Ability.java b/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/Ability.java index 35dbc3c1..2104a1dd 100644 --- a/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/Ability.java +++ b/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/Ability.java @@ -105,6 +105,9 @@ public enum Ability { LAVAIMMUNITY(SettingType.SLIDER, 1, 1000, UseType.PASSIVE, BindingType.CUSTOM_ONLY, Registration.UPGRADE_LAVAIMMUNITY), PHASE(SettingType.SLIDER, 1, 50000, UseType.PASSIVE, BindingType.CUSTOM_ONLY, Registration.UPGRADE_PHASE), TIMEPROTECTION(SettingType.SLIDER, 1, 5000, UseType.PASSIVE, BindingType.CUSTOM_ONLY, Registration.UPGRADE_TIMEPROTECTION), + POLYMORPH_TARGET(SettingType.TOGGLE, 10, 50000, UseType.USE, BindingType.LEFT_AND_CUSTOM, + AbilityMethods::polymorphTarget, CustomSettingType.NONE, + ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "textures/gui/overlay/polymorph_target.png")), EPICARROW(SettingType.SLIDER, 25, 100000, UseType.USE_COOLDOWN, BindingType.CUSTOM_ONLY, AbilityMethods::epicArrow, CustomSettingType.NONE, ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "textures/gui/overlay/epicarrow.png"), Registration.UPGRADE_EPICARROW); diff --git a/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/AbilityMethods.java b/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/AbilityMethods.java index bff61469..ace517d5 100644 --- a/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/AbilityMethods.java +++ b/src/main/java/com/direwolf20/justdirethings/common/items/interfaces/AbilityMethods.java @@ -54,6 +54,7 @@ import java.util.*; import java.util.stream.Collectors; +import static com.direwolf20.justdirethings.common.items.datacomponents.JustDireDataComponents.ENTITIYTYPE; import static com.direwolf20.justdirethings.common.items.interfaces.Helpers.*; import static com.direwolf20.justdirethings.common.items.interfaces.ToggleableTool.*; @@ -491,7 +492,7 @@ public static boolean polymorphRandom(Level level, Player player, ItemStack item // Spawn new mob at the same location Mob newMob = (Mob) newType.create(level); if (newMob != null) { - EventHooks.finalizeMobSpawn(mob, (ServerLevel) level, level.getCurrentDifficultyAt(player.blockPosition()), MobSpawnType.SPAWNER, null); + EventHooks.finalizeMobSpawn(newMob, (ServerLevel) level, level.getCurrentDifficultyAt(player.blockPosition()), MobSpawnType.SPAWNER, null); newMob.moveTo(mob.getX(), mob.getY(), mob.getZ(), mob.getYRot(), mob.getXRot()); newMob.setHealth(newMob.getMaxHealth()); // Reset health to maximum @@ -514,10 +515,51 @@ public static boolean polymorphRandom(Level level, Player player, ItemStack item Helpers.damageTool(itemStack, player, Ability.POLYMORPH_RANDOM); } } + } + } + return false; + } - //player.playNotifySound(SoundEvents.ILLUSIONER_CAST_SPELL, SoundSource.PLAYERS, 0.5F, 0.75F); - //((ServerLevel) level).sendParticles(ParticleTypes.WHITE_SMOKE, mob.getX(), mob.getEyeY(), mob.getZ(), 20, 0.25, 0.2, 0.25, 0); - //Helpers.damageTool(itemStack, player, Ability.POLYMORPH_RANDOM); + public static boolean polymorphTarget(Level level, Player player, ItemStack itemStack) { + if (level.isClientSide) return false; + if (itemStack.getItem() instanceof ToggleableTool toggleableTool && toggleableTool.canUseAbilityAndDurability(itemStack, Ability.POLYMORPH_TARGET)) { + Entity entity = MiscTools.getEntityLookedAt(player, 4); + if (entity == null) return false; + + int fuelAmt = Config.TARGET_POLYMORPH_COST.get(); + if (!FluidContainingItem.hasEnoughFluid(itemStack, fuelAmt)) + return false; + + if (entity instanceof Mob mob) { + if (!itemStack.has(ENTITIYTYPE)) return false; + EntityType newType = EntityType.byString(itemStack.get(ENTITIYTYPE)).orElse(null); + if (newType == null) return false; + + // Spawn new mob at the same location + Mob newMob = (Mob) newType.create(level); + if (newMob != null) { + EventHooks.finalizeMobSpawn(newMob, (ServerLevel) level, level.getCurrentDifficultyAt(player.blockPosition()), MobSpawnType.SPAWNER, null); + + newMob.moveTo(mob.getX(), mob.getY(), mob.getZ(), mob.getYRot(), mob.getXRot()); + newMob.setHealth(newMob.getMaxHealth()); // Reset health to maximum + ((ServerLevel) level).addFreshEntity(newMob); + + if (!newMob.isAddedToLevel()) + return false; //If it failed to add for some reason? + + // Play effects + player.playNotifySound(SoundEvents.ILLUSIONER_CAST_SPELL, SoundSource.PLAYERS, 0.5F, 0.75F); + ((ServerLevel) level).sendParticles(ParticleTypes.WHITE_SMOKE, + mob.getX(), mob.getEyeY(), mob.getZ(), + 20, 0.25, 0.2, 0.25, 0); + + // Remove the old mob + mob.discard(); + + // Damage the tool + FluidContainingItem.consumeFluid(itemStack, fuelAmt); + Helpers.damageTool(itemStack, player, Ability.POLYMORPH_RANDOM); + } } } return false; diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireEntityTags.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireEntityTags.java index 53de0a2b..4be2cee8 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireEntityTags.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireEntityTags.java @@ -28,6 +28,7 @@ public JustDireEntityTags(PackOutput packOutput, CompletableFuture> PARADOX_ABSORB_DENY = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "paradox_absorb_deny")); public static final TagKey> POLYMORPHIC_PEACEFUL = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "polymorphic_peaceful")); public static final TagKey> POLYMORPHIC_HOSTILE = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "polymorphic_hostile")); + public static final TagKey> POLYMORPHIC_TARGET_DENY = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "polymorphic_target_deny")); @Override public void addTags(HolderLookup.Provider lookupProvider) { @@ -122,6 +123,10 @@ public void addTags(HolderLookup.Provider lookupProvider) { EntityType.PHANTOM, EntityType.PILLAGER ); + tag(POLYMORPHIC_TARGET_DENY) + .add(EntityType.ENDER_DRAGON) + .add(EntityType.WITHER) + .add(EntityType.WARDEN); } } diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java index 0139c61d..f5e05f0d 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java @@ -119,6 +119,7 @@ protected void registerModels() { singleTexture(Registration.TEMPLATE_ECLIPSEALLOY.getId().getPath(), mcLoc("item/generated"), "layer0", modLoc("item/template_eclipsealloy")); singleTexture(Registration.TimeWand.getId().getPath(), mcLoc("item/generated"), "layer0", modLoc("item/time_wand")); singleTexture(Registration.PolymorphicWand.getId().getPath(), mcLoc("item/handheld"), "layer0", modLoc("item/polymorphic_wand")); + singleTexture(Registration.PolymorphicWandV2.getId().getPath(), mcLoc("item/handheld"), "layer0", modLoc("item/polymorphic_wand_v2")); registerBowModels(); diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java index a3e4de20..538c1a2c 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireLanguageProvider.java @@ -133,6 +133,7 @@ protected void addTranslations() { add(Registration.PotionCanister.get(), "Potion Canister"); add(Registration.TimeWand.get(), "Time Wand"); add(Registration.PolymorphicWand.get(), "Polymorphic Wand"); + add(Registration.PolymorphicWandV2.get(), "Advanced Polymorphic Wand"); //Tools add(Registration.FerricoreSword.get(), "Ferricore Sword"); @@ -362,6 +363,7 @@ protected void addTranslations() { add("justdirethings.lowportalfluid", "Insufficient Portal Fluid"); add("justdirethings.lowtimefluid", "Insufficient Time Fluid"); add("justdirethings.invalidpolymorphentity", "Invalid Entity for Polymorphing"); + add("justdirethings.polymorphset", "Polymorph Target: %s"); add("justdirethings.boundto", "Bound to: %s:%s"); add("justdirethings.boundto-missing", "Bound to (MISSING BLOCK): %s:%s"); add("justdirethings.unbound", " -Not Bound"); @@ -448,6 +450,7 @@ protected void addTranslations() { add(Ability.TIMEPROTECTION.getLocalization(), "Time Protection"); add(Ability.WATERBREATHING.getLocalization(), "Water Breathing"); add(Ability.POLYMORPH_RANDOM.getLocalization(), "Random Polymorph"); + add(Ability.POLYMORPH_TARGET.getLocalization(), "Targeted Polymorph"); //GUI add("justdirethings.screen.energy", "Energy: %s/%s FE"); diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireRecipes.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireRecipes.java index 4bc05dde..00c87f7a 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireRecipes.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireRecipes.java @@ -464,6 +464,16 @@ protected void buildRecipes(RecipeOutput consumer) { .group("justdirethings") .unlockedBy("has_blazegold_ingot", InventoryChangeTrigger.TriggerInstance.hasItems(Registration.BlazegoldIngot.get())) .save(consumer); + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Registration.PolymorphicWandV2.get()) + .pattern(" b") + .pattern(" r ") + .pattern("i ") + .define('i', Registration.Celestigem.get()) + .define('r', Registration.PolymorphicWand.get()) + .define('b', Registration.EclipseAlloyIngot.get()) + .group("justdirethings") + .unlockedBy("has_eclipsealloy_ingot", InventoryChangeTrigger.TriggerInstance.hasItems(Registration.EclipseAlloyIngot.get())) + .save(consumer); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Registration.TimeWand.get()) .pattern(" bt") .pattern(" ib") diff --git a/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java b/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java index b24650c1..868c8c2d 100644 --- a/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java +++ b/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java @@ -198,6 +198,7 @@ public static void registerItemDecorators(RegisterItemDecorationsEvent event) { event.register(Registration.PortalGunV2.get(), new FluidbarDecorator()); event.register(Registration.FluidCanister.get(), new FluidbarDecorator()); event.register(Registration.PolymorphicWand.get(), new FluidbarDecorator()); + event.register(Registration.PolymorphicWandV2.get(), new FluidbarDecorator()); } @SubscribeEvent diff --git a/src/main/java/com/direwolf20/justdirethings/setup/Config.java b/src/main/java/com/direwolf20/justdirethings/setup/Config.java index a9489d18..5af916da 100644 --- a/src/main/java/com/direwolf20/justdirethings/setup/Config.java +++ b/src/main/java/com/direwolf20/justdirethings/setup/Config.java @@ -93,6 +93,10 @@ public class Config { public static final String CATEGORY_POLYMORPHIC_WAND = "polymorphic_wand"; public static ModConfigSpec.IntValue POLYMORPHIC_WAND_MAX_FLUID; public static ModConfigSpec.IntValue RANDOM_POLYMORPH_COST; + public static ModConfigSpec.IntValue POLYMORPHIC_WAND_V2_MAX_FLUID; + public static ModConfigSpec.IntValue TARGET_POLYMORPH_COST; + public static ModConfigSpec.IntValue POLYMORPHIC_WAND_V2_FE_CAPACITY; + public static ModConfigSpec.IntValue POLYMORPHIC_WAND_V2_FE_COST; public static void register(ModContainer container) { //registerServerConfigs(container); @@ -275,6 +279,14 @@ private static void polymorphWandConfig() { .defineInRange("polymorphic_wand_fluid_cost", 100, 1, Integer.MAX_VALUE); POLYMORPHIC_WAND_MAX_FLUID = COMMON_BUILDER.comment("The amount of fluid the Polymorphic Wand can hold") .defineInRange("polymorphic_wand_max_fluid", 2000, 1, Integer.MAX_VALUE); + POLYMORPHIC_WAND_V2_FE_COST = COMMON_BUILDER.comment("The FE cost to use the Advanced Polymorphic Wand") + .defineInRange("polymorphic_wand_v2_fe_cost", 50000, 1, Integer.MAX_VALUE); + POLYMORPHIC_WAND_V2_FE_CAPACITY = COMMON_BUILDER.comment("The amount of FE the Advanced Polymorphic Wand can hold") + .defineInRange("polymorphic_wand_v2_fe_capacity", 1000000, 1, Integer.MAX_VALUE); + TARGET_POLYMORPH_COST = COMMON_BUILDER.comment("The polymorphic fluid cost to use the Advanced Polymorphic Wand") + .defineInRange("polymorphic_wand_v2_fluid_cost", 250, 1, Integer.MAX_VALUE); + POLYMORPHIC_WAND_V2_MAX_FLUID = COMMON_BUILDER.comment("The amount of fluid the Advanced Polymorphic Wand can hold") + .defineInRange("polymorphic_wand_v2_max_fluid", 8000, 1, Integer.MAX_VALUE); COMMON_BUILDER.pop(); } diff --git a/src/main/java/com/direwolf20/justdirethings/setup/Registration.java b/src/main/java/com/direwolf20/justdirethings/setup/Registration.java index 6cf824b0..f1c24579 100644 --- a/src/main/java/com/direwolf20/justdirethings/setup/Registration.java +++ b/src/main/java/com/direwolf20/justdirethings/setup/Registration.java @@ -519,6 +519,7 @@ public static void init(IEventBus eventBus) { public static final DeferredHolder CelestigemBow = BOWS.register("bow_celestigem", CelestigemBow::new); public static final DeferredHolder EclipseAlloyBow = BOWS.register("bow_eclipsealloy", EclipseAlloyBow::new); public static final DeferredHolder PolymorphicWand = ITEMS.register("polymorphic_wand", PolymorphicWand::new); + public static final DeferredHolder PolymorphicWandV2 = ITEMS.register("polymorphic_wand_v2", PolymorphicWandV2::new); //Items - Tools public static final DeferredHolder FerricoreSword = TOOLS.register("ferricore_sword", FerricoreSword::new); diff --git a/src/main/resources/assets/justdirethings/textures/item/polymorphic_wand_v2.png b/src/main/resources/assets/justdirethings/textures/item/polymorphic_wand_v2.png new file mode 100644 index 00000000..45491f51 Binary files /dev/null and b/src/main/resources/assets/justdirethings/textures/item/polymorphic_wand_v2.png differ