mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Add a teleport active sound, fix Lang
This commit is contained in:
1 parent
24549156c0
commit
bf0bf98c21
6 files changed
+60
-8
No files matched your search
@@ -60,7 +60,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
|
||||
private final ResourceLocation soundRes;
|
||||
|
||||
protected static ResourceLocation getSoundFor(String sound) {
|
||||
public static ResourceLocation getSoundFor(String sound) {
|
||||
return sound == null ? null : new ResourceLocation(EnderIO.MODID + ":" + sound);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import net.minecraft.client.audio.ITickableSound;
|
||||
import net.minecraft.client.audio.PositionedSound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class MachineSound extends PositionedSound implements ITickableSound{
|
||||
public class MachineSound extends PositionedSound implements ITickableSound {
|
||||
|
||||
private boolean donePlaying;
|
||||
|
||||
|
||||
public MachineSound(ResourceLocation sound, float x, float y, float z, float volume, float pitch) {
|
||||
super(sound);
|
||||
this.xPosF = x;
|
||||
@@ -27,12 +27,22 @@ public class MachineSound extends PositionedSound implements ITickableSound{
|
||||
public boolean isDonePlaying() {
|
||||
return donePlaying;
|
||||
}
|
||||
|
||||
|
||||
public void endPlaying() {
|
||||
donePlaying = true;
|
||||
}
|
||||
|
||||
|
||||
public void startPlaying() {
|
||||
donePlaying = false;
|
||||
}
|
||||
|
||||
public MachineSound setVolume(float vol) {
|
||||
this.volume = vol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineSound setPitch(float pitch) {
|
||||
this.field_147663_c = pitch;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
@@ -19,8 +20,13 @@ import cofh.api.energy.EnergyStorage;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Queues;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.api.teleport.ITelePad;
|
||||
import crazypants.enderio.api.teleport.TravelSource;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.MachineSound;
|
||||
import crazypants.enderio.machine.PacketPowerStorage;
|
||||
import crazypants.enderio.machine.PacketProgress;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
@@ -53,6 +59,9 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
private int powerUsed;
|
||||
private int maxPower;
|
||||
private int lastSyncPowerUsed;
|
||||
|
||||
private static final ResourceLocation activeRes = AbstractMachineEntity.getSoundFor("telepad.active");
|
||||
private MachineSound activeSound = null;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
@@ -65,7 +74,22 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
updateConnectedState(true);
|
||||
autoUpdate = false;
|
||||
}
|
||||
if(!worldObj.isRemote) {
|
||||
if(worldObj.isRemote) {
|
||||
if(active()) {
|
||||
if(activeSound == null) {
|
||||
activeSound = new MachineSound(activeRes, xCoord, yCoord, zCoord, 0.01f, 1);
|
||||
playSound();
|
||||
}
|
||||
activeSound.setVolume(Math.min(activeSound.getVolume() + 0.01f, 0.5f));
|
||||
} else if(!active() && activeSound != null) {
|
||||
if(activeSound.getVolume() > 0) {
|
||||
activeSound.setVolume(activeSound.getVolume() - 0.1f);
|
||||
} else {
|
||||
activeSound.endPlaying();
|
||||
activeSound = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(active()) {
|
||||
System.out.println(maxPower);
|
||||
if(powerUsed >= maxPower) {
|
||||
@@ -92,6 +116,11 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void playSound() {
|
||||
FMLClientHandler.instance().getClient().getSoundHandler().playSound(activeSound);
|
||||
}
|
||||
|
||||
private void updateQueuedEntities() {
|
||||
List<Entity> toRemove = Lists.newArrayList();
|
||||
for (Entity e : toTeleport) {
|
||||
@@ -234,7 +263,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
}
|
||||
|
||||
private int getPowerForTeleport() {
|
||||
return new BlockCoord(this).distance(target) * 10;
|
||||
return new BlockCoord(this).distance(target) * 1000;
|
||||
}
|
||||
|
||||
public boolean active() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package crazypants.util;
|
||||
|
||||
import java.util.IllegalFormatException;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class Lang {
|
||||
@@ -14,7 +16,12 @@ public class Lang {
|
||||
if(appendEIO) {
|
||||
s = prefix + s;
|
||||
}
|
||||
return String.format(StatCollector.translateToLocal(s), (Object[]) args);
|
||||
String ret = StatCollector.translateToLocal(s);
|
||||
try {
|
||||
return String.format(ret, (Object[]) args);
|
||||
} catch (IllegalFormatException e) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] localizeList(String string) {
|
||||
|
||||
Reference in new issue
Block a user