Update forge and Sound options for Alarm (#1435)
* Update forge and Sound options for Alarm * Revert changes to gradle wrapper properties * Cleanup imports * Removed sneaky debugging stuff
This commit is contained in:
parent
38933ca8a8
commit
9349ffe264
11 changed files with 90 additions and 7 deletions
|
@ -30,6 +30,7 @@ import net.minecraft.block.properties.PropertyDirection;
|
|||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -81,6 +82,21 @@ public class BlockAlarm extends BaseTileBlock {
|
|||
return new BlockStateContainer(this, FACING, ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
TileAlarm tileEntity = (TileAlarm)worldIn.getTileEntity(pos);
|
||||
if (tileEntity == null) {
|
||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
|
||||
}else {
|
||||
if(!worldIn.isRemote) {
|
||||
if(playerIn.isSneaking()) {
|
||||
tileEntity.rightClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
int facingInt = state.getValue(FACING).getIndex();
|
||||
|
|
|
@ -44,6 +44,8 @@ public class ModSounds {
|
|||
public static SoundEvent MACHINE_RUN;
|
||||
public static SoundEvent MACHINE_START;
|
||||
public static SoundEvent ALARM;
|
||||
public static SoundEvent ALARM_2;
|
||||
public static SoundEvent ALARM_3;
|
||||
|
||||
public static void init() {
|
||||
CABLE_SHOCK = getSound("cable_shock");
|
||||
|
@ -53,6 +55,8 @@ public class ModSounds {
|
|||
MACHINE_RUN = getSound("machine_run");
|
||||
MACHINE_START = getSound("machine_start");
|
||||
ALARM = getSound("alarm");
|
||||
ALARM_2 = getSound("alarm_2");
|
||||
ALARM_3 = getSound("alarm_3");
|
||||
|
||||
RecipeCrafter.soundHanlder = new SoundHandler();
|
||||
}
|
||||
|
|
|
@ -32,4 +32,5 @@ public class MessageIDs {
|
|||
public static int fluidPipeID = 1;
|
||||
public static int playerDetectorID = 2;
|
||||
public static int nanosaberID = 3;
|
||||
public static int alarmID = 4;
|
||||
}
|
||||
|
|
|
@ -24,25 +24,67 @@
|
|||
|
||||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import techreborn.blocks.BlockAlarm;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.lib.MessageIDs;
|
||||
|
||||
public class TileAlarm extends TileEntity implements ITickable {
|
||||
boolean state = false;
|
||||
int selectedSound;
|
||||
private int selectedSound = 1;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isRemote && world.getTotalWorldTime() % 25 == 0 && world.isBlockPowered(getPos())) {
|
||||
BlockAlarm.setActive(true, world, pos);
|
||||
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
|
||||
state = true;
|
||||
switch(selectedSound){
|
||||
case 1:
|
||||
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
case 2:
|
||||
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
case 3:
|
||||
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (!world.isRemote && world.getTotalWorldTime() % 25 == 0) {
|
||||
BlockAlarm.setActive(false, world, pos);
|
||||
state = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
if(compound == null){
|
||||
compound = new NBTTagCompound();
|
||||
}
|
||||
compound.setInteger("selectedSound", this.selectedSound);
|
||||
return super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
if(compound != null && compound.hasKey("selectedSound")){
|
||||
this.selectedSound = compound.getInteger("selectedSound");
|
||||
}
|
||||
super.readFromNBT(compound);
|
||||
}
|
||||
|
||||
public void rightClick() {
|
||||
if (!world.isRemote){
|
||||
if(selectedSound < 3){
|
||||
selectedSound++;
|
||||
}else{
|
||||
selectedSound = 1;
|
||||
}
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.alarm") + " " + "Alarm " + selectedSound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue