Skip to content

Commit 84a7668

Browse files
committed
amethyst chalk textures and casting grid attempt
1 parent 14eae6d commit 84a7668

File tree

5 files changed

+46
-18
lines changed

5 files changed

+46
-18
lines changed

common/src/main/java/net/hex_chalkcircles/item/ItemChalkStick.java

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
package net.hex_chalkcircles.item;
22

33
import at.petrak.hexcasting.common.items.ItemStaff;
4-
import at.petrak.hexcasting.common.items.magic.ItemMediaHolder;
5-
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex;
4+
import at.petrak.hexcasting.common.lib.HexSounds;
5+
import at.petrak.hexcasting.common.network.MsgOpenSpellGuiAck;
6+
import at.petrak.hexcasting.xplat.IXplatAbstractions;
7+
import net.minecraft.server.level.ServerPlayer;
8+
import net.minecraft.stats.Stats;
9+
import net.minecraft.world.InteractionHand;
10+
import net.minecraft.world.InteractionResultHolder;
11+
import net.minecraft.world.entity.player.Player;
612
import net.minecraft.world.item.ItemStack;
7-
import net.minecraft.world.entity.Entity;
13+
import net.minecraft.world.level.Level;
814

9-
public class ItemChalkStick extends ItemMediaHolder {
15+
16+
public class ItemChalkStick extends ItemStaff {
1017

1118
public ItemChalkStick(Properties pProperties) {
1219
super(pProperties);
13-
// TODO Auto-generated constructor stub
14-
}
15-
16-
@Override
17-
public boolean canProvideMedia(ItemStack stack) {
18-
// TODO Auto-generated method stub
19-
return false;
2020
}
2121

22+
2223
@Override
23-
public boolean canRecharge(ItemStack stack) {
24-
// TODO Auto-generated method stub
25-
return false;
26-
}
27-
24+
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
25+
if (player.isShiftKeyDown()) {
26+
if (world.isClientSide()) {
27+
player.playSound(HexSounds.FAIL_PATTERN, 1f, 1f);
28+
} else if (player instanceof ServerPlayer serverPlayer) {
29+
IXplatAbstractions.INSTANCE.clearCastingData(serverPlayer);
30+
}
31+
}
32+
33+
if (!world.isClientSide() && player instanceof ServerPlayer serverPlayer) {
34+
var harness = IXplatAbstractions.INSTANCE.getHarness(serverPlayer, hand);
35+
var patterns = IXplatAbstractions.INSTANCE.getPatterns(serverPlayer);
36+
var descs = harness.generateDescs();
37+
38+
IXplatAbstractions.INSTANCE.sendPacketToPlayer(serverPlayer,
39+
new MsgOpenSpellGuiAck(hand, patterns, descs.getFirst(), descs.getSecond(), descs.getThird(),
40+
harness.getParenCount()));
41+
}
42+
43+
player.awardStat(Stats.ITEM_USED.get(this));
44+
// player.gameEvent(GameEvent.ITEM_INTERACT_START);
45+
46+
return InteractionResultHolder.success(player.getItemInHand(hand));
47+
}
2848

2949

3050

common/src/main/java/net/hex_chalkcircles/registry/Hex_chalkcirclesItemRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class Hex_chalkcirclesItemRegistry {
1616
// Register items through this
1717
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(Hex_chalkcircles.MOD_ID, Registry.ITEM_REGISTRY);
18+
private static final Item.Properties CHALKCIRCLES_16STACK = new Item.Properties().stacksTo(16);
1819
private static final Item.Properties CHALKCIRCLES_UNSTACKABLE = new Item.Properties().stacksTo(1);
1920

2021

@@ -26,7 +27,7 @@ public static void init() {
2627
public static final CreativeModeTab CHALKCIRCLES_GROUP = CreativeTabRegistry.create(id("chalk_circles"), () -> new ItemStack(Hex_chalkcirclesItemRegistry.CHALKSTICK_ITEM.get()));
2728

2829
// During the loading phase, refrain from accessing suppliers' items (e.g. EXAMPLE_ITEM.get()), they will not be available
29-
public static final RegistrySupplier<Item> CHALKSTICK_ITEM = ITEMS.register("amethyst_chalk", () -> new ItemChalkStick(CHALKCIRCLES_UNSTACKABLE));
30+
public static final RegistrySupplier<Item> CHALKSTICK_ITEM = ITEMS.register("amethyst_chalk", () -> new ItemChalkStick(CHALKCIRCLES_16STACK));
3031

3132

3233
}

common/src/main/resources/assets/hex_chalkcircles/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"hex_chalkcircles.page.dummy_spells.congrats": "Accepts a player entity, tells them they are doing a good job and makes them look up.",
1010
"hex_chalkcircles.page.dummy_actions.signum": "Accepts a $(l:casting/101)number/$, returns -1 if it is negative, 0 if 0, 1 if positive.",
1111
"text.hex_chalkcircles.congrats": "Good job, %1$s!",
12-
"text.hex_chalkcircles.congrats.player": "a Player"
12+
"text.hex_chalkcircles.congrats.player": "a Player",
13+
"item.hex_chalkcircles.amethyst_chalk": "Amethyst Chalk"
1314
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "minecraft:item/generated",
3+
"textures": {
4+
"layer0": "hex_chalkcircles:item/amethyst_chalk"
5+
}
6+
}
Loading

0 commit comments

Comments
 (0)