mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-21 20:42:14 +00:00
Chainsaws now can shear ( Closes #23 ), fixed chainsaws sounds.
This commit is contained in:
1 parent
381896031b
commit
f2fb61feb0
8 files changed
+161
-105
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package emt.util;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import emt.ElectroMagicTools;
|
||||
import emt.client.EMTKeys;
|
||||
import emt.init.EMTItems;
|
||||
import emt.network.PacketEMTKeys;
|
||||
import ic2.api.item.IC2Items;
|
||||
import ic2.core.IC2;
|
||||
import ic2.core.Ic2Items;
|
||||
import ic2.core.audio.AudioSource;
|
||||
import ic2.core.audio.PositionSpec;
|
||||
import ic2.core.item.tool.ItemElectricToolChainsaw;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class EMTClientEventHandler {
|
||||
public AudioSource audio;
|
||||
public Item lastItem;
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientTick(ClientTickEvent e) {
|
||||
if (EMTKeys.keyUnequip.getIsKeyPressed()) {
|
||||
ElectroMagicTools.INSTANCE.sendToServer(new PacketEMTKeys());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerTick(TickEvent.PlayerTickEvent e) {
|
||||
if (e.side == Side.CLIENT) {
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
Item curItem = player.inventory.getCurrentItem() == null ? null : player.inventory.getCurrentItem().getItem();
|
||||
|
||||
if (curItem == EMTItems.diamondChainsaw || curItem == EMTItems.streamChainsaw || curItem == EMTItems.thaumiumChainsaw) {
|
||||
if (audio == null)
|
||||
audio = IC2.audioManager.createSource(player, PositionSpec.Hand, "Tools/Chainsaw/ChainsawIdle.ogg", true, false, IC2.audioManager.getDefaultVolume());
|
||||
if (audio != null) {
|
||||
audio.updatePosition();
|
||||
audio.play();
|
||||
}
|
||||
}
|
||||
|
||||
if (audio != null && curItem != lastItem) {
|
||||
audio.stop();
|
||||
audio.remove();
|
||||
audio = null;
|
||||
IC2.audioManager.playOnce(player, PositionSpec.Hand, "Tools/Chainsaw/ChainsawStop.ogg", true, IC2.audioManager.getDefaultVolume());
|
||||
}
|
||||
|
||||
if (audio != null && curItem != lastItem) {
|
||||
audio.stop();
|
||||
audio.remove();
|
||||
audio = null;
|
||||
IC2.audioManager.playOnce(player, PositionSpec.Hand, "Tools/Chainsaw/ChainsawStop.ogg", true, IC2.audioManager.getDefaultVolume());
|
||||
}
|
||||
|
||||
lastItem = curItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user