-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from enjarai/just-gonna-push-the-texture-and-b…
…asic-impl-we-can-figure-out-the-specifics-later This is certainly something isn't it
- Loading branch information
Showing
30 changed files
with
342 additions
and
18 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
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
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/3ac65fa3d3c37fa00307c1168fcecdd37a25c66a
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 +1 @@ | ||
// 1.21 2025-02-01T18:23:52.037965049 Trickster/Recipes | ||
// 1.21 2025-02-28T18:03:14.086844517 Trickster/Recipes |
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
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/79ef07c0320f2b1bff073a33f581b6ea484cf452
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
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/de828e1c0b483619cb31befb2371ade13f1a18a1
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,3 +1,3 @@ | ||
// 1.21 2025-02-01T18:23:52.038027029 Trickster/Tags for minecraft:item | ||
// 1.21 2025-02-28T18:03:14.08696223 Trickster/Tags for minecraft:item | ||
23bfb5af198cc6efbf9fdb01f4169f9c6df07968 data/trickster/tags/item/dyed_scroll_and_quill.json | ||
af8a8cadecd9999efde2ab4a363a6ac6a933d02b data/trickster/tags/item/dyed_written_scroll.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "trickster:item/collar" | ||
} | ||
} |
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/generated", | ||
"textures": { | ||
"layer0": "trickster:item/leash" | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dev.enjarai.trickster.item; | ||
|
||
import dev.enjarai.trickster.item.component.ModComponents; | ||
import io.wispforest.accessories.api.AccessoryItem; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.tooltip.TooltipType; | ||
import net.minecraft.text.Text; | ||
|
||
import java.util.List; | ||
|
||
public class CollarItem extends AccessoryItem { | ||
public CollarItem(Settings properties) { | ||
super(properties.maxCount(1)); | ||
} | ||
|
||
@Override | ||
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) { | ||
if (!stack.contains(ModComponents.COLLAR_LINK)) { | ||
tooltip.add(Text.translatable("trickster.tooltip.unlinked").withColor(0x775577)); | ||
} | ||
|
||
super.appendTooltip(stack, context, tooltip, type); | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
src/main/java/dev/enjarai/trickster/item/LeashItem.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,131 @@ | ||
package dev.enjarai.trickster.item; | ||
|
||
import dev.enjarai.trickster.cca.ModEntityComponents; | ||
import dev.enjarai.trickster.item.component.CollarLinkComponent; | ||
import dev.enjarai.trickster.item.component.ModComponents; | ||
import dev.enjarai.trickster.spell.SpellPart; | ||
import dev.enjarai.trickster.spell.fragment.EntityFragment; | ||
import io.wispforest.accessories.api.slot.SlotReference; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.tooltip.TooltipType; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.TypedActionResult; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class LeashItem extends Item { | ||
public LeashItem(Settings settings) { | ||
super(settings.maxCount(1)); | ||
} | ||
|
||
@Override | ||
public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) { | ||
if (!user.getWorld().isClient() && !stack.contains(ModComponents.COLLAR_LINK)) { | ||
var slot = SlotReference.of(entity, "necklace", 0); | ||
var collarStack = slot.getStack(); | ||
|
||
if (!(entity instanceof PlayerEntity)) { | ||
return super.useOnEntity(stack, user, entity, hand); | ||
} | ||
|
||
var particlePos = entity.getPos().add(0, 1, 0); | ||
|
||
if (collarStack == null || !collarStack.isIn(ModItems.COLLARS) || collarStack.contains(ModComponents.COLLAR_LINK)) { | ||
((ServerWorld) entity.getWorld()).spawnParticles( | ||
ParticleTypes.SMOKE, particlePos.x, particlePos.y, particlePos.z, | ||
10, 0.3, 0.3, 0.3, 0 | ||
); | ||
|
||
user.sendMessage(Text.translatable("trickster.message.leash.invalid_collar", entity.getName()), true); | ||
return ActionResult.CONSUME; | ||
} | ||
|
||
if (!entity.isSneaking()) { | ||
((ServerWorld) entity.getWorld()).spawnParticles( | ||
ParticleTypes.SMOKE, particlePos.x, particlePos.y, particlePos.z, | ||
10, 0.3, 0.3, 0.3, 0 | ||
); | ||
|
||
user.sendMessage(Text.translatable("trickster.message.leash.not_sneaking", entity.getName()), true); | ||
return ActionResult.CONSUME; | ||
} | ||
|
||
var component = new CollarLinkComponent(UUID.randomUUID()); | ||
user.getStackInHand(hand).set(ModComponents.COLLAR_LINK, component); | ||
collarStack = collarStack.copy(); | ||
collarStack.set(ModComponents.COLLAR_LINK, component); | ||
slot.setStack(collarStack); | ||
|
||
entity.getWorld().playSoundFromEntity( | ||
null, entity, SoundEvents.BLOCK_COMPARATOR_CLICK, | ||
SoundCategory.PLAYERS, 1, 1.6f | ||
); | ||
((ServerWorld) entity.getWorld()).spawnParticles( | ||
ParticleTypes.HEART, particlePos.x, particlePos.y, particlePos.z, | ||
10, 0.3, 0.3, 0.3, 0 | ||
); | ||
|
||
user.sendMessage(Text.translatable("trickster.message.leash.success", entity.getName()), true); | ||
return ActionResult.SUCCESS; | ||
} | ||
|
||
return super.useOnEntity(stack, user, entity, hand); | ||
} | ||
|
||
@Override | ||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { | ||
var stack = user.getStackInHand(hand); | ||
var linkComponent = stack.get(ModComponents.COLLAR_LINK); | ||
|
||
if (linkComponent != null) { | ||
if (!world.isClient()) { | ||
var players = world.getPlayers().stream().filter(p -> { | ||
var collarStack = SlotReference.of(p, "necklace", 0).getStack(); | ||
if (collarStack == null) return false; | ||
|
||
var component = collarStack.get(ModComponents.COLLAR_LINK); | ||
if (component == null) return false; | ||
|
||
return component.uuid().equals(linkComponent.uuid()); | ||
}).toList(); | ||
|
||
if (players.size() == 0) { | ||
user.sendMessage(Text.translatable("trickster.message.leash.not_online"), true); | ||
} else { | ||
var fragmentComponent = stack.get(ModComponents.FRAGMENT); | ||
if (fragmentComponent != null) { | ||
for (var player : players) { | ||
var spell = fragmentComponent.value() instanceof SpellPart part ? part : new SpellPart(fragmentComponent.value()); | ||
ModEntityComponents.CASTER.get(player).queueSpell(spell, List.of(EntityFragment.from(user))); | ||
ModEntityComponents.CASTER.get(user).playCastSound(0.8f, 0.1f); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return TypedActionResult.success(stack); | ||
} | ||
|
||
return super.use(world, user, hand); | ||
} | ||
|
||
@Override | ||
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) { | ||
if (!stack.contains(ModComponents.COLLAR_LINK)) { | ||
tooltip.add(Text.translatable("trickster.tooltip.unlinked").withColor(0x775577)); | ||
} | ||
|
||
super.appendTooltip(stack, context, tooltip, type); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/dev/enjarai/trickster/item/component/CollarLinkComponent.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,14 @@ | ||
package dev.enjarai.trickster.item.component; | ||
|
||
import dev.enjarai.trickster.EndecTomfoolery; | ||
import io.wispforest.endec.StructEndec; | ||
import io.wispforest.endec.impl.StructEndecBuilder; | ||
|
||
import java.util.UUID; | ||
|
||
public record CollarLinkComponent(UUID uuid) { | ||
public static final StructEndec<CollarLinkComponent> ENDEC = StructEndecBuilder.of( | ||
EndecTomfoolery.UUID.fieldOf("uuid", CollarLinkComponent::uuid), | ||
CollarLinkComponent::new | ||
); | ||
} |
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.