diff --git a/src/main/scala/net/machinemuse/general/gui/clickable/ClickableKeybinding.java b/src/main/scala/net/machinemuse/general/gui/clickable/ClickableKeybinding.java index a6a1a1f..6122331 100644 --- a/src/main/scala/net/machinemuse/general/gui/clickable/ClickableKeybinding.java +++ b/src/main/scala/net/machinemuse/general/gui/clickable/ClickableKeybinding.java @@ -37,7 +37,7 @@ public class ClickableKeybinding extends ClickableButton { } public void doToggleTick() { - doToggleIf(keybind.pressed); + doToggleIf(keybind.getIsKeyPressed()); } public void doToggleIf(boolean value) { @@ -65,10 +65,10 @@ public class ClickableKeybinding extends ClickableButton { } public static String parseName(KeyBinding keybind) { - if (keybind.keyCode < 0) { - return "Mouse" + (keybind.keyCode + 100); + if (keybind.getKeyCode() < 0) { + return "Mouse" + (keybind.getKeyCode() + 100); } else { - return Keyboard.getKeyName(keybind.keyCode); + return Keyboard.getKeyName(keybind.getKeyCode()); } } @@ -132,7 +132,7 @@ public class ClickableKeybinding extends ClickableButton { } public boolean equals(ClickableKeybinding other) { - return other.keybind.keyCode == this.keybind.keyCode; + return other.keybind.getKeyCode() == this.keybind.getKeyCode(); } } diff --git a/src/main/scala/net/machinemuse/powersuits/block/BlockLuxCapacitor.java b/src/main/scala/net/machinemuse/powersuits/block/BlockLuxCapacitor.java index ec8e61c..cbc8638 100644 --- a/src/main/scala/net/machinemuse/powersuits/block/BlockLuxCapacitor.java +++ b/src/main/scala/net/machinemuse/powersuits/block/BlockLuxCapacitor.java @@ -27,7 +27,7 @@ public class BlockLuxCapacitor extends Block { } public BlockLuxCapacitor() { - super(assignedBlockID, Material.circuits); + super(Material.circuits); // Block's creative tab setCreativeTab(Config.getCreativeTab()); @@ -48,7 +48,7 @@ public class BlockLuxCapacitor extends Block { // Light level, 0-1. Gets multiplied by 15 and truncated to find the // actual light level for the block. - setLightValue(1.0f); + setLightLevel(1.0f); // Whether to receive random ticks e.g. plants setTickRandomly(false); diff --git a/src/main/scala/net/machinemuse/powersuits/client/ClientProxy.java b/src/main/scala/net/machinemuse/powersuits/client/ClientProxy.java index 324c237..ce4f569 100644 --- a/src/main/scala/net/machinemuse/powersuits/client/ClientProxy.java +++ b/src/main/scala/net/machinemuse/powersuits/client/ClientProxy.java @@ -1,11 +1,8 @@ package net.machinemuse.powersuits.client; import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.common.registry.TickRegistry; -import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.common.FMLCommonHandler; import net.machinemuse.general.sound.SoundLoader; import net.machinemuse.numina.general.MuseLogger; import net.machinemuse.numina.network.MusePacket; @@ -30,10 +27,9 @@ import net.machinemuse.powersuits.control.KeybindManager; import net.machinemuse.powersuits.entity.EntityLuxCapacitor; import net.machinemuse.powersuits.entity.EntityPlasmaBolt; import net.machinemuse.powersuits.entity.EntitySpinningBlade; +import net.machinemuse.powersuits.event.PlayerUpdateHandler; import net.machinemuse.powersuits.event.RenderEventHandler; import net.machinemuse.powersuits.tick.ClientTickHandler; -import net.machinemuse.powersuits.tick.PlayerTickHandler; -import net.machinemuse.powersuits.tick.RenderTickHandler; import net.machinemuse.utils.render.MuseShaders; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; @@ -50,9 +46,6 @@ import java.net.URL; */ public class ClientProxy extends CommonProxy { private static ToolRenderer toolRenderer; - private static ClientTickHandler clientTickHandler; - private static RenderTickHandler renderTickHandler; - private static PlayerTickHandler playerTickHandler; public static KeybindKeyHandler keybindHandler; @Override @@ -115,20 +108,17 @@ public class ClientProxy extends CommonProxy { public void registerHandlers() { super.registerHandlers(); keybindHandler = new KeybindKeyHandler(); - KeyBindingRegistry.registerKeyBinding(keybindHandler); + FMLCommonHandler.instance().bus().register(keybindHandler); - playerTickHandler = new PlayerTickHandler(); + PlayerUpdateHandler playerTickHandler = new PlayerUpdateHandler(); MinecraftForge.EVENT_BUS.register(playerTickHandler); // TickRegistry.registerTickHandler(playerTickHandler, Side.SERVER); - renderTickHandler = new RenderTickHandler(); - TickRegistry.registerTickHandler(renderTickHandler, Side.CLIENT); - - clientTickHandler = new ClientTickHandler(); - TickRegistry.registerTickHandler(clientTickHandler, Side.CLIENT); + ClientTickHandler clientTickHandler = new ClientTickHandler(); + FMLCommonHandler.instance().bus().register(clientTickHandler); - packetHandler = new MusePacketHandler(); + packetHandler = MusePacketHandler; } @Override diff --git a/src/main/scala/net/machinemuse/powersuits/common/CommonProxy.java b/src/main/scala/net/machinemuse/powersuits/common/CommonProxy.java index 0f80dad..e381b7e 100644 --- a/src/main/scala/net/machinemuse/powersuits/common/CommonProxy.java +++ b/src/main/scala/net/machinemuse/powersuits/common/CommonProxy.java @@ -19,9 +19,6 @@ public class CommonProxy { public static String ITEMS_PNG = "/tutorial/generic/items.png"; public static String BLOCK_PNG = "/tutorial/generic/block.png"; - public static MusePacketHandler packetHandler; - public static PlayerTickHandler playerTickHandler; - public void registerEvents() { } diff --git a/src/main/scala/net/machinemuse/powersuits/control/KeybindKeyHandler.java b/src/main/scala/net/machinemuse/powersuits/control/KeybindKeyHandler.java index a42ecc6..30c75f8 100644 --- a/src/main/scala/net/machinemuse/powersuits/control/KeybindKeyHandler.java +++ b/src/main/scala/net/machinemuse/powersuits/control/KeybindKeyHandler.java @@ -1,7 +1,9 @@ package net.machinemuse.powersuits.control; -import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; +import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.TickType; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.machinemuse.powersuits.common.ModularPowersuits; @@ -15,73 +17,61 @@ import org.lwjgl.input.Keyboard; import java.util.EnumSet; @SideOnly(Side.CLIENT) -public class KeybindKeyHandler extends KeyHandler { - public static KeyBinding openKeybindGUI = new KeyBinding("Open MPS Keybind GUI", -1); - public static KeyBinding goDownKey = new KeyBinding("Go Down (MPS Flight Control)", Keyboard.KEY_Z); - public static KeyBinding cycleToolBackward = new KeyBinding("Cycle Tool Backward (MPS)", -1); - public static KeyBinding cycleToolForward = new KeyBinding("Cycle Tool Forward (MPS)", -1); - public static KeyBinding zoom = new KeyBinding("Zoom (MPS)", Keyboard.KEY_Y); - public static KeyBinding openCosmeticGUI = new KeyBinding("Cosmetic (MPS)", -1); +public class KeybindKeyHandler { + static String mps = "Modular Powersuits"; + public static KeyBinding openKeybindGUI = new KeyBinding("Open MPS Keybind GUI", -1, mps); + public static KeyBinding goDownKey = new KeyBinding("Go Down (MPS Flight Control)", Keyboard.KEY_Z, mps); + public static KeyBinding cycleToolBackward = new KeyBinding("Cycle Tool Backward (MPS)", -1, mps); + public static KeyBinding cycleToolForward = new KeyBinding("Cycle Tool Forward (MPS)", -1, mps); + public static KeyBinding zoom = new KeyBinding("Zoom (MPS)", Keyboard.KEY_Y, mps); + public static KeyBinding openCosmeticGUI = new KeyBinding("Cosmetic (MPS)", -1, mps); public static KeyBinding[] keybindArray = new KeyBinding[]{openKeybindGUI, goDownKey, cycleToolBackward, cycleToolForward, zoom, openCosmeticGUI}; public static boolean[] repeats = new boolean[keybindArray.length]; public KeybindKeyHandler() { - super(keybindArray, repeats); + for (KeyBinding key : keybindArray) { + ClientRegistry.registerKeyBinding(key); + } } - @Override - public String getLabel() { - return "machineMuseKeybinds"; - } - - @Override - public void keyDown(EnumSet types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { + @SubscribeEvent + public void onKeyInput(InputEvent.KeyInputEvent e) { + int key = Keyboard.getEventKey(); + boolean pressed = Keyboard.getEventKeyState(); EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - // Only activate if there is a player to work with and it is the start - // tick - if (player == null || tickEnd) { + // Only activate if there is a player to work with + if (player == null) { return; } - if (kb.equals(openKeybindGUI)) { - World world = Minecraft.getMinecraft().theWorld; - if (Minecraft.getMinecraft().inGameHasFocus) { - player.openGui(ModularPowersuits.INSTANCE, 1, world, 0, 0, 0); + if(pressed) { + if (key == openKeybindGUI.getKeyCode()) { + World world = Minecraft.getMinecraft().theWorld; + if (Minecraft.getMinecraft().inGameHasFocus) { + player.openGui(ModularPowersuits.INSTANCE, 1, world, 0, 0, 0); + } + } + if (key == openCosmeticGUI.getKeyCode()) { + World world = Minecraft.getMinecraft().theWorld; + if (Minecraft.getMinecraft().inGameHasFocus) { + player.openGui(ModularPowersuits.INSTANCE, 3, world, 0, 0, 0); + } + } + if (key == goDownKey.getKeyCode()) { + PlayerInputMap.getInputMapFor(player.getCommandSenderName()).downKey = true; + } + if (key == cycleToolBackward.getKeyCode()) { + Minecraft.getMinecraft().playerController.updateController(); + ModeChangingModularItem$.MODULE$.cycleModeForItem(player.inventory.getStackInSlot(player.inventory.currentItem), player, 1); + } + if (key == cycleToolForward.getKeyCode()) { + Minecraft.getMinecraft().playerController.updateController(); + ModeChangingModularItem$.MODULE$.cycleModeForItem(player.inventory.getStackInSlot(player.inventory.currentItem), player, -1); + } + } else { + if (Minecraft.getMinecraft().thePlayer != null && key == goDownKey.getKeyCode()) { + PlayerInputMap.getInputMapFor(Minecraft.getMinecraft().thePlayer.getCommandSenderName()).downKey = false; } } - if (kb.equals(openCosmeticGUI)) { - World world = Minecraft.getMinecraft().theWorld; - if (Minecraft.getMinecraft().inGameHasFocus) { - player.openGui(ModularPowersuits.INSTANCE, 3, world, 0, 0, 0); - } - } - if (kb.equals(goDownKey)) { - PlayerInputMap.getInputMapFor(player.username).downKey = true; - } - if (kb.equals(cycleToolBackward)) { - Minecraft.getMinecraft().playerController.updateController(); - ModeChangingModularItem$.MODULE$.cycleModeForItem(player.inventory.getStackInSlot(player.inventory.currentItem), player, 1); - } - if (kb.equals(cycleToolForward)) { - Minecraft.getMinecraft().playerController.updateController(); - ModeChangingModularItem$.MODULE$.cycleModeForItem(player.inventory.getStackInSlot(player.inventory.currentItem), player, -1); - } - } - - @Override - public void keyUp(EnumSet types, KeyBinding kb, boolean tickEnd) { - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - if (Minecraft.getMinecraft().thePlayer != null && kb.equals(goDownKey)) { - PlayerInputMap.getInputMapFor(Minecraft.getMinecraft().thePlayer.username).downKey = false; - } - } - - public void addKeybind(KeyBinding kb) { - - } - - @Override - public EnumSet ticks() { - return EnumSet.of(TickType.CLIENT); } } diff --git a/src/main/scala/net/machinemuse/powersuits/event/MovementManager.java b/src/main/scala/net/machinemuse/powersuits/event/MovementManager.java index 8c07249..6ea03a3 100644 --- a/src/main/scala/net/machinemuse/powersuits/event/MovementManager.java +++ b/src/main/scala/net/machinemuse/powersuits/event/MovementManager.java @@ -2,8 +2,6 @@ package net.machinemuse.powersuits.event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.machinemuse.api.ModuleManager; -import net.machinemuse.general.sound.SoundLoader; -import net.machinemuse.numina.sound.Musique; import net.machinemuse.powersuits.item.ItemPowerArmor; import net.machinemuse.powersuits.powermodule.movement.JumpAssistModule; import net.machinemuse.powersuits.powermodule.movement.ShockAbsorberModule; @@ -42,7 +40,7 @@ public class MovementManager { double jumpAssist = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_MULTIPLIER) * 2; double drain = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_ENERGY_CONSUMPTION); double avail = ElectricItemUtils.getPlayerEnergy(player); - Musique.playerSound(player, SoundLoader.SOUND_JUMP_ASSIST, (float) (jumpAssist / 8.0), 2, false); +// Musique.playerSound(player, SoundLoader.SOUND_JUMP_ASSIST, (float) (jumpAssist / 8.0), 2, false); if (drain < avail) { ElectricItemUtils.drainPlayerEnergy(player, drain); setPlayerJumpTicks(player, jumpAssist); @@ -67,7 +65,7 @@ public class MovementManager { if (boots != null) { if (ModuleManager.itemHasActiveModule(boots, ShockAbsorberModule.MODULE_SHOCK_ABSORBER) && event.distance > 3) { double distanceAbsorb = event.distance * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_MULTIPLIER); - Musique.playerSound(player, SoundLoader.SOUND_GUI_INSTALL, (float) (distanceAbsorb), 2, false); +// Musique.playerSound(player, SoundLoader.SOUND_GUI_INSTALL, (float) (distanceAbsorb), 2, false); double drain = distanceAbsorb * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_ENERGY_CONSUMPTION); double avail = ElectricItemUtils.getPlayerEnergy(player); diff --git a/src/main/scala/net/machinemuse/powersuits/event/PlayerUpdateHandler.scala b/src/main/scala/net/machinemuse/powersuits/event/PlayerUpdateHandler.scala index 967b4c7..92eac24 100644 --- a/src/main/scala/net/machinemuse/powersuits/event/PlayerUpdateHandler.scala +++ b/src/main/scala/net/machinemuse/powersuits/event/PlayerUpdateHandler.scala @@ -11,7 +11,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent /** * Created by Claire Semple on 9/8/2014. */ -object PlayerUpdateHandler { +class PlayerUpdateHandler { @SubscribeEvent def onPlayerUpdate(e: LivingUpdateEvent) = { val player = OptionCast[EntityPlayer](e.entity).map { player => diff --git a/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetBootsModule.java b/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetBootsModule.java index 241a723..d1c545e 100644 --- a/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetBootsModule.java +++ b/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetBootsModule.java @@ -4,8 +4,6 @@ import net.machinemuse.api.IModularItem; import net.machinemuse.api.ModuleManager; import net.machinemuse.api.moduletrigger.IPlayerTickModule; import net.machinemuse.api.moduletrigger.IToggleableModule; -import net.machinemuse.numina.sound.Musique; -import net.machinemuse.general.sound.SoundLoader; import net.machinemuse.powersuits.control.PlayerInputMap; import net.machinemuse.powersuits.item.ItemComponent; import net.machinemuse.powersuits.powermodule.PowerModuleBase; @@ -59,7 +57,7 @@ public class JetBootsModule extends PowerModuleBase implements IToggleableModule if (player.isInWater()) { return; } - PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username); + PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.getCommandSenderName()); boolean jumpkey = movementInput.jumpKey; ItemStack helmet = player.getCurrentArmor(3); boolean hasFlightControl = ModuleManager.itemHasActiveModule(helmet, FlightControlModule.MODULE_FLIGHT_CONTROL); @@ -70,23 +68,23 @@ public class JetBootsModule extends PowerModuleBase implements IToggleableModule thrust *= MusePlayerUtils.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000); if (hasFlightControl && thrust > 0) { thrust = MusePlayerUtils.thrust(player, thrust, true); - Musique.playerSound(player, SoundLoader.SOUND_JETBOOTS, (float) (thrust*12.5), 1.0f, true); +// Musique.playerSound(player, SoundLoader.SOUND_JETBOOTS, (float) (thrust*12.5), 1.0f, true); ElectricItemUtils.drainPlayerEnergy(player, thrust * jetEnergy); } else if (jumpkey && player.motionY < 0.5) { thrust = MusePlayerUtils.thrust(player, thrust, false); - Musique.playerSound(player, SoundLoader.SOUND_JETBOOTS,(float) (thrust*12.5), 1.0f, true); +// Musique.playerSound(player, SoundLoader.SOUND_JETBOOTS,(float) (thrust*12.5), 1.0f, true); ElectricItemUtils.drainPlayerEnergy(player, thrust * jetEnergy); } else { - Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS); } } else { - Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS); } } @Override public void onPlayerTickInactive(EntityPlayer player, ItemStack item) { - Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS); } @Override diff --git a/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetPackModule.java b/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetPackModule.java index 8fc1cd8..ae2dc77 100644 --- a/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetPackModule.java +++ b/src/main/scala/net/machinemuse/powersuits/powermodule/movement/JetPackModule.java @@ -4,8 +4,6 @@ import net.machinemuse.api.IModularItem; import net.machinemuse.api.ModuleManager; import net.machinemuse.api.moduletrigger.IPlayerTickModule; import net.machinemuse.api.moduletrigger.IToggleableModule; -import net.machinemuse.numina.sound.Musique; -import net.machinemuse.general.sound.SoundLoader; import net.machinemuse.powersuits.control.PlayerInputMap; import net.machinemuse.powersuits.item.ItemComponent; import net.machinemuse.powersuits.powermodule.PowerModuleBase; @@ -58,7 +56,7 @@ public class JetPackModule extends PowerModuleBase implements IToggleableModule, if (player.isInWater()) { return; } - PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username); + PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.getCommandSenderName()); boolean jumpkey = movementInput.jumpKey; ItemStack helmet = player.getCurrentArmor(3); boolean hasFlightControl = helmet != null && helmet.getItem() instanceof IModularItem @@ -88,7 +86,7 @@ public class JetPackModule extends PowerModuleBase implements IToggleableModule, @Override public void onPlayerTickInactive(EntityPlayer player, ItemStack item) { - Musique.stopPlayerSound(player, SoundLoader.SOUND_JETPACK); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_JETPACK); } @Override diff --git a/src/main/scala/net/machinemuse/powersuits/powermodule/movement/SwimAssistModule.java b/src/main/scala/net/machinemuse/powersuits/powermodule/movement/SwimAssistModule.java index 3eaa92d..87b49a1 100644 --- a/src/main/scala/net/machinemuse/powersuits/powermodule/movement/SwimAssistModule.java +++ b/src/main/scala/net/machinemuse/powersuits/powermodule/movement/SwimAssistModule.java @@ -4,8 +4,6 @@ import net.machinemuse.api.IModularItem; import net.machinemuse.api.ModuleManager; import net.machinemuse.api.moduletrigger.IPlayerTickModule; import net.machinemuse.api.moduletrigger.IToggleableModule; -import net.machinemuse.numina.sound.Musique; -import net.machinemuse.general.sound.SoundLoader; import net.machinemuse.powersuits.control.PlayerInputMap; import net.machinemuse.powersuits.item.ItemComponent; import net.machinemuse.powersuits.powermodule.PowerModuleBase; @@ -55,7 +53,7 @@ public class SwimAssistModule extends PowerModuleBase implements IToggleableModu @Override public void onPlayerTickActive(EntityPlayer player, ItemStack item) { if (player.isInWater() && !(player.isRiding())) { - PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username); + PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.getCommandSenderName()); boolean jumpkey = movementInput.jumpKey; boolean sneakkey = movementInput.sneakKey; float forwardkey = movementInput.forwardKey; @@ -74,22 +72,22 @@ public class SwimAssistModule extends PowerModuleBase implements IToggleableModu double swimAssistRate = ModuleManager.computeModularProperty(item, SWIM_BOOST_AMOUNT) * 0.05; double swimEnergyConsumption = ModuleManager.computeModularProperty(item, SWIM_BOOST_ENERGY_CONSUMPTION); if (swimEnergyConsumption < ElectricItemUtils.getPlayerEnergy(player)) { - Musique.playerSound(player, SoundLoader.SOUND_SWIMASSIST, 1.0f, 1.0f, true); +// Musique.playerSound(player, SoundLoader.SOUND_SWIMASSIST, 1.0f, 1.0f, true); MusePlayerUtils.thrust(player, swimAssistRate, true); } else { - Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); } } else { - Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); } } else { - Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); } } @Override public void onPlayerTickInactive(EntityPlayer player, ItemStack item) { - Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); +// Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST); } @Override diff --git a/src/main/scala/net/machinemuse/powersuits/powermodule/tool/AxeModule.java b/src/main/scala/net/machinemuse/powersuits/powermodule/tool/AxeModule.java index 60a39c9..b9af3ad 100644 --- a/src/main/scala/net/machinemuse/powersuits/powermodule/tool/AxeModule.java +++ b/src/main/scala/net/machinemuse/powersuits/powermodule/tool/AxeModule.java @@ -11,6 +11,7 @@ import net.machinemuse.utils.MuseCommonStrings; import net.machinemuse.utils.MuseItemUtils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; @@ -22,14 +23,13 @@ import java.util.List; public class AxeModule extends PowerModuleBase implements IBlockBreakingModule, IToggleableModule { public static final String MODULE_AXE = "Axe"; - public static final ItemStack ironAxe = new ItemStack(Item.axeIron); + public static final ItemStack ironAxe = new ItemStack(Items.iron_axe); public static final String AXE_ENERGY_CONSUMPTION = "Axe Energy Consumption"; public static final String AXE_HARVEST_SPEED = "Axe Harvest Speed"; public static final String AXE_SEARCH_RADIUS = "Axe Search Radius"; public AxeModule(List validItems) { super(validItems); - addInstallCost(new ItemStack(Item.ingotIron, 3)); addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.solenoid, 1)); addBaseProperty(AXE_ENERGY_CONSUMPTION, 50, "J"); addBaseProperty(AXE_HARVEST_SPEED, 8, "x"); diff --git a/src/main/scala/net/machinemuse/powersuits/powermodule/tool/HoeModule.java b/src/main/scala/net/machinemuse/powersuits/powermodule/tool/HoeModule.java index 804620a..309341b 100644 --- a/src/main/scala/net/machinemuse/powersuits/powermodule/tool/HoeModule.java +++ b/src/main/scala/net/machinemuse/powersuits/powermodule/tool/HoeModule.java @@ -1,5 +1,6 @@ package net.machinemuse.powersuits.powermodule.tool; +import cpw.mods.fml.common.eventhandler.Event; import net.machinemuse.api.IModularItem; import net.machinemuse.api.IPowerModule; import net.machinemuse.api.ModuleManager; @@ -11,13 +12,13 @@ import net.machinemuse.utils.MuseCommonStrings; import net.machinemuse.utils.MuseItemUtils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Event.Result; import net.minecraftforge.event.entity.player.UseHoeEvent; import java.util.List; @@ -29,7 +30,6 @@ public class HoeModule extends PowerModuleBase implements IPowerModule, IRightCl public HoeModule(List validItems) { super(validItems); - addInstallCost(new ItemStack(Item.ingotIron, 2)); addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.solenoid, 1)); addBaseProperty(HOE_ENERGY_CONSUMPTION, 50); @@ -50,7 +50,7 @@ public class HoeModule extends PowerModuleBase implements IPowerModule, IRightCl return; } - if (event.getResult() == Result.ALLOW) { + if (event.getResult() == Event.Result.ALLOW) { ElectricItemUtils.drainPlayerEnergy(player, energyConsumed); return; } @@ -62,17 +62,17 @@ public class HoeModule extends PowerModuleBase implements IPowerModule, IRightCl for (int i = (int) Math.floor(-radius); i < radius; i++) { for (int j = (int) Math.floor(-radius); j < radius; j++) { if (i * i + j * j < radius * radius) { - int id = world.getBlockId(x + i, y, z + j); - if (id == Block.grass.blockID || id == Block.dirt.blockID) { - world.setBlock(x + i, y, z + j, Block.tilledField.blockID); + Block block = world.getBlock(x + i, y, z + j); + if (block == Blocks.grass || block == Blocks.dirt) { + world.setBlock(x + i, y, z + j, Blocks.farmland); ElectricItemUtils.drainPlayerEnergy(player, ModuleManager.computeModularProperty(itemStack, HOE_ENERGY_CONSUMPTION)); } } } } - world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), - Block.tilledField.stepSound.getStepSound(), (Block.tilledField.stepSound.getVolume() + 1.0F) / 2.0F, - Block.tilledField.stepSound.getPitch() * 0.8F); +// Musique world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), +// Blocks.farmland.stepSound.getStepSound(), (Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F, +// Blocks.farmland.stepSound.getPitch() * 0.8F); } } diff --git a/src/main/scala/net/machinemuse/powersuits/tick/ClientTickHandler.java b/src/main/scala/net/machinemuse/powersuits/tick/ClientTickHandler.java deleted file mode 100644 index 70beff1..0000000 --- a/src/main/scala/net/machinemuse/powersuits/tick/ClientTickHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.machinemuse.powersuits.tick; - -import cpw.mods.fml.common.ITickHandler; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.common.network.Player; -import net.machinemuse.general.gui.clickable.ClickableKeybinding; -import net.machinemuse.numina.network.MusePacket; -import net.machinemuse.numina.network.PacketSender; -import net.machinemuse.powersuits.control.KeybindManager; -import net.machinemuse.powersuits.control.PlayerInputMap; -import net.machinemuse.powersuits.network.packets.MusePacketPlayerUpdate; -import net.machinemuse.utils.MuseItemUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; - -import java.util.EnumSet; - -/** - * This handler is called before/after the game processes input events and - * updates the gui state mainly. *independent of rendering, so don't do rendering here - * -is also the parent class of KeyBindingHandler - * - * @author MachineMuse - */ -public class ClientTickHandler implements ITickHandler { - @Override - public void tickStart(EnumSet type, Object... tickData) { - for (ClickableKeybinding kb : KeybindManager.getKeybindings()) { - kb.doToggleTick(); - } - } - - @Override - public void tickEnd(EnumSet type, Object... tickData) { - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - if (player != null && MuseItemUtils.getModularItemsInInventory(player).size() > 0) { - PlayerInputMap inputmap = PlayerInputMap.getInputMapFor(player.username); - inputmap.forwardKey = Math.signum(player.movementInput.moveForward); - inputmap.strafeKey = Math.signum(player.movementInput.moveStrafe); - inputmap.jumpKey = player.movementInput.jump; - inputmap.sneakKey = player.movementInput.sneak; - inputmap.motionX = player.motionX; - inputmap.motionY = player.motionY; - inputmap.motionZ = player.motionZ; - - if (inputmap.hasChanged()) { - inputmap.refresh(); - MusePacket inputPacket = new MusePacketPlayerUpdate(player, inputmap); - PacketSender.sendToServer(inputPacket.getPacket131()); - } - } - } - - @Override - public EnumSet ticks() { - return EnumSet.of(TickType.CLIENT); - } - - @Override - public String getLabel() { - return "MMMPS: Client Tick"; - } - -} diff --git a/src/main/scala/net/machinemuse/powersuits/tick/ClientTickHandler.scala b/src/main/scala/net/machinemuse/powersuits/tick/ClientTickHandler.scala new file mode 100644 index 0000000..07cea7c --- /dev/null +++ b/src/main/scala/net/machinemuse/powersuits/tick/ClientTickHandler.scala @@ -0,0 +1,46 @@ +package net.machinemuse.powersuits.tick + +import cpw.mods.fml.common.eventhandler.SubscribeEvent +import cpw.mods.fml.common.gameevent.TickEvent +import net.machinemuse.numina.network.{MusePacket, PacketSender} +import net.machinemuse.powersuits.control.{KeybindManager, PlayerInputMap} +import net.machinemuse.powersuits.network.packets.MusePacketPlayerUpdate +import net.machinemuse.utils.MuseItemUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityClientPlayerMP + +/** + * This handler is called before/after the game processes input events and + * updates the gui state mainly. *independent of rendering, so don't do rendering here + * -is also the parent class of KeyBindingHandler + * + * @author MachineMuse + */ +class ClientTickHandler { + @SubscribeEvent def onPreClientTick(event: TickEvent.ClientTickEvent) { + if (event.phase == TickEvent.Phase.START) { + import scala.collection.JavaConversions._ + for (kb <- KeybindManager.getKeybindings) { + kb.doToggleTick() + } + } + else { + val player: EntityClientPlayerMP = Minecraft.getMinecraft.thePlayer + if (player != null && MuseItemUtils.getModularItemsInInventory(player).size > 0) { + val inputmap: PlayerInputMap = PlayerInputMap.getInputMapFor(player.getCommandSenderName) + inputmap.forwardKey = Math.signum(player.movementInput.moveForward) + inputmap.strafeKey = Math.signum(player.movementInput.moveStrafe) + inputmap.jumpKey = player.movementInput.jump + inputmap.sneakKey = player.movementInput.sneak + inputmap.motionX = player.motionX + inputmap.motionY = player.motionY + inputmap.motionZ = player.motionZ + if (inputmap.hasChanged) { + inputmap.refresh() + val inputPacket: MusePacket = new MusePacketPlayerUpdate(player, inputmap) + PacketSender.sendToServer(inputPacket.getPacket131) + } + } + } + } +} \ No newline at end of file