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:
Dimmerworld 2018-02-10 22:53:11 +11:00 committed by Modmuss50
parent 38933ca8a8
commit 9349ffe264
11 changed files with 90 additions and 7 deletions

View file

@ -93,7 +93,7 @@ if (ENV.BUILD_NUMBER) {
}
minecraft {
version = "1.12.2-14.23.1.2590"
version = "1.12.2-14.23.2.2613"
mappings = "snapshot_20171003"
replace "@MODVERSION@", project.version
useDepAts = true

View file

@ -1,4 +1,4 @@
#Mon Jun 19 11:12:24 BST 2017
#Fri Feb 09 20:12:54 AEDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View file

@ -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();

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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));
}
}
}

View file

@ -654,6 +654,7 @@ techreborn.message.noCoordsSet=No Coordinates Set
techreborn.message.coordsHaveBeen=Coordinates have been
techreborn.message.cleared=Cleared
techreborn.message.detects=Detects
techreborn.message.alarm=Switched to:
techreborn.message.allPlayers=All Players
techreborn.message.onlyOtherPlayers=Only Other Players
techreborn.message.onlyYou=Only You

View file

@ -40,5 +40,17 @@
"sounds": [
"techreborn:alarm"
]
},
"alarm_2": {
"category": "block",
"sounds": [
"techreborn:alarm_2"
]
},
"alarm_3": {
"category": "block",
"sounds": [
"techreborn:alarm_3"
]
}
}

View file

@ -0,0 +1,7 @@
alarm_2
by rene___
https://freesound.org/people/rene___/sounds/56778/
alarm_3
by plasterbrain
https://freesound.org/people/plasterbrain/sounds/242856/