Working keybinding listener, and first stab at the ObjectHolder (some more learning necessary it seems, so commented out at the moment)

This commit is contained in:
pahimar 2014-05-25 09:55:50 -05:00
parent 06dced01b3
commit 7bd8adf478
18 changed files with 58 additions and 66 deletions

View file

@ -22,7 +22,7 @@ group = "com.pahimar.ee3" // http://maven.apache.org/guides/mini/guide-naming-co
archivesBaseName = "EquivalentExchange3"
minecraft {
version = "1.7.2-10.12.1.1084"
version = "1.7.2-10.12.1.1091"
assetDir = "run/assets"
}

View file

@ -22,7 +22,7 @@ public class BlockAlchemicalFuel extends BlockEE
public BlockAlchemicalFuel()
{
super();
this.setBlockName(Names.Items.ALCHEMICAL_FUEL);
this.setBlockName(Names.Blocks.ALCHEMICAL_FUEL);
this.setHardness(5.0f);
this.setResistance(10.0f);
}

View file

@ -55,7 +55,7 @@ public class KeyInputEventHandler
{
if (entityPlayer.worldObj.isRemote)
{
PacketHandler.INSTANCE.sendToServer(new MessageKeyPressed(Key.CHARGE)); // TODO Pass in the proper key pressed, but need to confirm FML SimpleNetworkWrapper fix first
PacketHandler.INSTANCE.sendToServer(new MessageKeyPressed(getPressedKeybinding()));
}
else
{

View file

@ -12,7 +12,7 @@ import java.io.File;
public class ClientConfiguration
{
public static final String CATEGORY_KEYBIND = "keybindings";
private static final String CATEGORY_KEYBIND = "keybindings";
private static Configuration configuration;
protected static void init(File configFile)
@ -26,10 +26,10 @@ public class ClientConfiguration
/* KeyBindings */
configuration.addCustomCategoryComment(CATEGORY_KEYBIND, "Keybindings for Equivalent Exchange 3. See http://www.minecraftwiki.net/wiki/Key_codes for mapping of key codes to keyboard keys");
Keybindings.charge = new KeyBinding(Names.Keys.CHARGE, configuration.get(CATEGORY_KEYBIND, Names.Keys.CHARGE, Keyboard.KEY_V).getInt(Keyboard.KEY_V), "Equivalent Exchange 3");
Keybindings.extra = new KeyBinding(Names.Keys.EXTRA, configuration.get(CATEGORY_KEYBIND, Names.Keys.EXTRA, Keyboard.KEY_C).getInt(Keyboard.KEY_C), "Equivalent Exchange 3");
Keybindings.release = new KeyBinding(Names.Keys.RELEASE, configuration.get(CATEGORY_KEYBIND, Names.Keys.RELEASE, Keyboard.KEY_R).getInt(Keyboard.KEY_R), "Equivalent Exchange 3");
Keybindings.toggle = new KeyBinding(Names.Keys.TOGGLE, configuration.get(CATEGORY_KEYBIND, Names.Keys.TOGGLE, Keyboard.KEY_G).getInt(Keyboard.KEY_G), "Equivalent Exchange 3");
Keybindings.charge = new KeyBinding(Names.Keys.CHARGE, configuration.get(CATEGORY_KEYBIND, Names.Keys.CHARGE, Keyboard.KEY_V).getInt(Keyboard.KEY_V), Names.Keys.CATEGORY);
Keybindings.extra = new KeyBinding(Names.Keys.EXTRA, configuration.get(CATEGORY_KEYBIND, Names.Keys.EXTRA, Keyboard.KEY_C).getInt(Keyboard.KEY_C), Names.Keys.CATEGORY);
Keybindings.release = new KeyBinding(Names.Keys.RELEASE, configuration.get(CATEGORY_KEYBIND, Names.Keys.RELEASE, Keyboard.KEY_R).getInt(Keyboard.KEY_R), Names.Keys.CATEGORY);
Keybindings.toggle = new KeyBinding(Names.Keys.TOGGLE, configuration.get(CATEGORY_KEYBIND, Names.Keys.TOGGLE, Keyboard.KEY_G).getInt(Keyboard.KEY_G), Names.Keys.CATEGORY);
}
catch (Exception e)
{

View file

@ -6,6 +6,7 @@ import com.pahimar.ee3.item.ItemBlockAlchemicalFuel;
import com.pahimar.ee3.reference.Names;
import cpw.mods.fml.common.registry.GameRegistry;
//@GameRegistry.ObjectHolder(Reference.MOD_ID)
public class ModBlocks
{
public static final BlockEE chalk = new BlockChalk();
@ -18,12 +19,12 @@ public class ModBlocks
public static void init()
{
GameRegistry.registerBlock(chalk, "tile." + Names.Items.CHALK);
GameRegistry.registerBlock(alchemicalFuel, ItemBlockAlchemicalFuel.class, "tile." + Names.Items.ALCHEMICAL_FUEL);
GameRegistry.registerBlock(alchemicalChest, ItemBlockAlchemicalChest.class, "tile." + Names.Blocks.ALCHEMICAL_CHEST);
GameRegistry.registerBlock(aludel, "tile." + Names.Blocks.ALUDEL);
GameRegistry.registerBlock(calcinator, "tile." + Names.Blocks.CALCINATOR);
GameRegistry.registerBlock(glassBell, "tile." + Names.Blocks.GLASS_BELL);
GameRegistry.registerBlock(researchStation, "tile." + Names.Blocks.RESEARCH_STATION);
GameRegistry.registerBlock(chalk, Names.Blocks.CHALK);
GameRegistry.registerBlock(alchemicalFuel, ItemBlockAlchemicalFuel.class, Names.Blocks.ALCHEMICAL_FUEL);
GameRegistry.registerBlock(alchemicalChest, ItemBlockAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST);
GameRegistry.registerBlock(aludel, Names.Blocks.ALUDEL);
GameRegistry.registerBlock(calcinator, Names.Blocks.CALCINATOR);
GameRegistry.registerBlock(glassBell, Names.Blocks.GLASS_BELL);
GameRegistry.registerBlock(researchStation, Names.Blocks.RESEARCH_STATION);
}
}

View file

@ -4,6 +4,7 @@ import com.pahimar.ee3.item.*;
import com.pahimar.ee3.reference.Names;
import cpw.mods.fml.common.registry.GameRegistry;
//@GameRegistry.ObjectHolder(Reference.MOD_ID)
public class ModItems
{
public static final ItemEE alchemicalBag = new ItemAlchemicalBag();
@ -19,15 +20,15 @@ public class ModItems
public static void init()
{
GameRegistry.registerItem(alchemicalBag, "item." + Names.Items.ALCHEMICAL_BAG);
GameRegistry.registerItem(alchemicalDust, "item." + Names.Items.ALCHEMICAL_DUST);
GameRegistry.registerItem(alchemicalFuel, "item." + Names.Items.ALCHEMICAL_FUEL);
GameRegistry.registerItem(inertStone, "item." + Names.Items.INERT_STONE);
GameRegistry.registerItem(miniumShard, "item." + Names.Items.MINIUM_SHARD);
GameRegistry.registerItem(miniumStone, "item." + Names.Items.MINIUM_STONE);
GameRegistry.registerItem(philosophersStone, "item." + Names.Items.PHILOSOPHERS_STONE);
GameRegistry.registerItem(chalk, "item." + Names.Items.CHALK);
GameRegistry.registerItem(alchemicalInventoryUpgrade, "item." + Names.Items.ALCHEMICAL_UPGRADE);
GameRegistry.registerItem(diviningRod, "item." + Names.Items.DIVINING_ROD);
GameRegistry.registerItem(alchemicalBag, Names.Items.ALCHEMICAL_BAG);
GameRegistry.registerItem(alchemicalDust, Names.Items.ALCHEMICAL_DUST);
GameRegistry.registerItem(alchemicalFuel, Names.Items.ALCHEMICAL_FUEL);
GameRegistry.registerItem(inertStone, Names.Items.INERT_STONE);
GameRegistry.registerItem(miniumShard, Names.Items.MINIUM_SHARD);
GameRegistry.registerItem(miniumStone, Names.Items.MINIUM_STONE);
GameRegistry.registerItem(philosophersStone, Names.Items.PHILOSOPHERS_STONE);
GameRegistry.registerItem(chalk, Names.Items.CHALK);
GameRegistry.registerItem(alchemicalInventoryUpgrade, Names.Items.ALCHEMICAL_UPGRADE);
GameRegistry.registerItem(diviningRod, Names.Items.DIVINING_ROD);
}
}

View file

@ -2,6 +2,7 @@ package com.pahimar.ee3.item;
import com.pahimar.ee3.reference.Key;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.util.LogHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -43,6 +44,6 @@ public class ItemPhilosophersStone extends ItemEE implements IKeyBound
@Override
public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key)
{
LogHelper.info(String.format("%s %s %s", entityPlayer.toString(), itemStack.toString(), key.toString()));
}
}

View file

@ -1,10 +1,12 @@
package com.pahimar.ee3.network.message;
import com.pahimar.ee3.item.IKeyBound;
import com.pahimar.ee3.reference.Key;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
public class MessageKeyPressed implements IMessage, IMessageHandler<MessageKeyPressed, IMessage>
{
@ -53,30 +55,27 @@ public class MessageKeyPressed implements IMessage, IMessageHandler<MessageKeyPr
@Override
public IMessage onMessage(MessageKeyPressed message, MessageContext ctx)
{
/**
* Yes I know that the entityPlayer is not correct. It appears that MessageContext never gets a nethandler set for it so
* there isn't an easy way to grab the player that sent the packet until that's resolved.
*/
EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
// if (entityPlayer != null && entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().getItem() instanceof IKeyBound)
// {
// if (keyPressed == Key.CHARGE.ordinal())
// {
// ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.CHARGE);
// }
// else if (keyPressed == Key.EXTRA.ordinal())
// {
// ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.EXTRA);
// }
// else if (keyPressed == Key.RELEASE.ordinal())
// {
// ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.RELEASE);
// }
// else if (keyPressed == Key.TOGGLE.ordinal())
// {
// ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.TOGGLE);
// }
// }
if (entityPlayer != null && entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().getItem() instanceof IKeyBound)
{
if (message.keyPressed == Key.CHARGE.ordinal())
{
((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.CHARGE);
}
else if (message.keyPressed == Key.EXTRA.ordinal())
{
((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.EXTRA);
}
else if (message.keyPressed == Key.RELEASE.ordinal())
{
((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.RELEASE);
}
else if (message.keyPressed == Key.TOGGLE.ordinal())
{
((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.TOGGLE);
}
}
return null;
}

View file

@ -4,7 +4,9 @@ public class Names
{
public static class Blocks
{
public static final String CHALK = "chalkBlock";
public static final String ALCHEMICAL_CHEST = "alchemicalChest";
public static final String ALCHEMICAL_FUEL = "alchemicalFuelBlock";
public static final String ALUDEL = "aludel";
public static final String GLASS_BELL = "glassBell";
public static final String CALCINATOR = "calcinator";
@ -62,6 +64,7 @@ public class Names
public static class Keys
{
public static final String CATEGORY = "key.categories.ee3";
public static final String CHARGE = "key.charge";
public static final String EXTRA = "key.extra";
public static final String RELEASE = "key.release";

View file

@ -1,4 +1,5 @@
# Key localizations
key.categories.ee3=Equivalent Exchange 3
key.charge=Charge
key.extra=Extra
key.release=Release
@ -25,9 +26,9 @@ item.ee3:alchemicalUpgrade.minium.name=Minium Upgrade
# Block localizations
tile.ee3:alchemicalChest.name=Alchemical Chest
tile.ee3:alchemicalFuel.alchemicalCoal.name=Block of Alchemical Coal
tile.ee3:alchemicalFuel.mobiusFuel.name=Block of Mobius Fuel
tile.ee3:alchemicalFuel.aeternalisFuel.name=Block of Aeternalis Fuel
tile.ee3:alchemicalFuelBlock.alchemicalCoal.name=Block of Alchemical Coal
tile.ee3:alchemicalFuelBlock.mobiusFuel.name=Block of Mobius Fuel
tile.ee3:alchemicalFuelBlock.aeternalisFuel.name=Block of Aeternalis Fuel
tile.ee3:aludel.name=Aludel Base
tile.ee3:calcinator.name=Calcinator
tile.ee3:chalk.name=Chalk

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

View file

@ -1,7 +0,0 @@
{
"animation": {
"frames": [
0
]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

View file

@ -1,7 +0,0 @@
{
"animation": {
"frames": [
0
]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B