generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
630f709
commit 7687ab9
Showing
22 changed files
with
325 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/justdirethings/models/item/polymorphic_wand_v2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...generated/resources/data/justdirethings/advancement/recipes/misc/polymorphic_wand_v2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/generated/resources/data/justdirethings/recipe/polymorphic_wand_v2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/generated/resources/data/justdirethings/tags/entity_type/polymorphic_target_deny.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"values": [ | ||
"minecraft:ender_dragon", | ||
"minecraft:wither", | ||
"minecraft:warden" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
src/main/java/com/direwolf20/justdirethings/common/items/PolymorphicWandV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.