-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Iteranya/1.20.1_Built_In_Script
Added Voice Feature and a Crafting Recipe for the Mob Talker Item
- Loading branch information
Showing
19 changed files
with
504 additions
and
340 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/org/arsparadox/mobtalkerredux/CustomItem.java
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,35 @@ | ||
package org.arsparadox.mobtalkerredux; | ||
|
||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.level.Level; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.List; | ||
|
||
public class CustomItem extends Item { | ||
// No Like, Literally Custom Item | ||
|
||
public CustomItem(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public Component getName(ItemStack stack) { | ||
if (stack.hasTag() && stack.getTag().contains("CustomName")) { | ||
return Component.translatable(stack.getTag().getString("CustomName")); | ||
} | ||
return super.getName(stack); | ||
} | ||
|
||
// Override texture retrieval | ||
@Override | ||
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) { | ||
if (stack.hasTag() && stack.getTag().contains("TextureKey")) { | ||
tooltip.add(Component.translatable("Texture: " + stack.getTag().getString("TextureKey"))); | ||
} | ||
super.appendHoverText(stack, level, tooltip, flag); | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
src/main/java/org/arsparadox/mobtalkerredux/vn/controller/vnmodules/SoundHandler.java
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,4 @@ | ||
package org.arsparadox.mobtalkerredux.vn.controller.vnmodules; | ||
|
||
public class SoundHandler { | ||
} |
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
118 changes: 118 additions & 0 deletions
118
src/main/java/org/arsparadox/mobtalkerredux/vn/view/SoundUtils.java
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,118 @@ | ||
package org.arsparadox.mobtalkerredux.vn.view; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.resources.sounds.SimpleSoundInstance; | ||
import net.minecraft.client.resources.sounds.SoundInstance; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.sounds.SoundSource; | ||
|
||
public class SoundUtils { | ||
|
||
private SimpleSoundInstance currentMusic = null; | ||
private SimpleSoundInstance currentSound = null; | ||
|
||
/** | ||
* Plays a sound effect once at full volume | ||
* Stops any currently playing sound effect | ||
* @param sound The ResourceLocation of the sound to play | ||
*/ | ||
public void playSound(ResourceLocation sound) { | ||
if (currentSound != null) { | ||
Minecraft.getInstance().getSoundManager().stop(currentSound); | ||
} | ||
currentSound = SimpleSoundInstance.forUI( | ||
net.minecraft.sounds.SoundEvent.createVariableRangeEvent(sound), | ||
1.0F, // Pitch | ||
1.5F // Volume | ||
); | ||
Minecraft.getInstance().getSoundManager().play(currentSound); | ||
} | ||
|
||
/** | ||
* Plays a sound effect with custom volume and pitch | ||
* Stops any currently playing sound effect | ||
* @param sound The ResourceLocation of the sound to play | ||
* @param volume Volume from 0.0 to 1.0 | ||
* @param pitch Pitch from 0.5 to 2.0 | ||
*/ | ||
public void playSound(ResourceLocation sound, float volume, float pitch) { | ||
if (currentSound != null) { | ||
Minecraft.getInstance().getSoundManager().stop(currentSound); | ||
} | ||
currentSound = SimpleSoundInstance.forUI( | ||
net.minecraft.sounds.SoundEvent.createVariableRangeEvent(sound), | ||
volume, | ||
pitch | ||
); | ||
Minecraft.getInstance().getSoundManager().play(currentSound); | ||
} | ||
|
||
/** | ||
* Plays music that will loop continuously | ||
* Automatically stops any currently playing music | ||
* @param music The ResourceLocation of the music to play | ||
*/ | ||
public void playMusic(ResourceLocation music) { | ||
stopMusic(); | ||
currentMusic = new SimpleSoundInstance( | ||
music, | ||
SoundSource.MUSIC, | ||
1.0F, // Volume | ||
1.0F, // Pitch | ||
SoundInstance.createUnseededRandom(), | ||
true, // Loop | ||
0, // Delay | ||
SoundInstance.Attenuation.NONE, | ||
0.0D, // x | ||
0.0D, // y | ||
0.0D, // z | ||
true // Relative | ||
); | ||
Minecraft.getInstance().getSoundManager().play(currentMusic); | ||
} | ||
|
||
/** | ||
* Plays music with custom volume that will loop continuously | ||
* Automatically stops any currently playing music | ||
* @param music The ResourceLocation of the music to play | ||
* @param volume Volume from 0.0 to 1.0 | ||
*/ | ||
public void playMusic(ResourceLocation music, float volume) { | ||
stopMusic(); | ||
currentMusic = new SimpleSoundInstance( | ||
music, | ||
SoundSource.MUSIC, | ||
volume, | ||
1.0F, | ||
SoundInstance.createUnseededRandom(), | ||
true, | ||
0, | ||
SoundInstance.Attenuation.NONE, | ||
0.0D, | ||
0.0D, | ||
0.0D, | ||
true | ||
); | ||
Minecraft.getInstance().getSoundManager().play(currentMusic); | ||
} | ||
|
||
/** | ||
* Stops any currently playing music | ||
*/ | ||
public void stopMusic() { | ||
if (currentMusic != null) { | ||
Minecraft.getInstance().getSoundManager().stop(currentMusic); | ||
currentMusic = null; | ||
} | ||
} | ||
|
||
/** | ||
* Stops any currently playing sound effect | ||
*/ | ||
public void stopSound() { | ||
if (currentSound != null) { | ||
Minecraft.getInstance().getSoundManager().stop(currentSound); | ||
currentSound = null; | ||
} | ||
} | ||
} |
Oops, something went wrong.