Started by
gustavowizard123
on
Topic category: Help with Minecraft modding (Java Edition)
im trying to set up a procedure or edit the code to make a sword (item) make a swing soung when the player swing the weapon on main haind, is this possible?
thanks in advance
i just find a procedure to Make the main hand swing (prb usefull to make mobs move arms when attacking and stuff), but i dont think i can use this one on this case, i need just the weapon to make a quick sound when swing (lightsaber 'wooon') :D
anybody?
hook the net.minecraftforge.client.event.MouseEvent. if left mouse button clicked with your item in main hand, do whatever
i found this but i dont know how to use it; (what part to vamp:
public static final int MOUSE_FIRST = 500;
/**
* The last number in the range of ids used for mouse events.
*/
public static final int MOUSE_LAST = 507;
/**
* The "mouse clicked" event. This <code>MouseEvent</code>
* occurs when a mouse button is pressed and released.
*/
public static final int MOUSE_CLICKED = MOUSE_FIRST;
/**
* The "mouse pressed" event. This <code>MouseEvent</code>
* occurs when a mouse button is pushed down.
*/
then i need to put a 'return' to play my lightsaber sound i supose? like
@Override // <--- exempla of a simple custom sound
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:crocodile_hurt"));
}
i think i need a IF too right? :/
i will try this (i dont know coding lol):
@Override
public ActionResult<ItemStack> onItemLeftClick(World world, PlayerEntity entity, Hand hand) {
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:crocodile_hurt"));
}
looool nvm i just download the new snapshot (the one they released today), and there is a 'when entity swing item' option now! hurray!
haha, you so lucky
haha
also, im so impressed how much 2020.4 is better than 2020.3... congratulations to the owners/programers!
HELLO . were you able to apply the sound file to the swing of your sword?