|
1 | 1 | package net.hex_chalkcircles.item;
|
2 | 2 |
|
3 | 3 | 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; |
6 | 12 | import net.minecraft.world.item.ItemStack;
|
7 |
| -import net.minecraft.world.entity.Entity; |
| 13 | +import net.minecraft.world.level.Level; |
8 | 14 |
|
9 |
| -public class ItemChalkStick extends ItemMediaHolder { |
| 15 | + |
| 16 | +public class ItemChalkStick extends ItemStaff { |
10 | 17 |
|
11 | 18 | public ItemChalkStick(Properties pProperties) {
|
12 | 19 | 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; |
20 | 20 | }
|
21 | 21 |
|
| 22 | + |
22 | 23 | @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 | + } |
28 | 48 |
|
29 | 49 |
|
30 | 50 |
|
|
0 commit comments