Skip to content

Commit

Permalink
Advanced Polymorphic Wand
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Dec 8, 2024
1 parent 630f709 commit 7687ab9
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/justdirethings/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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...",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "justdirethings:item/polymorphic_wand_v2"
}
}
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"minecraft:ender_dragon",
"minecraft:wither",
"minecraft:warden"
]
}
25 changes: 19 additions & 6 deletions src/main/java/com/direwolf20/justdirethings/JustDireThings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) -> {
Expand Down Expand Up @@ -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());
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<Ability> 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<ItemStack> 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<Component> 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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 7687ab9

Please sign in to comment.