mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 20:52:26 +00:00
Merge branch 'master' into weaponry
Conflicts: .gitignore build.properties
This commit is contained in:
commit
c42f99cba7
22 files changed
+853
-839
No files matched your search
@@ -1,183 +1,222 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Type;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import mantle.common.network.AbstractPacket;
|
||||
import modwarriors.notenoughkeys.api.Api;
|
||||
import modwarriors.notenoughkeys.api.KeyBindingPressedEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.*;
|
||||
import tconstruct.armor.ArmorProxyClient;
|
||||
import tconstruct.armor.ArmorProxyCommon;
|
||||
import tconstruct.armor.PlayerAbilityHelper;
|
||||
import tconstruct.armor.items.TravelGear;
|
||||
import tconstruct.util.network.*;
|
||||
import tconstruct.util.network.AccessoryInventoryPacket;
|
||||
import tconstruct.util.network.BeltPacket;
|
||||
import tconstruct.util.network.DoubleJumpPacket;
|
||||
import tconstruct.util.network.GogglePacket;
|
||||
|
||||
public class ArmorControls extends TKeyHandler
|
||||
{
|
||||
public static final String keybindCategory = "tconstruct.keybindings";
|
||||
public static KeyBinding armorKey = new KeyBinding("key.tarmor", 24, keybindCategory);
|
||||
public static KeyBinding toggleGoggles = new KeyBinding("key.tgoggles", 34, keybindCategory);
|
||||
public static KeyBinding beltSwap = new KeyBinding("key.tbelt", 48, keybindCategory);
|
||||
public static KeyBinding zoomKey = new KeyBinding("key.tzoom", 44, keybindCategory); //TODO: Make this hold, not toggle
|
||||
static KeyBinding jumpKey;
|
||||
static KeyBinding invKey;
|
||||
static Minecraft mc;
|
||||
public class ArmorControls {
|
||||
public static final String keybindCategory = "tconstruct.keybindings";
|
||||
public static final String[] keyDescs = new String[] { "key.tarmor", "key.tgoggles",
|
||||
"key.tbelt", "key.tzoom"
|
||||
};
|
||||
public static KeyBinding armorKey = new KeyBinding(keyDescs[0], 24, keybindCategory);
|
||||
public static KeyBinding toggleGoggles = new KeyBinding(keyDescs[1], 34, keybindCategory);
|
||||
public static KeyBinding beltSwap = new KeyBinding(keyDescs[2], 48, keybindCategory);
|
||||
public static KeyBinding zoomKey = new KeyBinding(keyDescs[3], 44,
|
||||
keybindCategory); //TODO: Make this hold, not toggle
|
||||
static KeyBinding jumpKey;
|
||||
static KeyBinding invKey;
|
||||
static Minecraft mc;
|
||||
|
||||
boolean jumping;
|
||||
int midairJumps = 0;
|
||||
boolean climbing = false;
|
||||
boolean onGround = false;
|
||||
public static boolean zoom = false;
|
||||
boolean activeGoggles = false; //TODO: Set this on server login
|
||||
boolean jumping;
|
||||
int midairJumps = 0;
|
||||
boolean climbing = false;
|
||||
boolean onGround = false;
|
||||
public static boolean zoom = false;
|
||||
boolean activeGoggles = false; //TODO: Set this on server login
|
||||
|
||||
int currentTab = 1;
|
||||
int currentTab = 1;
|
||||
|
||||
// boolean onStilts = false;
|
||||
// boolean onStilts = false;
|
||||
|
||||
public ArmorControls()
|
||||
{
|
||||
super(new KeyBinding[] { armorKey, toggleGoggles, beltSwap, zoomKey }, new boolean[] { false, false, false, false }, getVanillaKeyBindings(), new boolean[] { false, false });
|
||||
/*ClientRegistry.registerKeyBinding(armorKey);
|
||||
ClientRegistry.registerKeyBinding(refreshCapes);
|
||||
ClientRegistry.registerKeyBinding(toggleGoggles);
|
||||
ClientRegistry.registerKeyBinding(beltSwap);
|
||||
ClientRegistry.registerKeyBinding(zoomKey);*/
|
||||
}
|
||||
private final KeyBinding[] keys;
|
||||
|
||||
private static KeyBinding[] getVanillaKeyBindings ()
|
||||
{
|
||||
mc = Minecraft.getMinecraft();
|
||||
jumpKey = mc.gameSettings.keyBindJump;
|
||||
invKey = mc.gameSettings.keyBindInventory;
|
||||
return new KeyBinding[] { jumpKey, invKey };
|
||||
}
|
||||
public ArmorControls() {
|
||||
getVanillaKeyBindings();
|
||||
this.keys = new KeyBinding[] {
|
||||
ArmorControls.armorKey,
|
||||
ArmorControls.toggleGoggles,
|
||||
ArmorControls.beltSwap,
|
||||
ArmorControls.zoomKey,
|
||||
null, null
|
||||
};
|
||||
|
||||
@Override
|
||||
public void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
|
||||
{
|
||||
if (tickEnd && mc.theWorld != null)
|
||||
{
|
||||
if (kb == armorKey && mc.currentScreen == null) // Extended Armor
|
||||
{
|
||||
openArmorGui();// mc.thePlayer.username);
|
||||
}
|
||||
}
|
||||
|
||||
if (kb == jumpKey) // Double jump
|
||||
{
|
||||
if (mc.thePlayer.capabilities.isCreativeMode)
|
||||
return;
|
||||
public void registerKeys() {
|
||||
// Register bindings
|
||||
for (KeyBinding key : this.keys) {
|
||||
if (key != null)
|
||||
ClientRegistry.registerKeyBinding(key);
|
||||
}
|
||||
if (Loader.isModLoaded("notenoughkeys"))
|
||||
Api.registerMod(TConstruct.modID, ArmorControls.keyDescs);
|
||||
// Add mc keys
|
||||
this.keys[4] = ArmorControls.jumpKey;
|
||||
this.keys[5] = ArmorControls.invKey;
|
||||
}
|
||||
|
||||
if (jumping && midairJumps > 0)
|
||||
{
|
||||
mc.thePlayer.motionY = 0.42D;
|
||||
mc.thePlayer.fallDistance = 0;
|
||||
private static KeyBinding[] getVanillaKeyBindings() {
|
||||
mc = Minecraft.getMinecraft();
|
||||
jumpKey = mc.gameSettings.keyBindJump;
|
||||
invKey = mc.gameSettings.keyBindInventory;
|
||||
return new KeyBinding[] { jumpKey, invKey };
|
||||
}
|
||||
|
||||
if (mc.thePlayer.isPotionActive(Potion.jump))
|
||||
{
|
||||
mc.thePlayer.motionY += (double) ((float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void mouseEvent(InputEvent.MouseInputEvent event) {
|
||||
if (!Loader.isModLoaded("notenoughkeys"))
|
||||
this.checkKeys();
|
||||
}
|
||||
|
||||
midairJumps--;
|
||||
resetFallDamage();
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void keyEvent(InputEvent.KeyInputEvent event) {
|
||||
if (!Loader.isModLoaded("notenoughkeys"))
|
||||
this.checkKeys();
|
||||
}
|
||||
|
||||
if (!jumping)
|
||||
{
|
||||
jumping = mc.thePlayer.isAirBorne;
|
||||
ItemStack shoes = mc.thePlayer.getCurrentArmor(0);
|
||||
if (shoes != null && shoes.hasTagCompound() && shoes.getTagCompound().hasKey("TinkerArmor"))
|
||||
{
|
||||
NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
midairJumps += shoeTag.getInteger("Double-Jump");
|
||||
}
|
||||
ItemStack wings = mc.thePlayer.getCurrentArmor(1);
|
||||
if (wings != null && wings.hasTagCompound() && wings.getTagCompound().hasKey("TinkerArmor"))
|
||||
{
|
||||
NBTTagCompound shoeTag = wings.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
midairJumps += shoeTag.getInteger("Double-Jump");
|
||||
}
|
||||
}
|
||||
}
|
||||
@Optional.Method(modid = "notenoughkeys")
|
||||
@SubscribeEvent
|
||||
public void keyEventSpecial(KeyBindingPressedEvent event) {
|
||||
this.keyPressed(event.keyBinding);
|
||||
}
|
||||
|
||||
if (mc.currentScreen == null)
|
||||
{
|
||||
if (kb == toggleGoggles)
|
||||
{
|
||||
ItemStack goggles = mc.thePlayer.getCurrentArmor(3);
|
||||
if (goggles != null && goggles.getItem() instanceof TravelGear) //TODO: Genericize this
|
||||
{
|
||||
activeGoggles = !activeGoggles;
|
||||
PlayerAbilityHelper.toggleGoggles(mc.thePlayer, activeGoggles);
|
||||
toggleGoggles();
|
||||
}
|
||||
}
|
||||
if (kb == beltSwap)
|
||||
{
|
||||
if (ArmorProxyClient.armorExtended.inventory[3] != null)
|
||||
{
|
||||
PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended);
|
||||
toggleBelt();
|
||||
}
|
||||
}
|
||||
if (kb == zoomKey)
|
||||
zoom = !zoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void checkKeys() {
|
||||
for (KeyBinding key : this.keys) {
|
||||
if (this.isKeyActive(key.getKeyCode())) {
|
||||
this.keyPressed(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyUp (Type types, KeyBinding kb, boolean tickEnd)
|
||||
{
|
||||
// landOnGround();
|
||||
}
|
||||
private boolean isKeyActive(int keyCode) {
|
||||
if (keyCode < 0)
|
||||
return Mouse.isButtonDown(keyCode + 100);
|
||||
else
|
||||
return Keyboard.isKeyDown(keyCode);
|
||||
}
|
||||
|
||||
public void landOnGround ()
|
||||
{
|
||||
midairJumps = 0;
|
||||
jumping = false;
|
||||
}
|
||||
private void keyPressed(KeyBinding key) {
|
||||
if (key == ArmorControls.armorKey) {
|
||||
openArmorGui();
|
||||
}
|
||||
if (key == ArmorControls.jumpKey) {
|
||||
if (mc.thePlayer.capabilities.isCreativeMode)
|
||||
return;
|
||||
|
||||
public void resetControls ()
|
||||
{
|
||||
midairJumps = 0;
|
||||
jumping = false;
|
||||
climbing = false;
|
||||
onGround = false;
|
||||
}
|
||||
if (jumping && midairJumps > 0) {
|
||||
mc.thePlayer.motionY = 0.42D;
|
||||
mc.thePlayer.fallDistance = 0;
|
||||
|
||||
void resetFallDamage ()
|
||||
{
|
||||
AbstractPacket packet = new DoubleJumpPacket();
|
||||
updateServer(packet);
|
||||
}
|
||||
if (mc.thePlayer.isPotionActive(Potion.jump)) {
|
||||
mc.thePlayer.motionY += (double) (
|
||||
(float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier()
|
||||
+ 1) * 0.1F);
|
||||
}
|
||||
|
||||
public static void openArmorGui ()
|
||||
{
|
||||
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID);
|
||||
updateServer(packet);
|
||||
}
|
||||
midairJumps--;
|
||||
resetFallDamage();
|
||||
}
|
||||
|
||||
public static void openKnapsackGui ()
|
||||
{
|
||||
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID);
|
||||
updateServer(packet);
|
||||
}
|
||||
if (!jumping) {
|
||||
jumping = mc.thePlayer.isAirBorne;
|
||||
ItemStack shoes = mc.thePlayer.getCurrentArmor(0);
|
||||
if (shoes != null && shoes.hasTagCompound() && shoes.getTagCompound()
|
||||
.hasKey("TinkerArmor")) {
|
||||
NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
midairJumps += shoeTag.getInteger("Double-Jump");
|
||||
}
|
||||
ItemStack wings = mc.thePlayer.getCurrentArmor(1);
|
||||
if (wings != null && wings.hasTagCompound() && wings.getTagCompound()
|
||||
.hasKey("TinkerArmor")) {
|
||||
NBTTagCompound shoeTag = wings.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
midairJumps += shoeTag.getInteger("Double-Jump");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mc.currentScreen == null) {
|
||||
if (key == ArmorControls.toggleGoggles) {
|
||||
ItemStack goggles = mc.thePlayer.getCurrentArmor(3);
|
||||
if (goggles != null && goggles
|
||||
.getItem() instanceof TravelGear) //TODO: Genericize this
|
||||
{
|
||||
activeGoggles = !activeGoggles;
|
||||
PlayerAbilityHelper.toggleGoggles(mc.thePlayer, activeGoggles);
|
||||
toggleGoggles();
|
||||
}
|
||||
}
|
||||
if (key == ArmorControls.beltSwap) {
|
||||
if (ArmorProxyClient.armorExtended.inventory[3] != null) {
|
||||
PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended);
|
||||
toggleBelt();
|
||||
}
|
||||
}
|
||||
if (key == ArmorControls.zoomKey) {
|
||||
zoom = !zoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleGoggles ()
|
||||
{
|
||||
AbstractPacket packet = new GogglePacket(activeGoggles);
|
||||
updateServer(packet);
|
||||
}
|
||||
public void landOnGround() {
|
||||
midairJumps = 0;
|
||||
jumping = false;
|
||||
}
|
||||
|
||||
private void toggleBelt ()
|
||||
{
|
||||
AbstractPacket packet = new BeltPacket();
|
||||
updateServer(packet);
|
||||
}
|
||||
public void resetControls() {
|
||||
midairJumps = 0;
|
||||
jumping = false;
|
||||
climbing = false;
|
||||
onGround = false;
|
||||
}
|
||||
|
||||
static void updateServer (AbstractPacket abstractPacket)
|
||||
{
|
||||
TConstruct.packetPipeline.sendToServer(abstractPacket);
|
||||
}
|
||||
void resetFallDamage() {
|
||||
AbstractPacket packet = new DoubleJumpPacket();
|
||||
updateServer(packet);
|
||||
}
|
||||
|
||||
public static void openArmorGui() {
|
||||
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID);
|
||||
updateServer(packet);
|
||||
}
|
||||
|
||||
public static void openKnapsackGui() {
|
||||
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID);
|
||||
updateServer(packet);
|
||||
}
|
||||
|
||||
private void toggleGoggles() {
|
||||
AbstractPacket packet = new GogglePacket(activeGoggles);
|
||||
updateServer(packet);
|
||||
}
|
||||
|
||||
private void toggleBelt() {
|
||||
AbstractPacket packet = new BeltPacket();
|
||||
updateServer(packet);
|
||||
}
|
||||
|
||||
static void updateServer(AbstractPacket abstractPacket) {
|
||||
TConstruct.packetPipeline.sendToServer(abstractPacket);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class BlockSkinRenderHelper
|
||||
{
|
||||
@@ -852,28 +853,33 @@ public class BlockSkinRenderHelper
|
||||
}
|
||||
|
||||
public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int x, int y, int z, RenderBlocks renderer, IBlockAccess world, boolean extraBright)
|
||||
{
|
||||
return renderLiquidBlock(stillIcon, flowingIcon, x, y, z, renderer, world, extraBright, 0xffffffff);
|
||||
}
|
||||
|
||||
public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int x, int y, int z, RenderBlocks renderer, IBlockAccess world, boolean extraBright, int color)
|
||||
{
|
||||
Block block = Blocks.stone;
|
||||
int var5 = block.colorMultiplier(world, x, y, z);
|
||||
float var6 = (float) (var5 >> 16 & 255) / 255.0F;
|
||||
float var7 = (float) (var5 >> 8 & 255) / 255.0F;
|
||||
float var8 = (float) (var5 & 255) / 255.0F;
|
||||
float alpha = (float) (color >> 24 & 255) / 255.0F;
|
||||
float red = (float) (color >> 16 & 255) / 255.0F;
|
||||
float green = (float) (color >> 8 & 255) / 255.0F;
|
||||
float blue = (float) (color & 255) / 255.0F;
|
||||
|
||||
if (EntityRenderer.anaglyphEnable)
|
||||
{
|
||||
float var9 = (var6 * 30.0F + var7 * 59.0F + var8 * 11.0F) / 100.0F;
|
||||
float var10 = (var6 * 30.0F + var7 * 70.0F) / 100.0F;
|
||||
float var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F;
|
||||
var6 = var9;
|
||||
var7 = var10;
|
||||
var8 = var11;
|
||||
float var9 = (red * 30.0F + green * 59.0F + blue * 11.0F) / 100.0F;
|
||||
float var10 = (red * 30.0F + green * 70.0F) / 100.0F;
|
||||
float var11 = (red * 30.0F + blue * 70.0F) / 100.0F;
|
||||
red = var9;
|
||||
green = var10;
|
||||
blue = var11;
|
||||
}
|
||||
|
||||
if (extraBright)
|
||||
{
|
||||
var6 = Math.max(1.0f, var6 + 0.5f);
|
||||
var7 = Math.max(1.0f, var7 + 0.5f);
|
||||
var8 = Math.max(1.0f, var8 + 0.5f);
|
||||
red = Math.max(1.0f, red + 0.5f);
|
||||
green = Math.max(1.0f, green + 0.5f);
|
||||
blue = Math.max(1.0f, blue + 0.5f);
|
||||
}
|
||||
|
||||
// safety
|
||||
@@ -885,11 +891,18 @@ public class BlockSkinRenderHelper
|
||||
boolean raf = renderer.renderAllFaces;
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
//Tessellator.instance.setColorRGBA_F(alpha, red, green, blue);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
|
||||
|
||||
boolean ret;
|
||||
if (Minecraft.isAmbientOcclusionEnabled())
|
||||
ret = renderFakeBlockWithAmbientOcclusion(stillIcon, flowingIcon, x, y, z, var6, var7, var8, renderer, world);
|
||||
ret = renderFakeBlockWithAmbientOcclusion(stillIcon, flowingIcon, x, y, z, red, green, blue, renderer, world);
|
||||
else
|
||||
ret = renderFakeBlockWithColorMultiplier(stillIcon, flowingIcon, x, y, z, var6, var7, var8, renderer, world);
|
||||
ret = renderFakeBlockWithColorMultiplier(stillIcon, flowingIcon, x, y, z, red, green, blue, renderer, world);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
renderer.renderAllFaces = raf;
|
||||
return ret;
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Type;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.lwjgl.input.*;
|
||||
|
||||
public abstract class TKeyHandler
|
||||
{
|
||||
public KeyBinding[] keyBindings;
|
||||
public KeyBinding[] vKeyBindings;
|
||||
public boolean[] keyDown;
|
||||
public boolean[] repeatings;
|
||||
public boolean[] vRepeatings;
|
||||
public boolean isDummy;
|
||||
|
||||
/**
|
||||
* Pass an array of keybindings and a repeat flag for each one
|
||||
*
|
||||
* @param keyBindings
|
||||
* @param repeatings
|
||||
*/
|
||||
public TKeyHandler(KeyBinding[] keyBindings, boolean[] repeatings, KeyBinding[] vanillaKeys, boolean[] vanillaRepeatings)
|
||||
{
|
||||
assert keyBindings.length == repeatings.length : "You need to pass two arrays of identical length";
|
||||
assert vanillaKeys.length == vanillaRepeatings.length : "You need to pass two arrays of identical length";
|
||||
this.keyBindings = keyBindings;
|
||||
this.repeatings = repeatings;
|
||||
this.vKeyBindings = vanillaKeys;
|
||||
this.vRepeatings = vanillaRepeatings;
|
||||
this.keyDown = new boolean[keyBindings.length + vanillaKeys.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the keys into the system. You will do your own keyboard
|
||||
* management elsewhere. No events will fire if you use this method
|
||||
*
|
||||
* @param keyBindings
|
||||
*/
|
||||
public TKeyHandler(KeyBinding[] keyBindings)
|
||||
{
|
||||
this.keyBindings = keyBindings;
|
||||
this.isDummy = true;
|
||||
}
|
||||
|
||||
public KeyBinding[] getKeyBindings ()
|
||||
{
|
||||
return this.keyBindings;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick (ClientTickEvent event)
|
||||
{
|
||||
if (event.side == Side.CLIENT)
|
||||
{
|
||||
if (event.phase == Phase.START)
|
||||
keyTick(event.type, false);
|
||||
else if (event.phase == Phase.END)
|
||||
keyTick(event.type, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void keyTick (Type type, boolean tickEnd)
|
||||
{
|
||||
for (int i = 0; i < keyBindings.length; i++)
|
||||
{
|
||||
KeyBinding keyBinding = keyBindings[i];
|
||||
int keyCode = keyBinding.getKeyCode();
|
||||
boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
|
||||
if (state != keyDown[i] || (state && repeatings[i]))
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
keyDown(type, keyBinding, tickEnd, state != keyDown[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyUp(type, keyBinding, tickEnd);
|
||||
}
|
||||
if (tickEnd)
|
||||
{
|
||||
keyDown[i] = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < vKeyBindings.length; i++)
|
||||
{
|
||||
KeyBinding keyBinding = vKeyBindings[i];
|
||||
int keyCode = keyBinding.getKeyCode();
|
||||
boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
|
||||
if (state != keyDown[i + keyBindings.length] || (state && vRepeatings[i]))
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
keyDown(type, keyBinding, tickEnd, state != keyDown[i + keyBindings.length]);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyUp(type, keyBinding, tickEnd);
|
||||
}
|
||||
if (tickEnd)
|
||||
{
|
||||
keyDown[i + keyBindings.length] = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the key is first in the down position on any tick from the
|
||||
* {@link #ticks()} set. Will be called subsequently with isRepeat set to
|
||||
* true
|
||||
*
|
||||
* @see #keyUp(EnumSet, KeyBinding, boolean)
|
||||
*
|
||||
* @param types
|
||||
* the type(s) of tick that fired when this key was first down
|
||||
* @param tickEnd
|
||||
* was it an end or start tick which fired the key
|
||||
* @param isRepeat
|
||||
* is it a repeat key event
|
||||
*/
|
||||
public abstract void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepeat);
|
||||
|
||||
/**
|
||||
* Fired once when the key changes state from down to up
|
||||
*
|
||||
* @see #keyDown(EnumSet, KeyBinding, boolean, boolean)
|
||||
*
|
||||
* @param types
|
||||
* the type(s) of tick that fired when this key was first down
|
||||
* @param tickEnd
|
||||
* was it an end or start tick which fired the key
|
||||
*/
|
||||
public abstract void keyUp (Type types, KeyBinding kb, boolean tickEnd);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user