[RELEASE] 1.7.10 BETA1-Release ready. Code cleanup and inspection.

This commit is contained in:
0xSeb
2015-11-25 22:34:30 +01:00
parent 9d3ef44db7
commit dc54ca0a01
12 changed files with 47 additions and 125 deletions
@@ -45,6 +45,7 @@ public class CraftingKeys {
/**
* Current Instance of CraftingKeys.
*/
@SuppressWarnings("WeakerAccess")
@Instance(value = MODID)
public static CraftingKeys instance;
@@ -89,10 +90,12 @@ public class CraftingKeys {
*
* @param event Input Event from FML
*/
@SuppressWarnings("EmptyMethod")
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
@SuppressWarnings("UnusedParameters")
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (KeyBindings.openGuiBinding.isPressed()) {
@@ -122,6 +125,7 @@ public class CraftingKeys {
*
* @param event Some Forge input event
*/
@SuppressWarnings({"EmptyMethod", "UnusedParameters"})
@SubscribeEvent
public void onGuiOpened(GuiOpenEvent event) {
//if (event.gui instanceof GuiMainMenu) {
@@ -134,6 +138,7 @@ public class CraftingKeys {
*
* @param tick This is a tick. What did you think about it?
*/
@SuppressWarnings("UnusedParameters")
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent tick) {
@@ -184,7 +189,7 @@ public class CraftingKeys {
((GuiEnchantment) currentScreen).inventorySlots);
con.acceptKey();
} else if (currentScreen instanceof GuiRepair){
} else if (currentScreen instanceof GuiRepair) {
ContainerManager con = AnvilManager.getInstance(
((GuiRepair) currentScreen).inventorySlots);
con.acceptKey();
@@ -16,35 +16,32 @@ public class Config {
/**
* Defines the config string for the keys-category.
*/
protected static final String categoryKeys = "keys";
private static final String categoryKeys = "keys";
/**
* Defines the config string for the other-category.
*/
protected static final String categoryOther = "other";
private static final String categoryOther = "other";
/**
* Standard Return Key if there is a problem reading the config.
*/
private static final int retDefKey = -1;
/**
* Provides the Suggested Config File.
*/
protected static Configuration configFile = null;
/**
* Defines all 11 Keys you can use with Crafting Keys.
*/
protected static Property keyTopLeft, keyTopCenter, keyTopRight,
static Property keyTopLeft, keyTopCenter, keyTopRight,
keyCenterLeft, keyCenterCenter, keyCenterRight,
keyLowerLeft, keyLowerCenter, keyLowerRight,
keyStack, keyInteract, keyDrop;
/**
* Provides the Suggested Config File.
*/
private static Configuration configFile = null;
/**
* Defines, if NumPad is always active for crafting.
*/
protected static Property enableNumPad;
private static Property enableNumPad;
public static boolean isKeyTopLeftPressed() {
return Keyboard.isKeyDown(keyTopLeft.getInt(retDefKey)) || isNumPadEnabled() && Keyboard.isKeyDown(71);
@@ -94,7 +91,7 @@ public class Config {
return Keyboard.isKeyDown(keyDrop.getInt(retDefKey));
}
public static boolean isNumPadEnabled() {
private static boolean isNumPadEnabled() {
return enableNumPad.getBoolean(true);
}
@@ -1,51 +0,0 @@
package de.skate702.craftingkeys.config;
import cpw.mods.fml.client.config.DummyConfigElement;
import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.IConfigElement;
import de.skate702.craftingkeys.CraftingKeys;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.ConfigElement;
import java.util.ArrayList;
import java.util.List;
/**
* Custom Config Gui for Mod Options inside of Minecraft.
*/
@Deprecated
public class ConfigGui extends GuiConfig {
public ConfigGui(GuiScreen parent) {
super(parent, getConfigElements(),
CraftingKeys.MODID, false, false, CraftingKeys.NAME);
}
/**
* Generates Config Entires based on the main config file.
*
* @return A List of IConfigElement-Items, ready to add to the gui.
*/
private static List<IConfigElement> getConfigElements() {
List<IConfigElement> list = new ArrayList<IConfigElement>();
list.add(categoryElement(Config.categoryKeys, Config.categoryKeys, "de.skate702.craftingkeys.config.keys"));
list.add(categoryElement(Config.categoryOther, Config.categoryOther, "de.skate702.craftingkeys.config.other"));
return list;
}
/**
* Automatically generates category elements for config categories.
*
* @param category the given category string (from the config file)
* @param name the name of the category
* @param tooltip_key a lang-string, must have tooltip available under .tooltip
* @return Returns a IConfigElement ready to add to the list of elements
*/
private static IConfigElement categoryElement(String category, String name, String tooltip_key) {
return new DummyConfigElement.DummyCategoryElement(name, tooltip_key,
new ConfigElement<java.util.List<cpw.mods.fml.client.config.IConfigElement>>
(Config.configFile.getCategory(category)).getChildElements());
}
}
@@ -1,33 +0,0 @@
package de.skate702.craftingkeys.config;
import cpw.mods.fml.client.IModGuiFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import java.util.Set;
/**
* A Config Gui Factory which always returns the ConfigGUI-Class. Nothing more to see here, go away!
*/
@Deprecated
public class ConfigGuiFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) {
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return ConfigGui.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
@@ -21,6 +21,8 @@ public class GuiConfig extends GuiScreen {
private static final Color pureWhite = new Color(255, 255, 255, 255);
private static final Color lightGray = new Color(128, 128, 128, 255);
private static final Color highlight = new Color(86, 144, 72, 255);
private final int buttonSaveID = 901;
private final int buttonAbortID = 902;
/**
* 0,1,2 = top,
* 3,4,5 = mid,
@@ -37,8 +39,7 @@ public class GuiConfig extends GuiScreen {
private int guiShowState;
private long lastTime = 0;
private long currentTime;
private int buttonSaveID = 901;
private int buttonAbortID = 902;
@SuppressWarnings("FieldCanBeLocal")
private ArrayList<GuiButton> configButtons;
private int selectedButtonID = -1;
@@ -371,7 +372,7 @@ public class GuiConfig extends GuiScreen {
}
}
public void showNextGui() {
private void showNextGui() {
switch (guiShowState) {
case 0:
guiShowType = GuiType.FURNACE;
@@ -11,7 +11,7 @@ public class KeyBindings {
private static final String category = "craftingkeys.binding.cat";
public static KeyBinding openGuiBinding = new KeyBinding("craftingkeys.binding.opengui",
public static final KeyBinding openGuiBinding = new KeyBinding("craftingkeys.binding.opengui",
Keyboard.KEY_K, category);
/**
@@ -19,14 +19,14 @@ public abstract class ContainerManager {
/**
* The Container to work with.
*/
protected Container container;
Container container;
/**
* Creates a new ContainerManager with the given container.
*
* @param container The container to work with
*/
protected ContainerManager(Container container) {
ContainerManager(Container container) {
this.container = container;
}
@@ -78,7 +78,8 @@ public abstract class ContainerManager {
/**
* Handles what to do when the DropKey is pressed in acceptKey().
*/
protected void onDropKeyPressed() {
@SuppressWarnings("WeakerAccess")
void onDropKeyPressed() {
// Drop every defined dropSlot-Item
for (int i : getDropSlots()) {
@@ -90,7 +91,7 @@ public abstract class ContainerManager {
/**
* Handles what to do when the InteractionKey is pressed in acceptKey().
*/
protected void onInteractionKeyPressed() {
void onInteractionKeyPressed() {
// Handles Interaction with items held
// Stack up on hand if equal or small enough, else throw held stack away
@@ -126,7 +127,7 @@ public abstract class ContainerManager {
* @param currentHoveredSlot the slot number of the currently hovered Slot (mouse hover)
* @param slotIndex the slot index returned from the key input calculation
*/
protected void onSpecificKeyPressed(int currentHoveredSlot, int slotIndex) {
void onSpecificKeyPressed(int currentHoveredSlot, int slotIndex) {
if (Config.isKeyStackPressed()) {
moveAll(currentHoveredSlot, slotIndex);
@@ -142,7 +143,7 @@ public abstract class ContainerManager {
*
* @param slotIndex the slot index returned from the key input calculation
*/
protected void onHolding(int slotIndex) {
void onHolding(int slotIndex) {
onSpecificKeyPressed(-1, slotIndex);
@@ -150,9 +151,10 @@ public abstract class ContainerManager {
/**
* Handles what to do with NumKey-Inputs while holding a item.
* @param currentHoveredSlot
*
* @param currentHoveredSlot slot where the mouse is right now
*/
protected void handleNumKey(Slot currentHoveredSlot) {
void handleNumKey(Slot currentHoveredSlot) {
// hotbar-slots are always the last 9 slots of the currently opened inventory
int hotbarStartIndex = Util.client.thePlayer.openContainer.getInventory().size() - 9 - 1;
@@ -229,9 +231,9 @@ public abstract class ContainerManager {
* @param lowerRight lower-right slot index
* @return a slot index. wow!
*/
protected int mapKeyToSlot(int topLeft, int topCenter, int topRight,
int centerLeft, int centerCenter, int centerRight,
int lowerLeft, int lowerCenter, int lowerRight) {
int mapKeyToSlot(int topLeft, int topCenter, int topRight,
int centerLeft, int centerCenter, int centerRight,
int lowerLeft, int lowerCenter, int lowerRight) {
if (Config.isKeyTopLeftPressed()) {
return topLeft;
@@ -267,7 +269,7 @@ public abstract class ContainerManager {
* @param srcIndex The Source Slot Index of the Container
* @param destIndex The Destination Slot Index of the Container
*/
protected void moveAll(int srcIndex, int destIndex) {
void moveAll(int srcIndex, int destIndex) {
ItemStack source = getItemStack(srcIndex);
@@ -287,7 +289,7 @@ public abstract class ContainerManager {
* @param destIndex The Destination Slot Index of the Container
* @param amount The amount of items to move (can be bigger then Stack Size)
*/
protected void move(int srcIndex, int destIndex, int amount) {
void move(int srcIndex, int destIndex, int amount) {
// Stacks
ItemStack source = getItemStack(srcIndex);
@@ -339,7 +341,7 @@ public abstract class ContainerManager {
* @param index The index of the slot in the container
* @return Returns the ItemStack
*/
protected ItemStack getItemStack(int index) {
ItemStack getItemStack(int index) {
if (index >= 0 && index < container.inventorySlots.size()) {
@@ -362,7 +364,7 @@ public abstract class ContainerManager {
*
* @param sourceIndex A slot index of the source items
*/
protected void moveStackToInventory(int sourceIndex) {
void moveStackToInventory(int sourceIndex) {
// Moving Stack
ItemStack stackToMove = null;
@@ -459,7 +461,7 @@ public abstract class ContainerManager {
*
* @param index The index of the slot in the container
*/
protected void leftClick(int index) {
void leftClick(int index) {
slotClick(index, false);
}
@@ -468,7 +470,7 @@ public abstract class ContainerManager {
*
* @param index The index of the slot in the container
*/
protected void rightClick(int index) {
void rightClick(int index) {
slotClick(index, true);
}
@@ -478,7 +480,7 @@ public abstract class ContainerManager {
* @param index The index of the slot in the container
* @param rightClick True, if the click is with the right mouse button
*/
protected void slotClick(int index, boolean rightClick) {
private void slotClick(int index, boolean rightClick) {
Logger.info("slotClick(i,b)", "Clicked @ Slot " + index + " with data " + rightClick + ".");
@@ -23,7 +23,7 @@ public class CraftingKeysProxy {
* @param player The current player (from Client)
*/
@SideOnly(Side.CLIENT)
public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, int action,
public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, @SuppressWarnings("SameParameterValue") int action,
EntityPlayer player) {
}
@@ -64,6 +64,7 @@ public class Logger {
* @param method The calling method / method info
* @param message The message to print
*/
@SuppressWarnings("SameParameterValue")
public static void error(String method, String message) {
if (MODE.getLevel() <= 3) {
print(method, message, LevelOfDetail.ERROR);
@@ -13,7 +13,7 @@ public class Util {
/**
* Current Instance Client, used for a lot of operations.
*/
public static Minecraft client = FMLClientHandler.instance().getClient();
public static final Minecraft client = FMLClientHandler.instance().getClient();
/**
* Only used by isFirstInWorldTick()
*/
@@ -27,6 +27,7 @@ public class Util {
/**
* Returns the current held item stack.
*
* @return A item stack
*/
public static ItemStack getHeldStack() {
@@ -35,6 +36,7 @@ public class Util {
/**
* Returns if the current player is helding a item stack.
*
* @return True, if held stack != null
*/
public static boolean isHoldingStack() {
+2 -2
View File
@@ -2,10 +2,10 @@
{
"modid": "craftingkeys",
"name": "Crafting Keys",
"description": "Simple better crafting! You can change the Key Bindings by clicking on Config.",
"description": "Simple better crafting! Crafing Keys enables new inventory key-bindings to speed up your crafting.",
"version": "1.0.0",
"credits": "Based on the open-source InvTweaks-Mod. Thanks a lot!",
"mcversion": "1.7.10 - 1.8",
"mcversion": "1.7.10 or newer",
"url": "http://skate702.de",
"authorList": [ "skate702", "0xSeb" ]
}