Permalink
Browse files

Added lock and unlock sound effects to the blast doors. Fixed a poten…

…tial server crash.
  • Loading branch information...
Ri5ux committed Nov 5, 2017
1 parent 32b6dd7 commit 9503ee1ecd70c8b1add5ad1076ffd9e2016c2171
@@ -25,6 +25,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockBlastdoor extends Block
{
@@ -61,7 +63,8 @@ else if (doorSubBlock.isParent())
{
if (blastdoor.playerHoldingRequiredSecurityTuner(player))
{
FMLCommonHandler.instance().showGuiScreen(new GuiBlastdoor(blastdoor, false));
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
showAdministrationGUI(blastdoor);
}
}
else if (canOpen(blastdoor, player))
@@ -70,13 +73,26 @@ else if (canOpen(blastdoor, player))
}
else if (blastdoor.isLocked())
{
FMLCommonHandler.instance().showGuiScreen(new GuiBlastdoor(blastdoor));
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
showUnlockGUI(blastdoor);
}
}
}
return true;
}
@SideOnly(Side.CLIENT)
public static void showUnlockGUI(TileEntityBlastdoor blastdoor)
{
FMLCommonHandler.instance().showGuiScreen(new GuiBlastdoor(blastdoor));
}
@SideOnly(Side.CLIENT)
public static void showAdministrationGUI(TileEntityBlastdoor blastdoor)
{
FMLCommonHandler.instance().showGuiScreen(new GuiBlastdoor(blastdoor, false));
}
private void onOpen(TileEntityBlastdoor blastdoor, World world, EntityPlayer player)
{
@@ -50,6 +50,8 @@
public static final Sound MOTIONTRACKER_PING = sound("motiontracker.ping");
public static final Sound MOTIONTRACKER_PONG = sound("motiontracker.pong");
public static final Sound BLASTDOOR_OPEN = sound("blocks.blastdoor.open");
public static final Sound BLASTDOOR_UNLOCK = sound("blocks.blastdoor.unlock");
public static final Sound BLASTDOOR_LOCK = sound("blocks.blastdoor.lock");
@Override
public void pre(FMLPreInitializationEvent event)
@@ -250,12 +250,14 @@ public void unlock()
{
this.locked = false;
this.lockTimer = this.getDoorAutolockTime();
this.playUnlockSound();
}
public void lock()
{
this.locked = true;
this.setOpen(false);
this.playLockSound();
IBlockState state = world.getBlockState(this.getPos());
world.notifyBlockUpdate(this.getPos(), state, state, 3);
}
@@ -326,7 +328,7 @@ else if (this.isParent())
{
if (this.doorOpen != doorOpen)
{
this.playDoorOpenSound();
this.playOpenSound();
}
this.doorOpen = doorOpen;
@@ -558,10 +560,20 @@ public float getDoorProgressPrev()
return set.toArray(new BlockPos[set.size()]);
}
public void playDoorOpenSound()
public void playOpenSound()
{
AliensVsPredator.sounds().BLASTDOOR_OPEN.playSound(world, pos, 1F, 1F);
}
public void playUnlockSound()
{
AliensVsPredator.sounds().BLASTDOOR_UNLOCK.playSound(world, pos.getX(), pos.getY(), pos.getZ(), 50F, 1F, false);
}
public void playLockSound()
{
AliensVsPredator.sounds().BLASTDOOR_LOCK.playSound(world, pos.getX(), pos.getY(), pos.getZ(), 1F, 1F, false);
}
public boolean authenticate(String key)
{
@@ -38,7 +38,7 @@ public float getDoorSpeed()
}
@Override
public void playDoorOpenSound()
public void playOpenSound()
{
AliensVsPredator.sounds().BLASTDOOR_OPEN.playSound(world, pos, 1F, 2F);
}
@@ -47,6 +47,8 @@
"motiontracker.pong": { "sounds": [ "avp:items/motiontracker/pong" ] },
"blocks.turret.shoot": { "sounds": [ "avp:blocks/turret/shoot" ] },
"blocks.blastdoor.open": { "sounds": [ "avp:blocks/blastdoor/open" ] },
"blocks.blastdoor.lock": { "sounds": [ "avp:blocks/blastdoor/lock" ] },
"blocks.blastdoor.unlock": { "sounds": [ "avp:blocks/blastdoor/unlock" ] },
"blocks.hive.step": { "sounds": [ "avp:blocks/hive/step0", "avp:blocks/hive/step1", "avp:blocks/hive/step2", "avp:blocks/hive/step3" ] },
"blocks.newglass.step": { "sounds": [ "avp:blocks/newglass/step0", "avp:blocks/newglass/step1", "avp:blocks/newglass/step2", "avp:blocks/newglass/step3" ] },
"blocks.alarm.access": { "sounds": [ "avp:blocks/alarm/access" ] },
Binary file not shown.

0 comments on commit 9503ee1

Please sign in to comment.