diff options
Diffstat (limited to 'src/main')
5 files changed, 172 insertions, 21 deletions
diff --git a/src/main/java/gregtech/api/enums/SoundResource.java b/src/main/java/gregtech/api/enums/SoundResource.java index c99083b690..9de5c56015 100644 --- a/src/main/java/gregtech/api/enums/SoundResource.java +++ b/src/main/java/gregtech/api/enums/SoundResource.java @@ -78,26 +78,28 @@ public enum SoundResource { GT_SPRAYCAN_LOCK(244, GregTech.ID, "items.spraycan_lock"), GT_SPRAYCAN_UNLOCK(245, GregTech.ID, "items.spraycan_unlock"), - GT_MACHINES_MULTI_PRECISE_LOOP(244, GregTech.ID, "machines.MTEPreciseAssembler"), - GT_MACHINES_MULTI_ORE_WASHER_PLANT_LOOP(245, GregTech.ID, "machines.MTEIndustrialWashPlant"), - GT_MACHINES_MULTI_MEGA_VACUUM_FREEZER_LOOP(246, GregTech.ID, "machines.MTEMegaVacuumFreezer"), - GT_MACHINES_MULTI_VACUUM_FREEZER_LOOP(247, GregTech.ID, "machines.MTEVacuumFreezer"), - GT_MACHINES_EXTREME_ENTITY_CRUSHER_LOOP(248, GregTech.ID, "machines.MTEExtremeEntityCrusher"), - GT_MACHINES_CUTTING_MACHINE_LOOP(249, GregTech.ID, "machines.MTEIndustrialCuttingMachine"), - GT_MACHINES_ARC_FURNACE_LOOP(250, GregTech.ID, "machines.MTEIndustrialArcFurnace"), - GT_MACHINES_MEGA_INDUSTRIAL_APIARY_LOOP(251, GregTech.ID, "machines.MTEMegaIndustrialApiary"), - GT_MACHINES_ALGAE_LOOP(252, GregTech.ID, "machines.MTEAlgaePondBase"), - GT_MACHINES_THERMAL_CENTRIFUGE_LOOP(253, GregTech.ID, "machines.MTEIndustrialThermalCentrifuge"), - GT_MACHINES_SIFTER_LOOP(254, GregTech.ID, "machines.MTEIndustrialSifter"), - GT_MACHINES_EYE_OF_HARMONY_LOOP(255, GregTech.ID, "machines.MTEEyeOfHarmony"), - GT_MACHINES_EBF_LOOP(256, GregTech.ID, "machines.MTEElectricBlastFurnace"), - GT_MACHINES_ADV_FREEZER_LOOP(257, GregTech.ID, "machines.MTEIndustrialVacuumFreezer"), - GT_MACHINES_GOD_FORGE_LOOP(258, GregTech.ID, "machines.MTEForgeOfGods"), - GT_MACHINES_MEGA_BLAST_FURNACE_LOOP(259, GregTech.ID, "machines.MTEMegaBlastFurnace"), - GT_MACHINES_OIL_DRILL_LOOP(260, GregTech.ID, "machines.MTEOilDrillBase"), - GT_MACHINES_QUANTUM_FORCE_TRANSFORMER_LOOP(261, GregTech.ID, "machines.MTEQuantumForceTransformer"), - GT_MACHINES_ADV_EBF_LOOP(262, GregTech.ID, "machines.MTEAdvEBF"), - GT_MACHINES_LARGE_TURBINES_LOOP(263, GregTech.ID, "machines.MTELargeTurbine"), + GT_MACHINES_BLACK_HOLE_COMPRESSOR(246, GregTech.ID, "machines.BlackHoleCompressorLoop"), + + GT_MACHINES_MULTI_PRECISE_LOOP(247, GregTech.ID, "machines.MTEPreciseAssembler"), + GT_MACHINES_MULTI_ORE_WASHER_PLANT_LOOP(248, GregTech.ID, "machines.MTEIndustrialWashPlant"), + GT_MACHINES_MULTI_MEGA_VACUUM_FREEZER_LOOP(249, GregTech.ID, "machines.MTEMegaVacuumFreezer"), + GT_MACHINES_MULTI_VACUUM_FREEZER_LOOP(250, GregTech.ID, "machines.MTEVacuumFreezer"), + GT_MACHINES_EXTREME_ENTITY_CRUSHER_LOOP(251, GregTech.ID, "machines.MTEExtremeEntityCrusher"), + GT_MACHINES_CUTTING_MACHINE_LOOP(252, GregTech.ID, "machines.MTEIndustrialCuttingMachine"), + GT_MACHINES_ARC_FURNACE_LOOP(253, GregTech.ID, "machines.MTEIndustrialArcFurnace"), + GT_MACHINES_MEGA_INDUSTRIAL_APIARY_LOOP(254, GregTech.ID, "machines.MTEMegaIndustrialApiary"), + GT_MACHINES_ALGAE_LOOP(255, GregTech.ID, "machines.MTEAlgaePondBase"), + GT_MACHINES_THERMAL_CENTRIFUGE_LOOP(256, GregTech.ID, "machines.MTEIndustrialThermalCentrifuge"), + GT_MACHINES_SIFTER_LOOP(257, GregTech.ID, "machines.MTEIndustrialSifter"), + GT_MACHINES_EYE_OF_HARMONY_LOOP(258, GregTech.ID, "machines.MTEEyeOfHarmony"), + GT_MACHINES_EBF_LOOP(259, GregTech.ID, "machines.MTEElectricBlastFurnace"), + GT_MACHINES_ADV_FREEZER_LOOP(260, GregTech.ID, "machines.MTEIndustrialVacuumFreezer"), + GT_MACHINES_GOD_FORGE_LOOP(261, GregTech.ID, "machines.MTEForgeOfGods"), + GT_MACHINES_MEGA_BLAST_FURNACE_LOOP(262, GregTech.ID, "machines.MTEMegaBlastFurnace"), + GT_MACHINES_OIL_DRILL_LOOP(263, GregTech.ID, "machines.MTEOilDrillBase"), + GT_MACHINES_QUANTUM_FORCE_TRANSFORMER_LOOP(264, GregTech.ID, "machines.MTEQuantumForceTransformer"), + GT_MACHINES_ADV_EBF_LOOP(265, GregTech.ID, "machines.MTEAdvEBF"), + GT_MACHINES_LARGE_TURBINES_LOOP(266, GregTech.ID, "machines.MTELargeTurbine"), GUI_BUTTON_DOWN(-1, GregTech.ID, "gui.buttonDown"), GUI_BUTTON_UP(-1, GregTech.ID, "gui.buttonUp"), diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java index ba1c38db40..edfa676b53 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java @@ -28,6 +28,8 @@ import java.util.stream.Stream; import javax.annotation.Nonnull; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; @@ -48,9 +50,12 @@ import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTechAPI; import gregtech.api.enums.Materials; import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; @@ -76,6 +81,7 @@ import gregtech.common.tileentities.render.TileEntityBlackhole; import gtPlusPlus.core.util.minecraft.PlayerUtils; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; +import tectech.thing.metaTileEntity.multi.base.SoundLoopAnyBlock; public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBlackHoleCompressor> implements ISurvivalConstructable { @@ -153,6 +159,9 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl */ private byte blackHoleStatus = 1; + @SideOnly(Side.CLIENT) + private SoundLoopAnyBlock blackholeSoundLoop; + private final FluidStack blackholeCatalyzingCost = (MaterialsUEVplus.SpaceTime).getMolten(1); private int catalyzingCostModifier = 1; @@ -216,6 +225,44 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl if (oBlackHoleStatus != blackHoleStatus) getBaseMetaTileEntity().issueTextureUpdate(); } + @SideOnly(Side.CLIENT) + public void playBlackHoleSounds() { + if (blackHoleStatus > 1) { + if (blackholeSoundLoop == null) { + ForgeDirection oppositeDirection = getDirection().getOpposite(); + int offsetX = 7 * oppositeDirection.offsetX; + int offsetY = 11; + int offsetZ = 7 * oppositeDirection.offsetZ; + + World world = Minecraft.getMinecraft().thePlayer.worldObj; + IGregTechTileEntity base = getBaseMetaTileEntity(); + + int x = base.getXCoord() + offsetX; + int y = base.getYCoord() + offsetY; + int z = base.getZCoord() + offsetZ; + + Block blockAtSoundLocation = world.getBlock(x, y, z); + if (blockAtSoundLocation == Blocks.air) return; + + int[] offset = { offsetX, offsetY, offsetZ }; + blackholeSoundLoop = new SoundLoopAnyBlock( + SoundResource.GT_MACHINES_BLACK_HOLE_COMPRESSOR.resourceLocation, + getBaseMetaTileEntity(), + false, + false, + offset, + Blocks.air); + Minecraft.getMinecraft() + .getSoundHandler() + .playSound(blackholeSoundLoop); + } + } else { + if (blackholeSoundLoop != null) { + blackholeSoundLoop = null; + } + } + } + @Override public byte getUpdateData() { return blackHoleStatus; @@ -544,13 +591,16 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl mOutputItems = null; mOutputFluids = null; } + return super.onRunningTick(aStack); } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - + if (!aBaseMetaTileEntity.isServerSide()) { + playBlackHoleSounds(); + } if (aTick % 20 == 0) { if (blackHoleStatus == 2) { if (blackHoleStability >= 0) { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoopAnyBlock.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoopAnyBlock.java new file mode 100644 index 0000000000..15b08afb5c --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoopAnyBlock.java @@ -0,0 +1,90 @@ +package tectech.thing.metaTileEntity.multi.base; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.MovingSound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +@SideOnly(Side.CLIENT) +public class SoundLoopAnyBlock extends MovingSound { + + private final boolean stopWhenBlockActive; + private final boolean stopWhenBlockInactive; + private final int worldID; + private boolean fadeOut = false; + private int tileX; + private int tileY; + private int tileZ; + private Block blockToTriggerEnd = null; + + /** + * Constructs a SoundLoopAnyBlock. + * + * @param soundResource the sound file location + * @param tileEntity the tile entity associated with this sound + * @param stopWhenActive flag to stop the sound when the block is active + * @param stopWhenInactive flag to stop the sound when the block is inactive + * @param offset positional offset for sound origin from the tile entity [x, y, z] + * @param blockCheck block that ends the sound when matched at the sound location + */ + public SoundLoopAnyBlock(ResourceLocation soundResource, IGregTechTileEntity tileEntity, boolean stopWhenActive, + boolean stopWhenInactive, int[] offset, Block blockCheck) { + super(soundResource); + this.stopWhenBlockActive = stopWhenActive; + this.stopWhenBlockInactive = stopWhenInactive; + tileX = tileEntity.getXCoord(); + tileY = tileEntity.getYCoord(); + tileZ = tileEntity.getZCoord(); + xPosF = tileX + offset[0]; + yPosF = tileY + offset[1]; + zPosF = tileZ + offset[2]; + worldID = tileEntity.getWorld().provider.dimensionId; + repeat = true; + volume = 0.0625f; + blockToTriggerEnd = blockCheck; + } + + @Override + public void update() { + if (donePlaying) { + return; + } + + if (fadeOut) { + volume -= 0.0625f; + if (volume <= 0) { + volume = 0; + donePlaying = true; + } + } else if (volume < 1) { + volume += 0.0625f; + } + + World world = Minecraft.getMinecraft().thePlayer.worldObj; + donePlaying = world.provider.dimensionId != worldID + || !world.checkChunksExist((int) xPosF, (int) yPosF, (int) zPosF, (int) xPosF, (int) yPosF, (int) zPosF); + + if (donePlaying) return; + + Block blockAtSoundLocation = world.getBlock((int) xPosF, (int) yPosF, (int) zPosF); + if (blockToTriggerEnd != null) { + donePlaying = blockAtSoundLocation == blockToTriggerEnd; + } + + if (donePlaying) return; + + TileEntity tile = world.getTileEntity(tileX, tileY, tileZ); + donePlaying = tile == null; + + if (donePlaying) return; + + // Adjust fading based on the activity state of the tile entity + fadeOut |= ((IGregTechTileEntity) tile).isActive() ? stopWhenBlockActive : stopWhenBlockInactive; + } +} diff --git a/src/main/resources/assets/gregtech/sounds.json b/src/main/resources/assets/gregtech/sounds.json index 4f38e6827f..3488cc8373 100644 --- a/src/main/resources/assets/gregtech/sounds.json +++ b/src/main/resources/assets/gregtech/sounds.json @@ -142,6 +142,15 @@ } ] }, + "machines.BlackHoleCompressorLoop": { + "category": "block", + "sounds": [ + { + "name": "BlackHoleCompressorLoop", + "stream": false + } + ] + }, "items.spraycan_shake": { "category": "player", "sounds": [ diff --git a/src/main/resources/assets/gregtech/sounds/BlackHoleCompressorLoop.ogg b/src/main/resources/assets/gregtech/sounds/BlackHoleCompressorLoop.ogg Binary files differnew file mode 100644 index 0000000000..b2692e9531 --- /dev/null +++ b/src/main/resources/assets/gregtech/sounds/BlackHoleCompressorLoop.ogg |