diff --git a/src/main/java/com/zorbatron/zbgt/api/util/ZBGTUtility.java b/src/main/java/com/zorbatron/zbgt/api/util/ZBGTUtility.java index 27b78cfb..6de855c5 100644 --- a/src/main/java/com/zorbatron/zbgt/api/util/ZBGTUtility.java +++ b/src/main/java/com/zorbatron/zbgt/api/util/ZBGTUtility.java @@ -6,6 +6,8 @@ import org.jetbrains.annotations.NotNull; +import com.zorbatron.zbgt.ZBGTCore; + import gregtech.api.capability.INotifiableHandler; import gregtech.api.capability.impl.GhostCircuitItemStackHandler; import gregtech.api.capability.impl.ItemHandlerList; @@ -16,7 +18,7 @@ public class ZBGTUtility { public static @NotNull ResourceLocation zbgtId(@NotNull String path) { - return new ResourceLocation("zbgt", path); + return new ResourceLocation(ZBGTCore.MODID, path); } public static final int[] intV = { 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608, 33554432, diff --git a/src/main/java/com/zorbatron/zbgt/common/ZBGTMetaTileEntities.java b/src/main/java/com/zorbatron/zbgt/common/ZBGTMetaTileEntities.java index 4f68326a..4285ba7d 100644 --- a/src/main/java/com/zorbatron/zbgt/common/ZBGTMetaTileEntities.java +++ b/src/main/java/com/zorbatron/zbgt/common/ZBGTMetaTileEntities.java @@ -6,8 +6,7 @@ import com.zorbatron.zbgt.common.metatileentities.multi.MetaTileEntityYOTTank; import com.zorbatron.zbgt.common.metatileentities.multi.electric.*; import com.zorbatron.zbgt.common.metatileentities.multi.electric.megamultis.*; -import com.zorbatron.zbgt.common.metatileentities.multi.electric.quads.MetaTileEntityQuadEBF; -import com.zorbatron.zbgt.common.metatileentities.multi.electric.quads.MetaTileEntityQueezer; +import com.zorbatron.zbgt.common.metatileentities.multi.electric.quads.*; import com.zorbatron.zbgt.common.metatileentities.multi.multiblockpart.*; import com.zorbatron.zbgt.common.metatileentities.storage.MetaTileEntityCreativeComputationProvider; @@ -39,6 +38,7 @@ public class ZBGTMetaTileEntities { public static MetaTileEntityQuadEBF QUAD_EBF; public static MetaTileEntityQueezer QUEEZER; + public static MetaTileEntityQuacker QUACKER; public static MetaTileEntityYOTTank YOTTANK; @@ -125,5 +125,8 @@ public static void init() { new MetaTileEntityMegaFusionReactor(zbgtId("mega_fusion_2"), GTValues.ZPM)); MEGA_FUSION[2] = registerMetaTileEntity(18062, new MetaTileEntityMegaFusionReactor(zbgtId("mega_fusion_3"), GTValues.UV)); + + QUACKER = registerMetaTileEntity(18063, + new MetaTileEntityQuacker(zbgtId("quacker"))); } } diff --git a/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/quads/MetaTileEntityQuacker.java b/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/quads/MetaTileEntityQuacker.java new file mode 100644 index 00000000..7b3967cc --- /dev/null +++ b/src/main/java/com/zorbatron/zbgt/common/metatileentities/multi/electric/quads/MetaTileEntityQuacker.java @@ -0,0 +1,84 @@ +package com.zorbatron.zbgt.common.metatileentities.multi.electric.quads; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import org.jetbrains.annotations.NotNull; + +import com.zorbatron.zbgt.core.sound.ZBGTSoundEvents; + +import gregtech.api.GTValues; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.pattern.BlockPattern; +import gregtech.api.pattern.FactoryBlockPattern; +import gregtech.common.metatileentities.multi.electric.MetaTileEntityCrackingUnit; + +public class MetaTileEntityQuacker extends MetaTileEntityCrackingUnit { + + private int quackTimer; + + public MetaTileEntityQuacker(ResourceLocation metaTileEntityId) { + super(metaTileEntityId); + this.recipeMapWorkable.setParallelLimit(4); + this.quackTimer = calculateQuackInterval(); + } + + @Override + public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { + return new MetaTileEntityQuacker(metaTileEntityId); + } + + @Override + protected void updateFormedValid() { + super.updateFormedValid(); + + if (isActive() && quackTimer == 0) { + playQuack(); + // Only quack every 1 to 5 minutes. + quackTimer = calculateQuackInterval(); + } else if (quackTimer > 0) { + quackTimer--; + } + } + + private int calculateQuackInterval() { + return 20 * 60 + GTValues.RNG.nextInt(20 * 60 * 4); + } + + @SideOnly(Side.CLIENT) + private void playQuack() { + int randomInt = GTValues.RNG.nextInt(5); + ResourceLocation soundLocation = ZBGTSoundEvents.QUACKS.get(randomInt).getSoundName(); + BlockPos pos = getPos(); + + // I'm not using GregTechAPI.soundManager.startTileSound because it checks if a sound is playing at the + // position, which there will be because of the cracker's normal active sound effect. + ISound sound = new PositionedSoundRecord(soundLocation, SoundCategory.BLOCKS, getVolume(), 1.0F, + false, 0, ISound.AttenuationType.LINEAR, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F); + Minecraft.getMinecraft().getSoundHandler().playSound(sound); + } + + @Override + protected @NotNull BlockPattern createStructurePattern() { + return FactoryBlockPattern.start() + .aisle("XCXCX", "XCXCX", "XCXCX", "XCXCX", "XCXCX") + .aisle("XCXCX", "X###X", "XCTCX", "X###X", "XCXCX") + .aisle("XCXCX", "XCTCX", "XCTCX", "XCTCX", "XCXCX") + .aisle("XCXCX", "X###X", "XCTCX", "X###X", "XCXCX") + .aisle("XCXCX", "XCXCX", "XCSCX", "XCXCX", "XCXCX") + .where('S', selfPredicate()) + .where('C', heatingCoils()) + .where('X', states(getCasingState()).setMinGlobalLimited(25) + .or(autoAbilities())) + .where('T', states(getCasingState())) + .where('#', air()) + .build(); + } +} diff --git a/src/main/java/com/zorbatron/zbgt/core/sound/ZBGTSoundEvents.java b/src/main/java/com/zorbatron/zbgt/core/sound/ZBGTSoundEvents.java index d8c1878a..c47400a2 100644 --- a/src/main/java/com/zorbatron/zbgt/core/sound/ZBGTSoundEvents.java +++ b/src/main/java/com/zorbatron/zbgt/core/sound/ZBGTSoundEvents.java @@ -1,5 +1,11 @@ package com.zorbatron.zbgt.core.sound; +import static com.zorbatron.zbgt.api.util.ZBGTUtility.zbgtId; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import gregtech.api.GregTechAPI; @@ -8,7 +14,25 @@ public class ZBGTSoundEvents { public static SoundEvent FX_LOW_FREQ; + public static List QUACKS; + public static SoundEvent QUACK_1; + public static SoundEvent QUACK_2; + public static SoundEvent QUACK_3; + public static SoundEvent QUACK_4; + public static SoundEvent QUACK_5; + public static void register() { - FX_LOW_FREQ = GregTechAPI.soundManager.registerSound("fx_lo_freq"); + FX_LOW_FREQ = registerSoundHelper(zbgtId("yottank_pulse")); + + QUACK_1 = registerSoundHelper(zbgtId("quack_1")); + QUACK_2 = registerSoundHelper(zbgtId("quack_2")); + QUACK_3 = registerSoundHelper(zbgtId("quack_3")); + QUACK_4 = registerSoundHelper(zbgtId("quack_4")); + QUACK_5 = registerSoundHelper(zbgtId("quack_5")); + QUACKS = Arrays.asList(QUACK_1, QUACK_2, QUACK_3, QUACK_4, QUACK_5); + } + + private static SoundEvent registerSoundHelper(ResourceLocation resourceLocation) { + return GregTechAPI.soundManager.registerSound(resourceLocation.getNamespace(), resourceLocation.getPath()); } } diff --git a/src/main/resources/assets/gregtech/sounds.json b/src/main/resources/assets/gregtech/sounds.json deleted file mode 100644 index dd512923..00000000 --- a/src/main/resources/assets/gregtech/sounds.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "fx_lo_freq": { - "category": "block", - "subtitle": "zbgt.subtitle.fx_lo_freq", - "sounds": [ - { - "name": "gregtech:fx_lo_freq", - "stream": false - } - ] - } -} diff --git a/src/main/resources/assets/zbgt/lang/en_us.lang b/src/main/resources/assets/zbgt/lang/en_us.lang index 0d3d28d5..d8bfdf9d 100644 --- a/src/main/resources/assets/zbgt/lang/en_us.lang +++ b/src/main/resources/assets/zbgt/lang/en_us.lang @@ -186,6 +186,12 @@ recipemap.precise_assembler_recipes.name=Precise Assembler zbgt.machine.quad_ebf.name=Quad EBF zbgt.machine.quad_ebf.tooltip=The same shape as a quad EBF, and thus has 4 innate parallels! +zbgt.machine.queezer.name=Queezer +zbgt.machine.queezer.tooltip=A quad freezer that has 4 innate parallels + +zbgt.machine.quacker.name=Quacker +zbgt.machine.quacker.tooltip=A slightly larger oil cracker, although it may sometimes act like a duck... + zbgt.machine.coal.name=Component Assembly Line zbgt.machine.coal.description.1=Creates large batches of §fComponents§7 for §e75%%§7 of the Cost. zbgt.machine.coal.description.2=Recipes are limited by §bCasing Tier§7. @@ -196,9 +202,6 @@ zbgt.machine.coal.computation_tier.hover=Maximum amount of computation available zbgt.recipe.coal_casing_tier=Casing Tier: recipemap.coal_recipes.name=Component Assembly Line -zbgt.machine.queezer.name=Queezer -zbgt.machine.queezer.tooltip=A quad freezer that has 4 innate parallels - zbgt.machine.yottank.name=YOTTank zbgt.machine.yottank.max_capacity=Capacity: %s zbgt.machine.yottank.current_capacity=Stored: %s @@ -294,7 +297,8 @@ zbgt.substation_enabled= and Substation Hatches # Sound subtitles -zbgt.subtitle.fx_lo_freq=Low Frequency Buzzing +zbgt.subtitle.yottank_pulse=YOTTank Pulsed +zbgt.subtitle.quack=Quacker Quacked # Materials diff --git a/src/main/resources/assets/zbgt/sounds.json b/src/main/resources/assets/zbgt/sounds.json new file mode 100644 index 00000000..45f87671 --- /dev/null +++ b/src/main/resources/assets/zbgt/sounds.json @@ -0,0 +1,62 @@ +{ + "yottank_pulse": { + "category": "block", + "subtitle": "zbgt.subtitle.yottank_pulse", + "sounds": [ + { + "name": "zbgt:fx_lo_freq", + "stream": false + } + ] + }, + "quack_1": { + "category": "block", + "subtitle": "zbgt.subtitle.quack", + "sounds": [ + { + "name": "zbgt:quack_1", + "stream": false + } + ] + }, + "quack_2": { + "category": "block", + "subtitle": "zbgt.subtitle.quack", + "sounds": [ + { + "name": "zbgt:quack_2", + "stream": false + } + ] + }, + "quack_3": { + "category": "block", + "subtitle": "zbgt.subtitle.quack", + "sounds": [ + { + "name": "zbgt:quack_3", + "stream": false + } + ] + }, + "quack_4": { + "category": "block", + "subtitle": "zbgt.subtitle.quack", + "sounds": [ + { + "name": "zbgt:quack_4", + "stream": false + } + ] + }, + "quack_5": { + "category": "block", + "subtitle": "zbgt.subtitle.quack", + "sounds": [ + { + "name": "zbgt:quack_5", + "stream": false + } + ] + } +} diff --git a/src/main/resources/assets/gregtech/sounds/fx_lo_freq.ogg b/src/main/resources/assets/zbgt/sounds/fx_lo_freq.ogg similarity index 100% rename from src/main/resources/assets/gregtech/sounds/fx_lo_freq.ogg rename to src/main/resources/assets/zbgt/sounds/fx_lo_freq.ogg diff --git a/src/main/resources/assets/zbgt/sounds/quack_1.ogg b/src/main/resources/assets/zbgt/sounds/quack_1.ogg new file mode 100644 index 00000000..822ffc44 Binary files /dev/null and b/src/main/resources/assets/zbgt/sounds/quack_1.ogg differ diff --git a/src/main/resources/assets/zbgt/sounds/quack_2.ogg b/src/main/resources/assets/zbgt/sounds/quack_2.ogg new file mode 100644 index 00000000..825b0158 Binary files /dev/null and b/src/main/resources/assets/zbgt/sounds/quack_2.ogg differ diff --git a/src/main/resources/assets/zbgt/sounds/quack_3.ogg b/src/main/resources/assets/zbgt/sounds/quack_3.ogg new file mode 100644 index 00000000..b93a61e9 Binary files /dev/null and b/src/main/resources/assets/zbgt/sounds/quack_3.ogg differ diff --git a/src/main/resources/assets/zbgt/sounds/quack_4.ogg b/src/main/resources/assets/zbgt/sounds/quack_4.ogg new file mode 100644 index 00000000..eb0ef66b Binary files /dev/null and b/src/main/resources/assets/zbgt/sounds/quack_4.ogg differ diff --git a/src/main/resources/assets/zbgt/sounds/quack_5.ogg b/src/main/resources/assets/zbgt/sounds/quack_5.ogg new file mode 100644 index 00000000..3ee4bc14 Binary files /dev/null and b/src/main/resources/assets/zbgt/sounds/quack_5.ogg differ