-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
187 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...om/zorbatron/zbgt/common/metatileentities/multi/electric/quads/MetaTileEntityQuacker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
] | ||
} | ||
} |
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.