Merge remote-tracking branch 'origin/1.12' into 1.12

This commit is contained in:
modmuss50 2018-02-11 14:01:45 +00:00
commit 9c3d9d8e27
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
16 changed files with 237 additions and 26 deletions

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