Skip to content

Commit

Permalink
Merge pull request #99 from enjarai/just-gonna-push-the-texture-and-b…
Browse files Browse the repository at this point in the history
…asic-impl-we-can-figure-out-the-specifics-later

This is certainly something isn't it
  • Loading branch information
enjarai authored Mar 1, 2025
2 parents 1034ce7 + f1bd86d commit f26f515
Show file tree
Hide file tree
Showing 30 changed files with 342 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/client/java/dev/enjarai/trickster/TricksterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void onInitializeClient() {
AccessoriesRendererRegistry.registerRenderer(ModItems.FEZ, HoldableHatRenderer::new);
AccessoriesRendererRegistry.registerNoRenderer(ModItems.MACRO_RING);
AccessoriesRendererRegistry.registerNoRenderer(ModItems.AMETHYST_WHORL);
AccessoriesRendererRegistry.registerNoRenderer(ModItems.COLLAR);

BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.SPELL_RESONATOR, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.LIGHT, RenderLayer.getTranslucent());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.enjarai.trickster.render;

import dev.enjarai.trickster.ClientUtils;
import dev.enjarai.trickster.Trickster.TooltipAppender;
import dev.enjarai.trickster.Trickster;
import dev.enjarai.trickster.Trickster.MerlinTooltipAppender;
import dev.enjarai.trickster.item.component.ManaComponent;
import dev.enjarai.trickster.item.component.ModComponents;
import dev.enjarai.trickster.spell.mana.SharedManaPool;
Expand All @@ -21,7 +21,7 @@

import java.util.List;

public class MerlinKeeperTracker implements MerlinTooltipAppender {
public class MerlinKeeperTracker implements TooltipAppender {
private final Int2ObjectMap<MerlinUsage> stackMap = new Int2ObjectOpenHashMap<>();
private final int tickSpan;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 1.21 2025-02-01T18:23:52.037533785 Trickster/Model Definitions
731c4a8f7b5d2845410c03b22e2521bcf41f969c assets/trickster/models/item/scroll_and_quill_red.json
// 1.21 2025-02-28T18:03:14.086071682 Trickster/Model Definitions
7cd9a2d7e13659094779ee999474bc85392fe900 assets/trickster/models/item/scroll_and_quill_white.json
731c4a8f7b5d2845410c03b22e2521bcf41f969c assets/trickster/models/item/scroll_and_quill_red.json
c995dc518d2d7134ffe57b13897fda67a0b0f815 assets/trickster/models/item/scroll_and_quill_pink.json
1d20d3356c7098ceded88807637ed3ced7cb8d26 assets/trickster/models/item/cracked_echo_knot.json
e622027802fd7ffb1c2e6f6d1733f17ed239e61d assets/trickster/models/item/tome_of_tomfoolery.json
Expand All @@ -24,10 +24,11 @@ f00b04573fa8a37423acbd2cfa58995b577acc9f assets/trickster/models/item/written_sc
274e1f4724884bcb7cc8337d4ffac31a3af801fe assets/trickster/models/item/written_scroll_black.json
9485ad9be41799d6c5bd48cd6dead8464f65beb5 assets/trickster/models/item/scroll_and_quill_magenta.json
68b6bc87e4d5e9b2709e30d6a6ca9b139c4f5fee assets/trickster/models/item/macro_ring.json
fe72cc051cf77ba7ea5b6ca82cabf06c56cb4503 assets/trickster/blockstates/spell_construct.json
62cc6f617bc26a9ac45c2b21ff9e312062963258 assets/trickster/models/item/scroll_and_quill.json
fe72cc051cf77ba7ea5b6ca82cabf06c56cb4503 assets/trickster/blockstates/spell_construct.json
68799707c7a1bba63c5cff3c8dbeec6b44bd06b8 assets/trickster/blockstates/charging_array.json
4320a21f02ba7db476a7dbf19eaa031ef40ca85c assets/trickster/models/item/scroll_and_quill_green.json
d9c9e7c5a06cf74773b8918b63ba681e42630412 assets/trickster/models/item/collar.json
2a8749d4361b2691332bd1d021866d7f9106ca0e assets/trickster/blockstates/modular_spell_construct.json
22ef3ac293ebe5b86928380e232bfaccc6202a28 assets/trickster/models/item/warding_charm.json
9faf558d1aa0f4946cf100c91b4f2819b7a07538 assets/trickster/models/item/written_scroll_orange.json
Expand All @@ -42,6 +43,7 @@ c651f1dafc6486d4b76b11cafb5adaf86b97f2eb assets/trickster/models/item/emerald_kn
0365b58ff0a90639528778ad8ec3bdf3fd337ace assets/trickster/models/item/scroll_and_quill_lime.json
edec8170be553ecb287cd4f9e718988b201f58a9 assets/trickster/models/item/wand.json
f1968641f7837fe2083a928582b12d565cf59ce0 assets/trickster/models/item/spell_construct.json
52c2faf4a46d20a9987279a80233c74404831249 assets/trickster/models/item/leash.json
25fc9665ae52d7788aa19923c04ba3874290a007 assets/trickster/models/item/scroll_and_quill_orange.json
032bd4c0ea04699e58ffbf43c29d1bf96fa19eb5 assets/trickster/models/block/scroll_shelf.json
06fb6fc1c900f99d2dd7537b8c7d13481323604e assets/trickster/models/item/echo_knot.json
Expand All @@ -59,6 +61,6 @@ d29d7f82679d35538363d72edafd2229e0f26958 assets/trickster/models/item/scroll_and
06af58b66840c735a18e12df1442fa2cd83c4df4 assets/trickster/models/item/written_scroll_brown.json
be89ca0492892b810135472265a1fa873151a8f0 assets/trickster/models/item/command_knot.json
ad5d09f6b76c65ada5383c567922cd74524f968c assets/trickster/models/item/written_scroll_red.json
8281443de0ca3a61ddab9d788c20add65efa99ac assets/trickster/models/item/astral_knot.json
ac75d1dcaf4df0990b246b571b214c88c2043fc5 assets/trickster/models/item/written_scroll_blue.json
8281443de0ca3a61ddab9d788c20add65efa99ac assets/trickster/models/item/astral_knot.json
9d5d343103d621d1a2f492cec156c06274efdc15 assets/trickster/blockstates/spell_resonator.json
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2025-02-01T18:23:52.038410044 Trickster/Block Conversion (heat)
// 1.21 2025-02-28T18:03:14.087476085 Trickster/Block Conversion (heat)
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/heat/spruce_sapling.json
f355c50648c7ae4f280e154eeb0f7a169897e7e4 data/minecraft/conversion/heat/iron_ore.json
ef14533ad40b2b6b0862656671e25e20e4ac2ddc data/minecraft/conversion/heat/gold_ore.json
Expand Down Expand Up @@ -43,7 +43,7 @@ a86def6145874a0758b43a6646388d163cca0a9f data/minecraft/conversion/heat/mud.json
d7d660ccbcc6b2a73918dfdecd8ecec622a573fb data/minecraft/conversion/heat/cobweb.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/heat/dark_oak_sapling.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/heat/jungle_sapling.json
38847479b14af3f7a5c35af9a0cfda37cbaccdfd data/minecraft/conversion/heat/podzol.json
29af50841b9aee7823a5b115ad00b225516a656d data/minecraft/conversion/heat/granite.json
38847479b14af3f7a5c35af9a0cfda37cbaccdfd data/minecraft/conversion/heat/podzol.json
38847479b14af3f7a5c35af9a0cfda37cbaccdfd data/minecraft/conversion/heat/grass_block.json
5d6f6b956878f4f6edeb098d3276c4ee70a4fefd data/minecraft/conversion/heat/lapis_ore.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2025-02-01T18:23:52.038118676 Trickster/Block Conversion (erode)
// 1.21 2025-02-28T18:03:14.087073511 Trickster/Block Conversion (erode)
4ac09d15b60d0ac8481ed4f88cafb81de5dc895e data/minecraft/conversion/erode/stone_brick_stairs.json
576201c522570d4a4145933fe82c02ade00cce5c data/minecraft/conversion/erode/exposed_copper_trapdoor.json
0a6c19256b667006fed9840f5e9ca354840328ea data/minecraft/conversion/erode/anvil.json
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2025-02-01T18:23:52.037176187 Trickster/Block Conversion (cool)
// 1.21 2025-02-28T18:03:14.085496661 Trickster/Block Conversion (cool)
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/jungle_sapling.json
5d2f23dbd4aa8e87025495da0e5e86b459743d64 data/minecraft/conversion/cool/packed_ice.json
73175674bb164d74e6e7c648bc5545d242ce3e53 data/minecraft/conversion/cool/cauldron.json
Expand All @@ -7,9 +7,9 @@
7ebf3cd89ecfbca041b18aba5e76675ba30de3ff data/minecraft/conversion/cool/magma_block.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/dark_oak_sapling.json
411fd4561458e8b55ab8e8db17c59325a7f50f26 data/minecraft/conversion/cool/ice.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/cherry_sapling.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/azalea.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/flowering_azalea.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/cherry_sapling.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/acacia_sapling.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/spruce_sapling.json
074a1ac0403c184c4f922fd82e5215983abab056 data/minecraft/conversion/cool/birch_sapling.json
Expand Down
6 changes: 6 additions & 0 deletions src/main/generated/assets/trickster/models/item/collar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "trickster:item/collar"
}
}
6 changes: 6 additions & 0 deletions src/main/generated/assets/trickster/models/item/leash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "trickster:item/leash"
}
}
4 changes: 2 additions & 2 deletions src/main/java/dev/enjarai/trickster/Trickster.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Trickster implements ModInitializer, CicadaEntrypoint {

public static final TricksterConfig CONFIG = TricksterConfig.createAndLoad();

public static MerlinTooltipAppender merlinTooltipAppender;
public static TooltipAppender merlinTooltipAppender;

@Override
public void onInitialize() {
Expand Down Expand Up @@ -114,7 +114,7 @@ public static Identifier id(String... path) {
return Identifier.of(MOD_ID, String.join("/", path));
}

public interface MerlinTooltipAppender {
public interface TooltipAppender {
void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void executorError(int index, SpellExecutor executor) {
playCastSound(0.5f, 0.1f);
}

private void playCastSound(float startPitch, float pitchRange) {
public void playCastSound(float startPitch, float pitchRange) {
if (player instanceof ServerPlayerEntity serverPlayer) {
serverPlayer.getServerWorld().playSoundFromEntity(
null, serverPlayer, ModSounds.CAST, SoundCategory.PLAYERS, 1f, ModSounds.randomPitch(startPitch, pitchRange)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public void generateItemModels(ItemModelGenerator itemModelGenerator) {
itemModelGenerator.register(ModItems.TOME_OF_TOMFOOLERY, Models.GENERATED);
itemModelGenerator.register(ModItems.WARDING_CHARM, Models.GENERATED);
itemModelGenerator.register(ModItems.AMETHYST_WHORL, Models.GENERATED);
itemModelGenerator.register(ModItems.COLLAR, Models.GENERATED);
itemModelGenerator.register(ModItems.LEASH, Models.GENERATED);
itemModelGenerator.register(ModItems.MACRO_RING, Models.GENERATED);
itemModelGenerator.register(ModItems.SPELL_INK, Models.GENERATED);
itemModelGenerator.register(ModItems.SPELL_RESONATOR_ITEM, Models.GENERATED);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/dev/enjarai/trickster/item/CollarItem.java
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 src/main/java/dev/enjarai/trickster/item/LeashItem.java
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);
}
}
5 changes: 5 additions & 0 deletions src/main/java/dev/enjarai/trickster/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class ModItems {
public static final Item MACRO_RING = register("macro_ring",
new Item(new Item.Settings().maxCount(1)));
public static final ManaAccessory AMETHYST_WHORL = register("amethyst_whorl", new ManaAccessory());
public static final CollarItem COLLAR = register("collar", new CollarItem(new Item.Settings()));
public static final LeashItem LEASH = register("leash", new LeashItem(new Item.Settings()));
public static final Item WARDING_CHARM = register("warding_charm",
new Item(new Item.Settings().maxCount(1)));
public static final SpellInkItem SPELL_INK = register("spell_ink",
Expand Down Expand Up @@ -91,6 +93,7 @@ public class ModItems {
public static final TagKey<Item> WEAPON_SPELL_TRIGGERS = TagKey.of(RegistryKeys.ITEM, Trickster.id("weapon_spell_triggers"));
public static final TagKey<Item> MANA_KNOTS = TagKey.of(RegistryKeys.ITEM, Trickster.id("mana_knots"));
public static final TagKey<Item> CANT_DESPAWN = TagKey.of(RegistryKeys.ITEM, Trickster.id("cant_despawn"));
public static final TagKey<Item> COLLARS = TagKey.of(RegistryKeys.ITEM, Trickster.id("collars"));

public static final WrittenScrollItem[] COLORED_WRITTEN_SCROLLS = new WrittenScrollItem[DyeColor.values().length];
public static final ScrollAndQuillItem[] COLORED_SCROLLS_AND_QUILLS = new ScrollAndQuillItem[DyeColor.values().length];
Expand Down Expand Up @@ -131,6 +134,8 @@ public class ModItems {
entries.add(FEZ);
entries.add(WAND);
entries.add(AMETHYST_WHORL);
entries.add(COLLAR);
entries.add(LEASH);
entries.add(WARDING_CHARM);
entries.add(MACRO_RING);
entries.add(SPELL_INK);
Expand Down
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
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class ModComponents {
.codec(ManaComponent.CODEC)
.cache()
);
public static final ComponentType<CollarLinkComponent> COLLAR_LINK = register(
"collar_link", builder -> builder
.endec(CollarLinkComponent.ENDEC)
.cache()
);

private static <T> ComponentType<T> register(String id, UnaryOperator<ComponentType.Builder<T>> builderOperator) {
return Registry.register(Registries.DATA_COMPONENT_TYPE, Trickster.id(id), (builderOperator.apply(ComponentType.builder())).build());
Expand Down
Loading

0 comments on commit f26f515

Please sign in to comment.