Controller support, toggle sprint, left hand
This commit is contained in:
parent
8be88fd75d
commit
dd4da4ed46
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -70,6 +70,133 @@ window.addEventListener("load", () => {
|
|||
launchInterval = setInterval(launchTick, 50);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
let controllerIndex = null;
|
||||
|
||||
//Left JoyStick
|
||||
let leftRightAxis1 = 0;
|
||||
let upDownAxis1 = 0;
|
||||
|
||||
//Right JoyStick
|
||||
let leftRightAxis2 = 0;
|
||||
let upDownAxis2 = 0;
|
||||
|
||||
//in-game controller
|
||||
let jump = false;
|
||||
let crouch = false;
|
||||
|
||||
window.addEventListener("gamepadconnected", (event) => {
|
||||
const gamepad = event.gamepad;
|
||||
controllerIndex = gamepad.index;
|
||||
});
|
||||
|
||||
window.addEventListener("gamepaddisconnected",(event) => {
|
||||
controllerIndex = null;
|
||||
});
|
||||
|
||||
function handleSticks(axes) {
|
||||
updateStick1(axes[0], axes[1]);
|
||||
updateStick2(axes[2], axes[3]);
|
||||
}
|
||||
|
||||
function updateStick1(leftRighAxis, upDownAxis) {
|
||||
const multiplier = 25;
|
||||
const stickLeftRight = leftRighAxis * multiplier;
|
||||
const stickUpDown = upDownAxis * multiplier;
|
||||
leftRightAxis1 = stickLeftRight;
|
||||
upDownAxis1 = stickUpDown;
|
||||
}
|
||||
|
||||
function updateStick2(leftRightAxis, upDownAxis) {
|
||||
const multiplier = 25;
|
||||
const stickLeftRight = leftRightAxis * multiplier;
|
||||
const stickUpDown = upDownAxis * multiplier;
|
||||
leftRightAxis2 = stickLeftRight;
|
||||
upDownAxis2 = stickUpDown;
|
||||
}
|
||||
|
||||
function controllerConnected() {
|
||||
if(controllerIndex != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleButtons(buttons) {
|
||||
for(let i = 0; i < buttons.length; i++) {
|
||||
const button = buttons[i];
|
||||
|
||||
if(button.value > 0) {
|
||||
if(i == 0) {
|
||||
jump = true;
|
||||
}
|
||||
|
||||
if(i == 1) {
|
||||
crouch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCameraX() {
|
||||
return leftRightAxis2;
|
||||
}
|
||||
|
||||
function getCameraY() {
|
||||
return upDownAxis2;
|
||||
}
|
||||
|
||||
function isWalkingForward() {
|
||||
if(upDownAxis1 < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWalkingBackward() {
|
||||
if(upDownAxis1 > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWalkingLeft() {
|
||||
if(leftRightAxis1 < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWalkingRight() {
|
||||
if(leftRightAxis1 > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isKeyDown(buttonID) {
|
||||
const gamepad = navigator.getGamepads()[controllerIndex];
|
||||
const buttons = gamepad.buttons;
|
||||
const button = buttons[buttonID];
|
||||
if (gamepad) {
|
||||
const buttons = gamepad.buttons;
|
||||
const button = buttons[buttonID];
|
||||
return button.value > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateController() {
|
||||
if(controllerConnected()) {
|
||||
if(controllerIndex != null) {
|
||||
const gamepad = navigator.getGamepads()[controllerIndex];
|
||||
handleSticks(gamepad.axes);
|
||||
handleButtons(gamepad.buttons);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link type="image/png" rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAR/SURBVEhLtZXZK3ZRFMYPcqXc+gv413DHxVuGIpIhkciQWaRccCNjSCkligwXSOZ5nmfv9zvn2e8+58V753sudmuvvdZ61l5r7XOc8H+GS/D19aUNkPz5+aktQH5/f//4+LBKZKuRkpUtQjCUYG5gD2T38vLy/PwsDfL9/f3Dw8PT05M0b29vnKLhCKCBT4L4gvBLBIei4//4+Hh1dUVEQutUuLu7E83FxQUGnKLBWKfQaA3S+AREVxaEOD8/Pzk50XpzcyMDcH19zdZG3N3d3dzc3Nvb01aX5pQUpQGGQJxcQpfNysoKhUIdHR1o1tbWbInYAgxIPDMzMy8vLzc3FxqOdMoRqwJK8G8ALUYIhHMiSEhIwI6CyIb0qQzC4eGhsXCc1tZWnZIEKzdQJQSXgKxfX18RCM3Z5eWlcfVAxKOjo+Pj49PTU88lTOk2NjbMsePc3t6SAfcgFdszOyMuAdeBg0CQi2lhYUHOeOLDCisN8FzcPFZXV3t7ezHY3t5GQ+6it+2xMASsKhEEWKsmRLRBBUpPvpJ/TpFKFBwKYAiITmicsbYhdHfJAltqhUCVsCQhwslmeXmZxiBQT9c0Ar9E2O3v72sYSE0N1yQArkKy0kBMXLqlZqIZHR3t6empqqqSDcBdhXEJSJ/bUc3q6uq+vj629GB9fR1WsLW1NTs7u7S0RN2locMjIyOEm5ubQ7+4uJienk4/+vv77Y1hwhLBEKhwWHitdVFfX9/Y2Gg2HuLi4owUAysrK8yCG97rh0+ApP5Q2ZycHFlPTExUVFRIBvn5+WhKSkp2dnaMKhptbW2426GgQ/rwuAQCZ1hwFayLiork9hMFBQV1dXVmE0BLS4vqw3QFB8kn4IAxoGPkYpxi4FeDmpqas7Mz4pClAgqGwD48rjY2NmacYqC0tJQ1KSlJWyE5OZkpUKkBAxZVIntAoZh04+Q48fHxPNGBgYHExMT29naj9cBodnZ2mo3jlJWVMeW2OGQck4B1amqqoaGhqamJjx2lGxwcpL0mUgR8fJhsWqJtSkoKU2SbHHUDpkhPBujd8xuQG6PJRM/Pz09PT7O1NNnZ2Tw3fgZkXVhYKCUlUhBATP+hCVyKZGky17RV0g04laayslJ6hlVeFHB4eFhKaogGd0LxtmTgE+hbhKDnPjMzgw8E3qGL2tpaBWpubjYqj2BoaEj6rq4uNATRZ0ZwCbiL6gXEzINk5vCBQJ9rMD4+rkA8QNK036uDg4Py8vLu7m680KjIBNR3zBDoWQM1g98snyB+VSoRW8C/UwR81/SvhgNj9JOTkwwVERUdRBEI0BAdLRVERkhLS8vIyEDQlrsTPTU1lVFhKxARvZgUlFLbegCf4BvIsbi4mIg4E5EogIHhiKCMtU0WUFiVy06j5fAJIDdSBDQw+PegDfBRcbOPwH4F9LuFWIIQdQNKwWqzIE0aoFUaBsw+SQuFw0uNtC9A+F4i3QNrbg3IDn+SAsHh+wYiEpeyBEMLv/cAO6KzAijxxB+Y4wisBhssJUhjEbPJf4Nw+B+JXqLW3bw+wQAAAABJRU5ErkJggg==" />
|
||||
</head>
|
||||
|
|
73342
javascript/classes.js
73342
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
124
javascript/controller.js
Normal file
124
javascript/controller.js
Normal file
|
@ -0,0 +1,124 @@
|
|||
let controllerIndex = null;
|
||||
|
||||
//Left JoyStick
|
||||
let leftRightAxis1 = 0;
|
||||
let upDownAxis1 = 0;
|
||||
|
||||
//Right JoyStick
|
||||
let leftRightAxis2 = 0;
|
||||
let upDownAxis2 = 0;
|
||||
|
||||
//in-game controller
|
||||
let jump = false;
|
||||
let crouch = false;
|
||||
|
||||
window.addEventListener("gamepadconnected", (event) => {
|
||||
const gamepad = event.gamepad;
|
||||
controllerIndex = gamepad.index;
|
||||
});
|
||||
|
||||
window.addEventListener("gamepaddisconnected",(event) => {
|
||||
controllerIndex = null;
|
||||
});
|
||||
|
||||
function handleSticks(axes) {
|
||||
updateStick1(axes[0], axes[1]);
|
||||
updateStick2(axes[2], axes[3]);
|
||||
}
|
||||
|
||||
function updateStick1(leftRighAxis, upDownAxis) {
|
||||
const multiplier = 25;
|
||||
const stickLeftRight = leftRighAxis * multiplier;
|
||||
const stickUpDown = upDownAxis * multiplier;
|
||||
leftRightAxis1 = stickLeftRight;
|
||||
upDownAxis1 = stickUpDown;
|
||||
}
|
||||
|
||||
function updateStick2(leftRightAxis, upDownAxis) {
|
||||
const multiplier = 25;
|
||||
const stickLeftRight = leftRightAxis * multiplier;
|
||||
const stickUpDown = upDownAxis * multiplier;
|
||||
leftRightAxis2 = stickLeftRight;
|
||||
upDownAxis2 = stickUpDown;
|
||||
}
|
||||
|
||||
function controllerConnected() {
|
||||
if(controllerIndex != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleButtons(buttons) {
|
||||
for(let i = 0; i < buttons.length; i++) {
|
||||
const button = buttons[i];
|
||||
|
||||
if(button.value > 0) {
|
||||
if(i == 0) {
|
||||
jump = true;
|
||||
}
|
||||
|
||||
if(i == 1) {
|
||||
crouch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCameraX() {
|
||||
return leftRightAxis2;
|
||||
}
|
||||
|
||||
function getCameraY() {
|
||||
return upDownAxis2;
|
||||
}
|
||||
|
||||
function isWalkingForward() {
|
||||
if(upDownAxis1 < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWalkingBackward() {
|
||||
if(upDownAxis1 > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWalkingLeft() {
|
||||
if(leftRightAxis1 < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWalkingRight() {
|
||||
if(leftRightAxis1 > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isKeyDown(buttonID) {
|
||||
const gamepad = navigator.getGamepads()[controllerIndex];
|
||||
const buttons = gamepad.buttons;
|
||||
const button = buttons[buttonID];
|
||||
if (gamepad) {
|
||||
const buttons = gamepad.buttons;
|
||||
const button = buttons[buttonID];
|
||||
return button.value > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateController() {
|
||||
if(controllerConnected()) {
|
||||
if(controllerIndex != null) {
|
||||
const gamepad = navigator.getGamepads()[controllerIndex];
|
||||
handleSticks(gamepad.axes);
|
||||
handleButtons(gamepad.buttons);
|
||||
}
|
||||
}
|
||||
}
|
42
src/main/java/net/PeytonPlayz585/shadow/Controller.java
Normal file
42
src/main/java/net/PeytonPlayz585/shadow/Controller.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package net.PeytonPlayz585.shadow;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
|
||||
public class Controller {
|
||||
|
||||
@JSBody(params = {}, script = "return isWalkingForward();")
|
||||
public static native boolean isWalkingForward();
|
||||
|
||||
@JSBody(params = {}, script = "return isWalkingBackward();")
|
||||
public static native boolean isWalkingBackward();
|
||||
|
||||
@JSBody(params = {}, script = "return isWalkingLeft();")
|
||||
public static native boolean isWalkingLeft();
|
||||
|
||||
@JSBody(params = {}, script = "return isWalkingRight();")
|
||||
public static native boolean isWalkingRight();
|
||||
|
||||
@JSBody(params = {}, script = "return getCameraX();")
|
||||
public static native int getCameraX();
|
||||
|
||||
@JSBody(params = {}, script = "return getCameraY();")
|
||||
public static native int getCameraY();
|
||||
|
||||
@JSBody(params = {}, script = "return jump;")
|
||||
public static native boolean isJumping();
|
||||
|
||||
@JSBody(params = {}, script = "return crouch;")
|
||||
public static native boolean isSneaking();
|
||||
|
||||
@JSBody(params = {}, script = "updateController();")
|
||||
public static native void controllerTick();
|
||||
|
||||
@JSBody(params = {}, script = "jump = false;")
|
||||
public static native void unpressJump();
|
||||
|
||||
@JSBody(params = {}, script = "crouch = false;")
|
||||
public static native void unpressCrouch();
|
||||
|
||||
@JSBody(params = {"buttonID"}, script = "return isKeyDown(buttonID);")
|
||||
public static native boolean isButtonPressed(int buttonID);
|
||||
}
|
134
src/main/java/net/PeytonPlayz585/shadow/gui/ArmorGui.java
Normal file
134
src/main/java/net/PeytonPlayz585/shadow/gui/ArmorGui.java
Normal file
|
@ -0,0 +1,134 @@
|
|||
package net.PeytonPlayz585.shadow.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ArmorGui {
|
||||
public static void draw() {
|
||||
renderPotEffects();
|
||||
renderArmorDura();
|
||||
renderCPS();
|
||||
}
|
||||
|
||||
public static void renderArmorDura() {
|
||||
GlStateManager.enableLighting();
|
||||
ItemStack boots = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[0];
|
||||
ItemStack legs = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[1];
|
||||
ItemStack chest = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[2];
|
||||
ItemStack helmet = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[3];
|
||||
ItemStack hand = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem();
|
||||
if (helmet != null) {
|
||||
ItemStack displayhelmet = helmet.copy();
|
||||
displayhelmet.stackSize = 1;
|
||||
GuiIngame.itemRenderer.renderItemAndEffectIntoGUI(displayhelmet, 5 + 3, 15 + 2);
|
||||
GuiIngame.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displayhelmet, 5 + 3, 15 + 2, "");
|
||||
}
|
||||
if (chest != null) {
|
||||
ItemStack displaychest = chest.copy();
|
||||
displaychest.stackSize = 1;
|
||||
GuiIngame.itemRenderer.renderItemAndEffectIntoGUI(displaychest, 5 + 3, 15 + 18);
|
||||
GuiIngame.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displaychest, 5 + 3, 15 + 18, "");
|
||||
}
|
||||
if (legs != null) {
|
||||
ItemStack displaylegs = legs.copy();
|
||||
displaylegs.stackSize = 1;
|
||||
GuiIngame.itemRenderer.renderItemAndEffectIntoGUI(displaylegs, 5 + 3, 10 + 34);
|
||||
GuiIngame.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displaylegs, 5 + 3, 15 + 34, "");
|
||||
}
|
||||
if (boots != null) {
|
||||
ItemStack displayboots = boots.copy();
|
||||
displayboots.stackSize = 1;
|
||||
GuiIngame.itemRenderer.renderItemAndEffectIntoGUI(displayboots, 5 + 3, 15 + 50);
|
||||
GuiIngame.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displayboots, 5 + 3, 15 + 50, "");
|
||||
}
|
||||
if (hand != null) {
|
||||
ItemStack displayhand = hand.copy();
|
||||
displayhand.stackSize = 1;
|
||||
GuiIngame.itemRenderer.renderItemAndEffectIntoGUI(displayhand, 5 + 3, 15 + 66);
|
||||
GuiIngame.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displayhand, 5 + 3, 15 + 66, "");
|
||||
}
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
}
|
||||
public static void renderPotEffects() {
|
||||
int i = 80;
|
||||
int i2 = 16;
|
||||
Collection < PotionEffect > collection = Minecraft.getMinecraft().thePlayer.getActivePotionEffects();
|
||||
if (!collection.isEmpty()) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableAlpha();
|
||||
int l = 33;
|
||||
if (collection.size() > 5) l = 132 / (collection.size() - 1);
|
||||
for (PotionEffect potioneffect: Minecraft.getMinecraft().thePlayer.getActivePotionEffects()) {
|
||||
Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (potion.hasStatusIcon()) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png"));
|
||||
int i3 = potion.getStatusIconIndex();
|
||||
GuiIngame guiIngame = new GuiIngame(Minecraft.getMinecraft());
|
||||
guiIngame.drawTexturedModalRect(4 + 21 - 20, 110 + i2 - 14, 0 + i3 % 8 * 18, 198 + i3 / 8 * 18, 18, 18);
|
||||
}
|
||||
String s1 = I18n.format(potion.getName(), new Object[0]);
|
||||
if (potioneffect.getAmplifier() == 1) {
|
||||
s1 = String.valueOf(String.valueOf(s1)) + " " + I18n.format("enchantment.level.2", new Object[0]);
|
||||
} else if (potioneffect.getAmplifier() == 2) {
|
||||
s1 = String.valueOf(String.valueOf(s1)) + " " + I18n.format("enchantment.level.3", new Object[0]);
|
||||
} else if (potioneffect.getAmplifier() == 3) {
|
||||
s1 = String.valueOf(String.valueOf(s1)) + " " + I18n.format("enchantment.level.4", new Object[0]);
|
||||
}
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(s1, (4 + 21), (110 + i2 - 14), -1);
|
||||
String s2 = Potion.getDurationString(potioneffect);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(s2, (4 + 21), (110 + i2 + 10 - 14), -1);
|
||||
i2 += l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean wasPressed;
|
||||
public static long lastPressed;
|
||||
private static List < Long > clicks = new ArrayList < > ();
|
||||
|
||||
public static void renderCPS() {
|
||||
boolean pressed = Mouse.isButtonDown(0) || Mouse.isButtonDown(1);
|
||||
|
||||
if (pressed != wasPressed) {
|
||||
lastPressed = System.currentTimeMillis();
|
||||
wasPressed = pressed;
|
||||
if (pressed) {
|
||||
clicks.add(lastPressed);
|
||||
}
|
||||
}
|
||||
|
||||
final long time = System.currentTimeMillis();
|
||||
FuncUtils.removeIf(clicks, sinceLast -> sinceLast + 1000 < time);
|
||||
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString("[CPS: " + clicks.size() + "]", 300 + 2, 5 + 2, -1);
|
||||
}
|
||||
|
||||
public static void renderKeyStrokes() {
|
||||
Gui.drawRect(400 + 25 + 5, 40, 400 + 25 + 5 + 25, 40 + 25, !Minecraft.getMinecraft().gameSettings.keyBindForward.pressed ? 0x88101010 : 0x88888888);
|
||||
Gui.drawRect(400 + 25 + 5, 40 + 5 + 25, 400 + 25 + 5 + 25, 40 + 25 + 5 + 25, !Minecraft.getMinecraft().gameSettings.keyBindBack.pressed ? 0x88101010 : 0x88888888);
|
||||
Gui.drawRect(400 + 25 + 5 + 5 + 25, 40 + 5 + 25, 400 + 25 + 5 + 5 + 25 + 25, 40 + 25 + 5 + 25, !Minecraft.getMinecraft().gameSettings.keyBindRight.pressed ? 0x88101010 : 0x88888888);
|
||||
Gui.drawRect(400, 40 + 5 + 25, 400 + 25, 40 + 25 + 5 + 25, !Minecraft.getMinecraft().gameSettings.keyBindLeft.pressed ? 0x88101010 : 0x88888888);
|
||||
Gui.drawRect(400, 40 + 5 + 25 + 5 + 25, 400 + 40, 40 + 25 + 5 + 25 + 5 + 25, !Minecraft.getMinecraft().gameSettings.keyBindAttack.pressed ? 0x88101010 : 0x88888888);
|
||||
Gui.drawRect(400 + 40 + 5, 40 + 5 + 25 + 5 + 25, 400 + 40 + 40 + 5, 40 + 25 + 5 + 25 + 5 + 25, !Minecraft.getMinecraft().gameSettings.keyBindUseItem.pressed ? 0x88101010 : 0x88888888);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().gameSettings.getKeyDisplayString(Minecraft.getMinecraft().gameSettings.keyBindForward.keyCode), 400 + 25 + 5 + (25 / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(Minecraft.getMinecraft().gameSettings.getKeyDisplayString(Minecraft.getMinecraft().gameSettings.keyBindForward.keyCode)) / 2), 40 + 25 / 2 - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2, Minecraft.getMinecraft().gameSettings.keyBindForward.pressed ? 0 : -1);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().gameSettings.getKeyDisplayString(Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode), 400 + (25 / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(Minecraft.getMinecraft().gameSettings.getKeyDisplayString(Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode)) / 2), (40 + 25 + (25 / 2)), Minecraft.getMinecraft().gameSettings.keyBindLeft.pressed ? 0 : -1);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().gameSettings.getKeyDisplayString(Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode), 400 + 25 + 25 + 5 + 5 + (25 / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(Minecraft.getMinecraft().gameSettings.getKeyDisplayString(Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode)) / 2), (40 + 25 + (25 / 2)), Minecraft.getMinecraft().gameSettings.keyBindRight.pressed ? 0 : -1);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString("LEFT", 400 + 40 / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth("LEFT") / 2, (40 + 25 + 25 + 5 + 5 + 25 / 2) - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2, Minecraft.getMinecraft().gameSettings.keyBindAttack.pressed ? 0 : -1);
|
||||
Minecraft.getMinecraft().fontRendererObj.drawString("RIGHT", 400 + 40 + 5 + 40 / 2 - Minecraft.getMinecraft().fontRendererObj.getStringWidth("RIGHT") / 2, (40 + 25 + 25 + 5 + 5 + 25 / 2) - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2, Minecraft.getMinecraft().gameSettings.keyBindUseItem.pressed ? 0 : -1);
|
||||
}
|
||||
}
|
34
src/main/java/net/PeytonPlayz585/shadow/gui/FuncUtils.java
Normal file
34
src/main/java/net/PeytonPlayz585/shadow/gui/FuncUtils.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package net.PeytonPlayz585.shadow.gui;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
|
||||
public class FuncUtils {
|
||||
|
||||
public static < T > boolean removeIf(Collection < T > collection, Predicate < T > pre) {
|
||||
boolean ret = false;
|
||||
Iterator < T > itr = collection.iterator();
|
||||
while (itr.hasNext()) {
|
||||
if (pre.test(itr.next())) {
|
||||
itr.remove();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean isInside(int mouseX, int mouseY, double x, double y, double width, double height) {
|
||||
return (mouseX > x && mouseX < (x + width)) && (mouseY > y && mouseY < (y + height));
|
||||
}
|
||||
|
||||
public static void setColor(int color) {
|
||||
float f3 = (float)(color >> 24 & 255) / 255.0F;
|
||||
float f = (float)(color >> 16 & 255) / 255.0F;
|
||||
float f1 = (float)(color >> 8 & 255) / 255.0F;
|
||||
float f2 = (float)(color & 255) / 255.0F;
|
||||
|
||||
GlStateManager.color(f, f1, f2, f3);
|
||||
}
|
||||
}
|
|
@ -167,6 +167,8 @@ import net.minecraft.world.WorldProviderEnd;
|
|||
import net.minecraft.world.WorldProviderHell;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
|
||||
import net.PeytonPlayz585.shadow.Controller;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
|
@ -1240,6 +1242,9 @@ public class Minecraft implements IThreadListener {
|
|||
* Runs the current tick.
|
||||
*/
|
||||
public void runTick() throws IOException {
|
||||
|
||||
Controller.controllerTick();
|
||||
|
||||
if (this.rightClickDelayTimer > 0) {
|
||||
--this.rightClickDelayTimer;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.minecraft.client.entity;
|
||||
|
||||
import net.FatalCodes.shadow.Shadow;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.MovingSoundMinecartRiding;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
|
@ -664,18 +665,30 @@ public class EntityPlayerSP extends AbstractClientPlayer {
|
|||
this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D,
|
||||
this.posZ + (double) this.width * 0.35D);
|
||||
boolean flag3 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying;
|
||||
if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= f && !this.isSprinting() && flag3
|
||||
&& !this.isUsingItem() && !this.isPotionActive(Potion.blindness)) {
|
||||
if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) {
|
||||
this.sprintToggleTimer = 7;
|
||||
if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= f && !this.isSprinting() && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness)) {
|
||||
if(!Minecraft.getMinecraft().gameSettings.toggleSprint) {
|
||||
if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) {
|
||||
this.sprintToggleTimer = 7;
|
||||
} else {
|
||||
this.setSprinting(true);
|
||||
}
|
||||
} else {
|
||||
this.setSprinting(true);
|
||||
if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.toggleSprintEnabled) {
|
||||
this.sprintToggleTimer = 7;
|
||||
} else {
|
||||
this.setSprinting(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isSprinting() && this.movementInput.moveForward >= f && flag3 && !this.isUsingItem()
|
||||
&& !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.isKeyDown()) {
|
||||
this.setSprinting(true);
|
||||
if(!Minecraft.getMinecraft().gameSettings.toggleSprint) {
|
||||
if (!this.isSprinting() && this.movementInput.moveForward >= f && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.isKeyDown()) {
|
||||
this.setSprinting(true);
|
||||
}
|
||||
} else {
|
||||
if (!this.isSprinting() && this.movementInput.moveForward >= f && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.toggleSprintEnabled) {
|
||||
this.setSprinting(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isSprinting() && (this.movementInput.moveForward < f || this.isCollidedHorizontally || !flag3)) {
|
||||
|
@ -741,5 +754,8 @@ public class EntityPlayerSP extends AbstractClientPlayer {
|
|||
this.sendPlayerAbilities();
|
||||
}
|
||||
|
||||
if(Minecraft.getMinecraft().gameSettings.keyBindSprint.isPressed() && Minecraft.getMinecraft().gameSettings.toggleSprint) {
|
||||
GameSettings.toggleSprintEnabled = !GameSettings.toggleSprintEnabled;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,8 +26,7 @@ import net.minecraft.client.settings.KeyBinding;
|
|||
*
|
||||
*/
|
||||
public class GuiControls extends GuiScreen {
|
||||
private static final GameSettings.Options[] optionsArr = new GameSettings.Options[] {
|
||||
GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN };
|
||||
private static final GameSettings.Options[] optionsArr = new GameSettings.Options[] {GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN, GameSettings.Options.TOGGLE_SPRINT };
|
||||
private GuiScreen parentScreen;
|
||||
protected String screenTitle = "Controls";
|
||||
private GameSettings options;
|
||||
|
|
|
@ -3,6 +3,8 @@ package net.minecraft.client.gui;
|
|||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
|
@ -39,12 +41,12 @@ public class GuiCustomizeSkin extends GuiScreen {
|
|||
this.title = I18n.format("options.skinCustomisation.title", new Object[0]);
|
||||
|
||||
for (EnumPlayerModelParts enumplayermodelparts : EnumPlayerModelParts.values()) {
|
||||
this.buttonList.add(new GuiCustomizeSkin.ButtonPart(enumplayermodelparts.getPartId(),
|
||||
this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), 150, 20,
|
||||
enumplayermodelparts));
|
||||
this.buttonList.add(new GuiCustomizeSkin.ButtonPart(enumplayermodelparts.getPartId(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), 150, 20, enumplayermodelparts));
|
||||
++i;
|
||||
}
|
||||
|
||||
this.buttonList.add(new GuiOptionButton(201, this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), GameSettings.Options.LEFT_HAND, "Main Hand"));
|
||||
|
||||
if (i % 2 == 1) {
|
||||
++i;
|
||||
}
|
||||
|
@ -66,6 +68,9 @@ public class GuiCustomizeSkin extends GuiScreen {
|
|||
EnumPlayerModelParts enumplayermodelparts = ((GuiCustomizeSkin.ButtonPart) parGuiButton).playerModelParts;
|
||||
this.mc.gameSettings.switchModelPartEnabled(enumplayermodelparts);
|
||||
parGuiButton.displayString = this.func_175358_a(enumplayermodelparts);
|
||||
} else {
|
||||
mc.gameSettings.setOptionValue(((GuiOptionButton)parGuiButton).returnEnumOptions(), 1);
|
||||
parGuiButton.displayString = mc.gameSettings.getKeyBinding(GameSettings.Options.LEFT_HAND);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import net.FatalCodes.shadow.Shadow;
|
||||
import net.FatalCodes.shadow.module.RenderModule;
|
||||
import net.PeytonPlayz585.shadow.Config;
|
||||
import net.PeytonPlayz585.shadow.gui.ArmorGui;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
|
||||
|
@ -78,7 +79,7 @@ public class GuiIngame extends Gui {
|
|||
private static final ResourceLocation pumpkinBlurTexPath = new ResourceLocation("textures/misc/pumpkinblur.png");
|
||||
private final EaglercraftRandom rand = new EaglercraftRandom();
|
||||
private final Minecraft mc;
|
||||
private final RenderItem itemRenderer;
|
||||
public static RenderItem itemRenderer;
|
||||
private final GuiNewChat persistantChatGUI;
|
||||
private int updateCounter;
|
||||
/**+
|
||||
|
@ -316,6 +317,7 @@ public class GuiIngame extends Gui {
|
|||
}
|
||||
}
|
||||
|
||||
ArmorGui.draw();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableAlpha();
|
||||
|
|
|
@ -88,6 +88,7 @@ import net.minecraft.world.WorldSettings;
|
|||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import net.PeytonPlayz585.shadow.Config;
|
||||
import net.PeytonPlayz585.shadow.Controller;
|
||||
import net.PeytonPlayz585.shadow.TextureUtils;
|
||||
|
||||
/**+
|
||||
|
@ -680,7 +681,11 @@ public class EntityRenderer implements IResourceManagerReloadListener {
|
|||
GlStateManager.loadIdentity();
|
||||
float f = 0.07F;
|
||||
if (this.mc.gameSettings.anaglyph) {
|
||||
GlStateManager.translate((float) (-(xOffset * 2 - 1)) * f, 0.0F, 0.0F);
|
||||
if(this.mc.gameSettings.leftHand) {
|
||||
GlStateManager.translate((float) (-(xOffset * 2 - 1)) * f, 0.0F, 0.0F);
|
||||
} else {
|
||||
GlStateManager.translate((float) (-(xOffset * 2 + 1)) * f, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.gluPerspective(this.getFOVModifier(partialTicks, false),
|
||||
|
@ -908,6 +913,7 @@ public class EntityRenderer implements IResourceManagerReloadListener {
|
|||
this.mc.mcProfiler.startSection("mouse");
|
||||
|
||||
if (this.mc.inGameHasFocus && flag) {
|
||||
|
||||
this.mc.mouseHelper.mouseXYChange();
|
||||
float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
||||
if (this.mc.gameSettings.keyBindZoomCamera.isKeyDown()) {
|
||||
|
|
|
@ -124,23 +124,23 @@ public class GameSettings {
|
|||
public KeyBinding keyBindRight = new KeyBinding("key.right", 32, "key.categories.movement");
|
||||
public KeyBinding keyBindJump = new KeyBinding("key.jump", 57, "key.categories.movement");
|
||||
public KeyBinding keyBindSneak = new KeyBinding("key.sneak", 42, "key.categories.movement");
|
||||
public KeyBinding keyBindSprint = new KeyBinding("key.sprint", KeyboardConstants.KEY_R, "key.categories.movement");
|
||||
public KeyBinding keyBindInventory = new KeyBinding("key.inventory", 18, "key.categories.inventory");
|
||||
public KeyBinding keyBindUseItem = new KeyBinding("key.use", -99, "key.categories.gameplay");
|
||||
public KeyBinding keyBindDrop = new KeyBinding("key.drop", 16, "key.categories.gameplay");
|
||||
public KeyBinding keyBindAttack = new KeyBinding("key.attack", -100, "key.categories.gameplay");
|
||||
public KeyBinding keyBindSprint = new KeyBinding(10, "key.sprint", KeyboardConstants.KEY_R, "key.categories.movement");
|
||||
public KeyBinding keyBindInventory = new KeyBinding(3, "key.inventory", 18, "key.categories.inventory");
|
||||
public KeyBinding keyBindUseItem = new KeyBinding(6, "key.use", -99, "key.categories.gameplay");
|
||||
public KeyBinding keyBindDrop = new KeyBinding(13, "key.drop", 16, "key.categories.gameplay");
|
||||
public KeyBinding keyBindAttack = new KeyBinding(7, "key.attack", -100, "key.categories.gameplay");
|
||||
public KeyBinding keyBindPickBlock = new KeyBinding("key.pickItem", -98, "key.categories.gameplay");
|
||||
public KeyBinding keyBindChat = new KeyBinding("key.chat", 20, "key.categories.multiplayer");
|
||||
public KeyBinding keyBindChat = new KeyBinding(15, "key.chat", 20, "key.categories.multiplayer");
|
||||
public KeyBinding keyBindPlayerList = new KeyBinding("key.playerlist", 15, "key.categories.multiplayer");
|
||||
public KeyBinding keyBindCommand = new KeyBinding("key.command", 53, "key.categories.multiplayer");
|
||||
public KeyBinding keyBindScreenshot = new KeyBinding("key.screenshot", 60, "key.categories.misc");
|
||||
public KeyBinding keyBindTogglePerspective = new KeyBinding("key.togglePerspective", 63, "key.categories.misc");
|
||||
public KeyBinding keyBindSmoothCamera = new KeyBinding("key.smoothCamera", KeyboardConstants.KEY_M,
|
||||
public KeyBinding keyBindTogglePerspective = new KeyBinding(12, "key.togglePerspective", 63, "key.categories.misc");
|
||||
public KeyBinding keyBindSmoothCamera = new KeyBinding(14, "key.smoothCamera", KeyboardConstants.KEY_M,
|
||||
"key.categories.misc");
|
||||
public KeyBinding keyBindZoomCamera = new KeyBinding("key.zoomCamera", KeyboardConstants.KEY_C,
|
||||
"key.categories.misc");
|
||||
public KeyBinding keyBindFunction = new KeyBinding("key.function", KeyboardConstants.KEY_F, "key.categories.misc");
|
||||
public KeyBinding keyBindClose = new KeyBinding("key.close", KeyboardConstants.KEY_GRAVE, "key.categories.misc");
|
||||
public KeyBinding keyBindClose = new KeyBinding(9, "key.close", KeyboardConstants.KEY_GRAVE, "key.categories.misc");
|
||||
public KeyBinding[] keyBindsHotbar = new KeyBinding[] {
|
||||
new KeyBinding("key.hotbar.1", 2, "key.categories.inventory"),
|
||||
new KeyBinding("key.hotbar.2", 3, "key.categories.inventory"),
|
||||
|
@ -252,6 +252,10 @@ public class GameSettings {
|
|||
private static final String[] KEYS_DYNAMIC_LIGHTS = new String[] {"options.off", "options.graphics.fast", "options.graphics.fancy"};
|
||||
private static final int[] OF_TREES_VALUES = new int[] {0, 1, 4, 2};
|
||||
|
||||
public static boolean toggleSprint = false;
|
||||
public static boolean toggleSprintEnabled = false;
|
||||
public boolean leftHand = false;
|
||||
|
||||
public GameSettings(Minecraft mcIn) {
|
||||
this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem,
|
||||
this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump,
|
||||
|
@ -766,6 +770,15 @@ public class GameSettings {
|
|||
this.mc.standardGalacticFontRenderer.onResourceManagerReload(this.mc.getResourceManager());
|
||||
}
|
||||
|
||||
if (parOptions == GameSettings.Options.TOGGLE_SPRINT) {
|
||||
toggleSprintEnabled = false;
|
||||
toggleSprint = !toggleSprint;
|
||||
}
|
||||
|
||||
if(parOptions == GameSettings.Options.LEFT_HAND) {
|
||||
leftHand = !leftHand;
|
||||
}
|
||||
|
||||
this.saveOptions();
|
||||
}
|
||||
|
||||
|
@ -852,6 +865,10 @@ public class GameSettings {
|
|||
return this.ofShowCapes;
|
||||
case DYNAMIC_FOV:
|
||||
return this.ofDynamicFov;
|
||||
case TOGGLE_SPRINT:
|
||||
return toggleSprint;
|
||||
case LEFT_HAND:
|
||||
return leftHand;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -1114,7 +1131,11 @@ public class GameSettings {
|
|||
return this.ofBetterSnow ? s + "ON" : s + "OFF";
|
||||
} else if (parOptions == GameSettings.Options.CUSTOM_FONTS) {
|
||||
return this.ofCustomFonts ? s + "ON" : s + "OFF";
|
||||
} else {
|
||||
} else if (parOptions == GameSettings.Options.TOGGLE_SPRINT) {
|
||||
return toggleSprint ? s + "Toggle" : s + "Hold";
|
||||
} else if(parOptions == GameSettings.Options.LEFT_HAND) {
|
||||
return leftHand ? s + "Left" : s + "Right";
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -1595,6 +1616,14 @@ public class GameSettings {
|
|||
this.ofCustomFonts = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
if (astring[0].equals("toggleSprint") && astring.length >= 2) {
|
||||
toggleSprint = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
if (astring[0].equals("leftHand")) {
|
||||
this.leftHand = Boolean.valueOf(astring[1]).booleanValue();
|
||||
}
|
||||
|
||||
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
|
||||
|
||||
for (SoundCategory soundcategory : SoundCategory.values()) {
|
||||
|
@ -1746,6 +1775,8 @@ public class GameSettings {
|
|||
printwriter.println("ofMipmapType:" + this.ofMipmapType);
|
||||
printwriter.println("ofBetterSnow:" + this.ofBetterSnow);
|
||||
printwriter.println("ofCustomFonts:" + this.ofCustomFonts);
|
||||
printwriter.println("toggleSprint:" + toggleSprint);
|
||||
printwriter.println("leftHand:" + this.leftHand);
|
||||
|
||||
for (KeyBinding keybinding : this.keyBindings) {
|
||||
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
|
||||
|
@ -1934,7 +1965,9 @@ public class GameSettings {
|
|||
DYNAMIC_FOV("Dynamic FOV", false, false),
|
||||
MIPMAP_TYPE("Mipmap Type", true, false, 0.0F, 3.0F, 1.0F),
|
||||
BETTER_SNOW("Better Snow", false, false),
|
||||
CUSTOM_FONTS("Custom Fonts", false, false);
|
||||
CUSTOM_FONTS("Custom Fonts", false, false),
|
||||
TOGGLE_SPRINT("Sprint", false, false),
|
||||
LEFT_HAND("Main Hand", false, false);
|
||||
|
||||
private final boolean enumFloat;
|
||||
private final boolean enumBoolean;
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Set;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.PeytonPlayz585.shadow.Controller;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.IntHashMap;
|
||||
|
||||
|
@ -34,20 +35,28 @@ public class KeyBinding implements Comparable<KeyBinding> {
|
|||
private final String keyDescription;
|
||||
private final int keyCodeDefault;
|
||||
private final String keyCategory;
|
||||
private int keyCode;
|
||||
private boolean pressed;
|
||||
public int keyCode;
|
||||
public boolean pressed;
|
||||
private int pressTime;
|
||||
private int buttonID;
|
||||
|
||||
public static void onTick(int keyCode) {
|
||||
if (keyCode != 0) {
|
||||
KeyBinding keybinding = (KeyBinding) hash.lookup(keyCode);
|
||||
if (keybinding != null) {
|
||||
keybinding.updateButtonState();
|
||||
++keybinding.pressTime;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateButtonState() {
|
||||
if(Controller.isButtonPressed(buttonID)) {
|
||||
this.pressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setKeyBindState(int keyCode, boolean pressed) {
|
||||
if (keyCode != 0) {
|
||||
KeyBinding keybinding = (KeyBinding) hash.lookup(keyCode);
|
||||
|
@ -86,6 +95,18 @@ public class KeyBinding implements Comparable<KeyBinding> {
|
|||
keybindArray.add(this);
|
||||
hash.addKey(keyCode, this);
|
||||
keybindSet.add(category);
|
||||
buttonID = -1;
|
||||
}
|
||||
|
||||
public KeyBinding(int parButtonID, String description, int keyCode, String category) {
|
||||
this.keyDescription = description;
|
||||
this.keyCode = keyCode;
|
||||
this.keyCodeDefault = keyCode;
|
||||
this.keyCategory = category;
|
||||
keybindArray.add(this);
|
||||
hash.addKey(keyCode, this);
|
||||
keybindSet.add(category);
|
||||
buttonID = parButtonID;
|
||||
}
|
||||
|
||||
/**+
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.minecraft.util;
|
||||
|
||||
import net.PeytonPlayz585.shadow.Controller;
|
||||
import net.lax1dude.eaglercraft.v1_8.Display;
|
||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class MouseHelper {
|
|||
}
|
||||
|
||||
public void mouseXYChange() {
|
||||
this.deltaX = Mouse.getDX();
|
||||
this.deltaY = Mouse.getDY();
|
||||
this.deltaX = Mouse.getDX() + Controller.getCameraX();
|
||||
this.deltaY = Mouse.getDY() + Controller.getCameraY();
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@ package net.minecraft.util;
|
|||
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
import net.PeytonPlayz585.shadow.Controller;
|
||||
|
||||
/**+
|
||||
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||||
*
|
||||
|
@ -30,24 +32,26 @@ public class MovementInputFromOptions extends MovementInput {
|
|||
public void updatePlayerMoveState() {
|
||||
this.moveStrafe = 0.0F;
|
||||
this.moveForward = 0.0F;
|
||||
if (this.gameSettings.keyBindForward.isKeyDown()) {
|
||||
if (this.gameSettings.keyBindForward.isKeyDown() || Controller.isWalkingForward()) {
|
||||
++this.moveForward;
|
||||
}
|
||||
|
||||
if (this.gameSettings.keyBindBack.isKeyDown()) {
|
||||
if (this.gameSettings.keyBindBack.isKeyDown() || Controller.isWalkingBackward()) {
|
||||
--this.moveForward;
|
||||
}
|
||||
|
||||
if (this.gameSettings.keyBindLeft.isKeyDown()) {
|
||||
if (this.gameSettings.keyBindLeft.isKeyDown() || Controller.isWalkingLeft()) {
|
||||
++this.moveStrafe;
|
||||
}
|
||||
|
||||
if (this.gameSettings.keyBindRight.isKeyDown()) {
|
||||
if (this.gameSettings.keyBindRight.isKeyDown() || Controller.isWalkingRight()) {
|
||||
--this.moveStrafe;
|
||||
}
|
||||
|
||||
this.jump = this.gameSettings.keyBindJump.isKeyDown();
|
||||
this.sneak = this.gameSettings.keyBindSneak.isKeyDown();
|
||||
this.jump = this.gameSettings.keyBindJump.isKeyDown() || Controller.isJumping();
|
||||
this.sneak = this.gameSettings.keyBindSneak.isKeyDown() || Controller.isSneaking();
|
||||
Controller.unpressCrouch();
|
||||
Controller.unpressJump();
|
||||
if (this.sneak) {
|
||||
this.moveStrafe = (float) ((double) this.moveStrafe * 0.3D);
|
||||
this.moveForward = (float) ((double) this.moveForward * 0.3D);
|
||||
|
|
Loading…
Reference in New Issue
Block a user