Skip to content

Commit

Permalink
Merge pull request #39 from Exaxxion/master
Browse files Browse the repository at this point in the history
Add support for machine sounds (requires GTNE 1.18.5+)
  • Loading branch information
eutro authored Dec 27, 2024
2 parents 74b0267 + 46037a0 commit 1381c92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
dependencies {
implementation rfg.deobf("curse.maven:codechicken-lib-1-8-242818:2779848")
implementation rfg.deobf("curse.maven:gregtech-nomifactory-edition-1019238:5411833") // GT Nomi 1.18.3
implementation rfg.deobf("curse.maven:gregtech-nomifactory-edition-1019238:6020404") // GT Nomi 1.18.5

// Soft Dependencies
implementation "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.684"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eutros.multiblocktweaker.crafttweaker.construction;

import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ZenRegister;
import eutros.multiblocktweaker.crafttweaker.gtwrap.constants.ConstantMoveType;
import eutros.multiblocktweaker.crafttweaker.gtwrap.interfaces.ITextureArea;
Expand All @@ -11,7 +12,9 @@
import gregtech.api.gui.widgets.ProgressWidget;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.crafttweaker.CTRecipeBuilder;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

Expand Down Expand Up @@ -39,6 +42,7 @@ public class RecipeMapBuilder {
private final TByteObjectMap<TextureArea> slotOverlays = new TByteObjectHashMap<>();
private ProgressWidget.MoveType moveType = null;
private TextureArea progressBarTexture = null;
private ResourceLocation sound = null;

/**
* Create a new, blank {@link CTRecipeBuilder} that can be used with {@link #setDefaultRecipe(CTRecipeBuilder)}.
Expand Down Expand Up @@ -245,6 +249,19 @@ public RecipeMapBuilder setSlotOverlay(boolean isOutput, boolean isFluid, boolea
return this;
}

/**
* Set the sound this machine will play while running. If the specified resource doesn't exist, it will not be
* applied.
*
* @param path the resource location of the sound to play, e.g. "gregtech:tick.macerator"
* @return This builder, for convenience.
*/
@ZenMethod
public RecipeMapBuilder setSound(String path) {
sound = new ResourceLocation(path);
return this;
}

/**
* Construct the {@link RecipeMap}.
*
Expand Down Expand Up @@ -272,6 +289,12 @@ public RecipeMap<?> build() {
map.setProgressBar(progressBarTexture, moveType);
}

if (sound != null) {
if(ForgeRegistries.SOUND_EVENTS.containsKey(sound))
map.setSound(ForgeRegistries.SOUND_EVENTS.getValue(sound));
else
CraftTweakerAPI.logError(String.format("Couldn't locate sound '%s'.", sound));
}
return map;
}

Expand Down

0 comments on commit 1381c92

Please sign in to comment.