-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
32 changed files
with
749 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dev.enjarai.trickster; | ||
|
||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.sound.SoundEvent; | ||
import net.minecraft.util.math.random.LocalRandom; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
public class ModSounds { | ||
public static final SoundEvent DRAW = register("draw"); | ||
public static final SoundEvent COMPLETE = register("complete"); | ||
|
||
private static SoundEvent register(String path) { | ||
var id = Trickster.id(path); | ||
return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id)); | ||
} | ||
|
||
public static void register() { | ||
|
||
} | ||
|
||
private static final Random PITCH_RANDOM = new LocalRandom(0xCAFEBABE); | ||
|
||
public static float randomPitch(float start, float range) { | ||
return start - range + PITCH_RANDOM.nextFloat() * range * 2; | ||
} | ||
} |
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
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,33 @@ | ||
package dev.enjarai.trickster.item; | ||
|
||
import dev.enjarai.trickster.item.component.ModComponents; | ||
import dev.enjarai.trickster.spell.PlayerSpellContext; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.TypedActionResult; | ||
import net.minecraft.world.World; | ||
|
||
public class WandItem extends Item { | ||
public WandItem(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { | ||
var stack = user.getStackInHand(hand); | ||
var slot = hand == Hand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND; | ||
|
||
if (!world.isClient()) { | ||
var spell = stack.get(ModComponents.SPELL); | ||
if (spell != null) { | ||
spell.spell().runSafely(new PlayerSpellContext((ServerPlayerEntity) user, slot)); | ||
} | ||
} | ||
|
||
return TypedActionResult.success(stack); | ||
} | ||
} |
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.