mirror of
https://github.com/GTNewHorizons/MouseTweaks.git
synced 2026-11-20 12:09:37 +00:00
Updated to Minecraft 1.7.10, little code cleanup, fixed some minor bugs. Mouse Tweaks 2.4.4.
This commit is contained in:
1 parent
f7390768cf
commit
dbf0a2141e
8 files changed
+36
-48
No files matched your search
@@ -1,9 +1,6 @@
|
||||
package yalter.mousetweaks;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Config {
|
||||
@@ -37,7 +34,12 @@ public class Config {
|
||||
|
||||
public boolean saveConfig() {
|
||||
try {
|
||||
FileWriter configWriter = new FileWriter(fileName);
|
||||
File config = new File(fileName);
|
||||
File parentDir = config.getParentFile();
|
||||
if (!parentDir.exists())
|
||||
parentDir.mkdirs();
|
||||
|
||||
FileWriter configWriter = new FileWriter(config);
|
||||
properties.store(configWriter, null);
|
||||
configWriter.close();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class Constants {
|
||||
public static final String ISMOUSEOVERSLOT_NAME = "a";
|
||||
public static final String FIELDE_NAME = "H";
|
||||
public static final String FIELDq_NAME = "t";
|
||||
public static final String MCPROFILER_NAME = "A";
|
||||
public static final String MCPROFILER_NAME = "z";
|
||||
|
||||
// Forge obfuscated names
|
||||
public static final String ISMOUSEOVERSLOT_FORGE_NAME = "func_146981_a";
|
||||
@@ -18,7 +18,10 @@ public class Constants {
|
||||
public static final String MCPROFILER_FORGE_NAME = "field_71424_I";
|
||||
|
||||
// MCP names - these are the same as Forge ones for the most part
|
||||
public static final String MCPROFILER_MCP_NAME = "mcProfiler";
|
||||
public static final String ISMOUSEOVERSLOT_MCP_NAME = "isMouseOverSlot";
|
||||
public static final String FIELDE_MCP_NAME = "ignoreMouseUp";
|
||||
public static final String FIELDq_MCP_NAME = "dragSplitting";
|
||||
public static final String MCPROFILER_MCP_NAME = "mcProfiler";
|
||||
|
||||
// OnTick methods
|
||||
public static final String ONTICKMETHOD_FORGE_NAME = "Forge";
|
||||
|
||||
@@ -7,10 +7,8 @@ import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
@@ -54,7 +52,7 @@ public class DeobfuscationLayer {
|
||||
}
|
||||
|
||||
protected static Container getContainer(GuiContainer guiContainer) {
|
||||
return guiContainer.field_147002_h;
|
||||
return guiContainer.inventorySlots;
|
||||
}
|
||||
|
||||
protected static List<?> getSlots(Container container) {
|
||||
@@ -69,18 +67,6 @@ public class DeobfuscationLayer {
|
||||
return (slot == null) ? null : slot.getStack();
|
||||
}
|
||||
|
||||
protected static int getItemStackID(ItemStack itemStack) {
|
||||
return Item.getIdFromItem(itemStack.getItem());
|
||||
}
|
||||
|
||||
protected static boolean hasSubtypesItemStack(ItemStack itemStack) {
|
||||
return itemStack.getHasSubtypes();
|
||||
}
|
||||
|
||||
protected static int getItemStackItemDamage(ItemStack itemStack) {
|
||||
return itemStack.getItemDamage();
|
||||
}
|
||||
|
||||
protected static int getWindowId(Container container) {
|
||||
return container.windowId;
|
||||
}
|
||||
@@ -101,10 +87,6 @@ public class DeobfuscationLayer {
|
||||
return getThePlayer().inventory;
|
||||
}
|
||||
|
||||
protected static GameSettings getGameSettings() {
|
||||
return mc.gameSettings;
|
||||
}
|
||||
|
||||
protected static int getDisplayWidth() {
|
||||
return mc.displayWidth;
|
||||
}
|
||||
@@ -139,13 +121,11 @@ public class DeobfuscationLayer {
|
||||
|
||||
protected static boolean areStacksCompatible(ItemStack itemStack1, ItemStack itemStack2) {
|
||||
return ((itemStack1 == null) || (itemStack2 == null))
|
||||
|| ((getItemStackID(itemStack1) == getItemStackID(itemStack2))
|
||||
&& (!hasSubtypesItemStack(itemStack1)
|
||||
|| (getItemStackItemDamage(itemStack1) == getItemStackItemDamage(itemStack2))));
|
||||
|| itemStack1.isItemEqual(itemStack2);
|
||||
}
|
||||
|
||||
protected static boolean isMouseOverSlot(GuiContainer guiContainer, Slot slot) {
|
||||
return (Boolean) Reflection.guiContainerClass.invokeMethod(guiContainer, "isMouseOverSlot", slot, getRequiredMouseX(), getRequiredMouseY());
|
||||
return (Boolean) Reflection.guiContainerClass.invokeMethod(guiContainer, Constants.ISMOUSEOVERSLOT_FORGE_NAME, slot, getRequiredMouseX(), getRequiredMouseY());
|
||||
}
|
||||
|
||||
protected static Slot getSelectedSlot(GuiContainer guiContainer, Container container, int slotCount) {
|
||||
@@ -169,20 +149,16 @@ public class DeobfuscationLayer {
|
||||
}
|
||||
|
||||
protected static int getRequiredMouseX() {
|
||||
ScaledResolution var8 = new ScaledResolution(getGameSettings(), getDisplayWidth(),
|
||||
ScaledResolution var8 = new ScaledResolution(mc, getDisplayWidth(),
|
||||
getDisplayHeight());
|
||||
int var9 = var8.getScaledWidth();
|
||||
return (Mouse.getX() * var9) / getDisplayWidth();
|
||||
}
|
||||
|
||||
protected static int getRequiredMouseY() {
|
||||
ScaledResolution var8 = new ScaledResolution(getGameSettings(), getDisplayWidth(),
|
||||
ScaledResolution var8 = new ScaledResolution(mc, getDisplayWidth(),
|
||||
getDisplayHeight());
|
||||
int var10 = var8.getScaledHeight();
|
||||
return var10 - ((Mouse.getY() * var10) / getDisplayHeight()) - 1;
|
||||
}
|
||||
|
||||
protected static void sendClientMessage(String message) {
|
||||
getThePlayer().sendChatMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,8 @@ public class Main extends DeobfuscationLayer {
|
||||
if (Mouse.isButtonDown(1)) { // Right mouse button
|
||||
if ((Main.RMBTweak == 1) && !Main.DisableRMBTweak) {
|
||||
|
||||
if ((stackOnMouse != null) && areStacksCompatible(stackOnMouse, targetStack)) {
|
||||
if ((stackOnMouse != null) && areStacksCompatible(stackOnMouse, targetStack)
|
||||
&& !isCraftingOutputSlot(currentScreen, selectedSlot)) {
|
||||
if ((firstSlot != null) && !firstSlotClicked) {
|
||||
firstSlotClicked = true;
|
||||
disableRMBDragWithID(currentScreen);
|
||||
@@ -353,8 +354,13 @@ public class Main extends DeobfuscationLayer {
|
||||
clickSlot(currentScreen, selectedSlot, 0, true);
|
||||
} else { // If shift is not down, we need to merge the item stack on the mouse with the one in the slot.
|
||||
if ((getItemStackSize(stackOnMouse) + getItemStackSize(targetStack)) <= getMaxItemStackSize(stackOnMouse)) {
|
||||
clickSlot(currentScreen, selectedSlot, 0, false); // We need to click on the slot so that our item stack gets merged with
|
||||
clickSlot(currentScreen, selectedSlot, 0, false); // it, and then click again to return the stack to the mouse.
|
||||
// We need to click on the slot so that our item stack gets merged with it,
|
||||
// and then click again to return the stack to the mouse.
|
||||
// However, if the slot is crafting output, then the item is added to the mouse stack
|
||||
// on the first click and we don't need to click the second time.
|
||||
clickSlot(currentScreen, selectedSlot, 0, false);
|
||||
if (!isCraftingOutputSlot(currentScreen, selectedSlot))
|
||||
clickSlot(currentScreen, selectedSlot, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Reflection {
|
||||
guiContainerClass.storeClass("GuiContainer", GuiContainer.class);
|
||||
|
||||
Method isMouseOverSlot = getMethod(GuiContainer.class,
|
||||
getObfuscatedName(Constants.ISMOUSEOVERSLOT_FORGE_NAME, Constants.ISMOUSEOVERSLOT_FORGE_NAME, Constants.ISMOUSEOVERSLOT_NAME), Slot.class, int.class,
|
||||
getObfuscatedName(Constants.ISMOUSEOVERSLOT_MCP_NAME, Constants.ISMOUSEOVERSLOT_FORGE_NAME, Constants.ISMOUSEOVERSLOT_NAME), Slot.class, int.class,
|
||||
int.class);
|
||||
|
||||
if (isMouseOverSlot == null) {
|
||||
@@ -37,11 +37,11 @@ public class Reflection {
|
||||
return false;
|
||||
}
|
||||
|
||||
guiContainerClass.storeMethod("isMouseOverSlot", isMouseOverSlot);
|
||||
guiContainerClass.storeMethod(Constants.ISMOUSEOVERSLOT_FORGE_NAME, isMouseOverSlot);
|
||||
|
||||
Field field;
|
||||
field = getField(GuiContainer.class,
|
||||
getObfuscatedName(Constants.FIELDE_FORGE_NAME, Constants.FIELDE_FORGE_NAME, Constants.FIELDE_NAME));
|
||||
getObfuscatedName(Constants.FIELDE_MCP_NAME, Constants.FIELDE_FORGE_NAME, Constants.FIELDE_NAME));
|
||||
|
||||
if (field == null) {
|
||||
Logger.Log("Failed to retrieve the E field, disabling RMBTweak");
|
||||
@@ -50,7 +50,7 @@ public class Reflection {
|
||||
guiContainerClass.storeField(Constants.FIELDE_FORGE_NAME, field);
|
||||
|
||||
field = getField(GuiContainer.class,
|
||||
getObfuscatedName(Constants.FIELDq_FORGE_NAME, Constants.FIELDq_FORGE_NAME, Constants.FIELDq_NAME));
|
||||
getObfuscatedName(Constants.FIELDq_MCP_NAME, Constants.FIELDq_FORGE_NAME, Constants.FIELDq_NAME));
|
||||
|
||||
if (field == null) {
|
||||
Logger.Log("Failed to retreive the q field, disabling RMBTweak");
|
||||
|
||||
Reference in new issue
Block a user