Skip to content

Commit

Permalink
Add a new custom sound effect
Browse files Browse the repository at this point in the history
Thanks to Choonster for posting helpful info on Minecraft Forum about
custom sound events.
  • Loading branch information
matshou committed Sep 2, 2016
1 parent 87bb692 commit e7e2e4a
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 5 deletions.
9 changes: 8 additions & 1 deletion FierySouls-changelog-.txt
@@ -1,8 +1,15 @@
Version 1.4.4

- Modified the torch humidity threshold value.
- Created a new class for all new custom sound events.
- Matchbox items will now produce a custom sound when used.

Version 1.4.3

- Resolved issue #8 (Duplicate elements in config...)
- Fixed an unreported issue that was preventing the config file from getting updated on data change.
- Added 'torch fire hazard' function main variable to config file.
- Added 'torch fire hazard' function main variable to config file.
- Updated .classpath, .project and added some new rules to .gitignore.

Version 1.4.2

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/yooksi/fierysouls/common/CommonProxy.java
Expand Up @@ -24,6 +24,8 @@ public void preInit(FMLPreInitializationEvent event)

registerResources();
registerTileEntities();

CustomSoundEvents.registerSounds();
}

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/yooksi/fierysouls/common/CustomSoundEvents.java
@@ -0,0 +1,24 @@
package com.yooksi.fierysouls.common;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CustomSoundEvents
{
public static SoundEvent item_match_strike;

/**
* Register the {@link SoundEvent}s.
*/
public static void registerSounds()
{
item_match_strike = registerSound("item.match_strike");
}

private static SoundEvent registerSound(String soundName)
{
final ResourceLocation soundID = new ResourceLocation(FierySouls.MODID, soundName);
return GameRegistry.register(new SoundEvent(soundID).setRegistryName(soundID));
}
}
Expand Up @@ -91,7 +91,7 @@ private static void syncConfig(boolean loadConfigFromFile, boolean readFieldsFro

TileEntityTorchLit.MAX_TORCH_FLAME_DURATION = configProperty.getInt();

final int HUMIDITY_THRESHOLD_DEFAULT = 300; // Index - #2
final int HUMIDITY_THRESHOLD_DEFAULT = 150; // Index - #2

comment = "Maximum amount of time (in ticks) this torch is allowed to be exposed to rain before extinguishing.";
configProperty = getFixedIntProperty(TORCH_CATEGORY, "humidity_threshold", HUMIDITY_THRESHOLD_DEFAULT, comment, 0, 24000);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/yooksi/fierysouls/common/FierySouls.java
Expand Up @@ -21,7 +21,7 @@ public class FierySouls
{
public static final String MODID = "fierysouls";
public static final String NAME = "Fiery Souls";
public static final String VERSION = "1.4.3";
public static final String VERSION = "1.4.4";

public static final String GUIFACTORY = "com.yooksi.fierysouls.common.FSGuiFactory";

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/yooksi/fierysouls/item/ItemMatchbox.java
Expand Up @@ -2,6 +2,7 @@

import com.yooksi.fierysouls.block.BlockTorchUnlit;
import com.yooksi.fierysouls.common.FierySouls;
import com.yooksi.fierysouls.common.CustomSoundEvents;
import com.yooksi.fierysouls.common.ResourceLibrary;

import net.minecraft.item.Item;
Expand All @@ -10,11 +11,12 @@
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;

import net.minecraft.world.World;
import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.SoundEvents;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -42,6 +44,8 @@ public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World
if (worldIn.getBlockState(pos).getBlock() == ResourceLibrary.TORCH_UNLIT)
BlockTorchUnlit.lightTorch(worldIn, pos);

worldIn.playSound(playerIn, pos, CustomSoundEvents.item_match_strike, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);

return EnumActionResult.SUCCESS; // Always allow the item to be used
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/resources/assets/fierysouls/sounds.json
@@ -0,0 +1,14 @@
{
"item.match_strike": {
"category": "item",
"sounds": [
{
# Sound downloaded from https://www.freesound.org/people/HunteR4708/sounds/256804/
# All credits got to user HunterR4708

"name": "fierysouls:item/match_strike",
"stream": true
}
]
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Expand Up @@ -3,7 +3,7 @@
"modid": "fierysouls",
"name": "Fiery Souls",
"description": "Revealing the true essence of fire elements in the mystical world of Minecraftia.",
"version": "1.4.3",
"version": "1.4.4",
"mcversion": "1.10.2",
"url": "https://github.com/yooksi/FierySouls",
"updateUrl": "",
Expand Down

0 comments on commit e7e2e4a

Please sign in to comment.