ModSounds refactored to follow items, blocks and fluids
This commit is contained in:
parent
316def3086
commit
f06e1a8673
4 changed files with 24 additions and 30 deletions
|
@ -33,6 +33,7 @@ import net.minecraft.util.Identifier;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RegistrationManager;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.client.GuiHandler;
|
||||
|
@ -63,7 +64,6 @@ public class TechReborn implements ModInitializer {
|
|||
INSTANCE = this;
|
||||
@SuppressWarnings("unused")
|
||||
RegistrationManager registrationManager = new RegistrationManager("techreborn", getClass());
|
||||
// TechRebornAPI.subItemRetriever = new SubItemRetriever();
|
||||
|
||||
// Done to force the class to load
|
||||
ModRecipes.GRINDER.getName();
|
||||
|
@ -72,15 +72,13 @@ public class TechReborn implements ModInitializer {
|
|||
ServerboundPackets.init();
|
||||
|
||||
ModRegistry.setupShit();
|
||||
RecipeCrafter.soundHanlder = new ModSounds.SoundHandler();
|
||||
|
||||
proxy.preInit();
|
||||
|
||||
// Registers Chest Loot
|
||||
ModLoot.init();
|
||||
// MinecraftForge.EVENT_BUS.register(new ModLoot());
|
||||
// Sounds
|
||||
// TODO 1.13 registry events
|
||||
ModSounds.init();
|
||||
// Client only init, needs to be done before parts system
|
||||
proxy.init();
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import techreborn.blocks.misc.BlockRubberPlankStair;
|
|||
import techreborn.blocks.misc.BlockRubberSapling;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModFluids;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.init.TRArmorMaterial;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRContent.*;
|
||||
|
@ -82,6 +83,7 @@ public class ModRegistry {
|
|||
registerBlocks();
|
||||
registerItems();
|
||||
registerFluids();
|
||||
registerSounds();
|
||||
}
|
||||
|
||||
public static void registerBlocks() {
|
||||
|
@ -214,4 +216,16 @@ public class ModRegistry {
|
|||
public static void registerFluids() {
|
||||
Arrays.stream(ModFluids.values()).forEach(ModFluids::register);
|
||||
}
|
||||
|
||||
public static void registerSounds() {
|
||||
ModSounds.ALARM = InitUtils.setup("alarm");
|
||||
ModSounds.ALARM_2 = InitUtils.setup("alarm_2");
|
||||
ModSounds.ALARM_3 = InitUtils.setup("alarm_3");
|
||||
ModSounds.AUTO_CRAFTING = InitUtils.setup("auto_crafting");
|
||||
ModSounds.BLOCK_DISMANTLE = InitUtils.setup("block_dismantle");
|
||||
ModSounds.CABLE_SHOCK = InitUtils.setup("cable_shock");
|
||||
ModSounds.MACHINE_RUN = InitUtils.setup("machine_run");
|
||||
ModSounds.MACHINE_START = InitUtils.setup("machine_start");
|
||||
ModSounds.SAP_EXTRACT = InitUtils.setup("sap_extract");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,7 @@ package techreborn.init;
|
|||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.common.recipes.ICrafterSoundHanlder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
|
||||
/**
|
||||
* Created by Mark on 20/03/2016.
|
||||
|
@ -47,34 +44,12 @@ public class ModSounds {
|
|||
public static SoundEvent ALARM_2;
|
||||
public static SoundEvent ALARM_3;
|
||||
|
||||
public static void init() {
|
||||
CABLE_SHOCK = getSound("cable_shock");
|
||||
BLOCK_DISMANTLE = getSound("block_dismantle");
|
||||
SAP_EXTRACT = getSound("sap_extract");
|
||||
AUTO_CRAFTING = getSound("auto_crafting");
|
||||
MACHINE_RUN = getSound("machine_run");
|
||||
MACHINE_START = getSound("machine_start");
|
||||
ALARM = getSound("alarm");
|
||||
ALARM_2 = getSound("alarm_2");
|
||||
ALARM_3 = getSound("alarm_3");
|
||||
|
||||
RecipeCrafter.soundHanlder = new SoundHandler();
|
||||
}
|
||||
|
||||
private static SoundEvent getSound(String str) {
|
||||
Identifier identifier = new Identifier("techreborn", str);
|
||||
SoundEvent soundEvent = new SoundEvent(identifier);
|
||||
return Registry.register(Registry.SOUND_EVENT, identifier, soundEvent);
|
||||
}
|
||||
|
||||
public static class SoundHandler implements ICrafterSoundHanlder {
|
||||
|
||||
@Override
|
||||
public void playSound(boolean firstRun, BlockEntity blockEntity) {
|
||||
blockEntity.getWorld().playSound(null, blockEntity.getPos().getX(), blockEntity.getPos().getY(),
|
||||
blockEntity.getPos().getZ(), ModSounds.MACHINE_RUN,
|
||||
SoundCategory.BLOCKS, 0.1F, 1F);
|
||||
blockEntity.getPos().getZ(), ModSounds.MACHINE_RUN, SoundCategory.BLOCKS, 0.1F, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ package techreborn.utils;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.RebornRegistry;
|
||||
import techreborn.TechReborn;
|
||||
|
||||
|
@ -40,4 +42,9 @@ public class InitUtils {
|
|||
RebornRegistry.registerIdent(block, new Identifier(TechReborn.MOD_ID, name));
|
||||
return block;
|
||||
}
|
||||
|
||||
public static SoundEvent setup(String name) {
|
||||
Identifier identifier = new Identifier(TechReborn.MOD_ID, name);
|
||||
return Registry.register(Registry.SOUND_EVENT, identifier, new SoundEvent(identifier));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue