Merge pull request #16 from kirstymcnaught/v1_11

V1_11
This commit is contained in:
Sebastian
2017-06-05 16:42:00 +02:00
committed by GitHub
14 changed files with 67 additions and 106 deletions
@@ -1,20 +1,19 @@
package de.skate702.craftingkeys;
// NEW_1_8 cpw.mods.fml => net.minecraftforge.fml
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import de.skate702.craftingkeys.config.Config;
import de.skate702.craftingkeys.config.GuiConfig;
import de.skate702.craftingkeys.config.GuiConfigHandler;
@@ -102,9 +101,9 @@ public class CraftingKeys {
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (KeyBindings.openGuiBinding.isPressed()) {
Logger.info("onKeyInput(e)", "Open Crafting Keys Config Gui.");
Util.client.thePlayer.openGui(instance, GuiConfig.GuiID, Util.client.theWorld,
((int) Util.client.thePlayer.posX), (int) Util.client.thePlayer.posY,
(int) Util.client.thePlayer.posZ);
Util.client.player.openGui(instance, GuiConfig.GuiID, Util.client.world,
((int) Util.client.player.posX), (int) Util.client.player.posY,
(int) Util.client.player.posZ);
}
}
@@ -116,7 +115,7 @@ public class CraftingKeys {
*/
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
if (eventArgs.modID.equals(MODID)) { // NEW_1_9 modID => getModID()
if (eventArgs.getModID().equals(MODID)) {
Config.syncConfig();
Logger.info("onConfigChanged(e)", "Changed config.");
}
@@ -199,4 +198,4 @@ public class CraftingKeys {
}
}
}
}
@@ -1,8 +1,7 @@
package de.skate702.craftingkeys.config;
// NEW_1_8 cpw.mods.fml => net.minecraftforge.fml
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import de.skate702.craftingkeys.CraftingKeys;
import de.skate702.craftingkeys.util.Logger;
import net.minecraftforge.common.config.Configuration;
@@ -142,11 +142,11 @@ public class GuiConfig extends GuiScreen {
public void actionPerformed(GuiButton button) {
if (button.id == buttonAbortID) {
Logger.info("actionPerformed(b)", "Closing Crafting Keys GUI now!");
mc.thePlayer.closeScreen();
mc.player.closeScreen();
} else if (button.id == buttonSaveID) {
save();
Logger.info("actionPerformed(b)", "Saving & closing Crafting Keys GUI now!");
mc.thePlayer.closeScreen();
mc.player.closeScreen();
} else if (button.id >= 0 && button.id <= 11) {
if (selectedButtonID == -1) {
selectedButtonID = button.id;
@@ -229,18 +229,11 @@ public class GuiConfig extends GuiScreen {
mc.renderEngine.bindTexture(new ResourceLocation(CraftingKeys.MODID, "textures/gui/symbols.png"));
drawTexturedModalRect(guiShowBasePosX + 105, guiShowBasePosY + 17, 200, 0, 50, 50);
//NEW_1.11
/*
drawInfoString(0, 24, 21);
drawInfoString(4, 86, 63);
drawInfoString(3, 64, 56);
drawInfoString(5, 109, 56);
*/
drawInfoString(1, 86, 21);
drawInfoString(4, 86, 58);
drawInfoString(3, 63, 50);
drawInfoString(5, 109, 50);
}
private void genEnchantmentInfo() {
@@ -253,14 +246,8 @@ public class GuiConfig extends GuiScreen {
mc.renderEngine.bindTexture(new ResourceLocation(CraftingKeys.MODID, "textures/gui/symbols.png"));
drawTexturedModalRect(guiShowBasePosX + 105, guiShowBasePosY + 17, 150, 50, 50, 50);
//NEW_1.11
/*
drawInfoString(1, 22, 51);
drawInfoString(2, 42, 51);
*/
drawInfoString(1, 32, 51);
// NEW_1_8 drawInfoString(2, 42, 51);
}
@@ -306,19 +293,12 @@ public class GuiConfig extends GuiScreen {
mc.renderEngine.bindTexture(new ResourceLocation(CraftingKeys.MODID, "textures/gui/symbols.png"));
drawTexturedModalRect(guiShowBasePosX + 105, guiShowBasePosY + 17, 0, 0, 50, 50);
/* NEW_1_11
drawInfoString(1, 105, 22);
drawInfoString(2, 123, 22);
drawInfoString(4, 105, 40);
drawInfoString(5, 123, 40);
drawInfoString(9, 164, 32);
*/
drawInfoString(1, 95, 30);
drawInfoString(2, 113, 30);
drawInfoString(4, 95, 48);
drawInfoString(5, 113, 48);
drawInfoString(9, 151, 40);
}
private void genDispenserInfo() {
@@ -1,8 +1,7 @@
package de.skate702.craftingkeys.config;
// NEW_1_8 cpw.mods.fml => net.minecraftforge.fml
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -1,8 +1,7 @@
package de.skate702.craftingkeys.config;
// NEW_1_8 cpw.mods.fml => net.minecraftforge.fml
import cpw.mods.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraft.client.settings.KeyBinding;
import org.lwjgl.input.Keyboard;
@@ -36,8 +36,8 @@ public class BrewingManager extends ContainerManager {
@Override
protected int specificKeyToSlotIndex() {
//NEW_1.11 return mapKeyToSlot(4, 3, -1, 0, 1, 2, -1, -1, -1);
return mapKeyToSlot(-1, 3, -1, 0, 1, 2, -1, -1, -1);
//TODO: check for v1.11
return mapKeyToSlot(4, 3, -1, 0, 1, 2, -1, -1, -1);
}
@Override
@@ -6,9 +6,12 @@ import de.skate702.craftingkeys.util.InputUtil;
import de.skate702.craftingkeys.util.Logger;
import de.skate702.craftingkeys.util.Util;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
@@ -17,8 +20,6 @@ import org.lwjgl.input.Keyboard;
*/
public abstract class ContainerManager {
// NEW_1_11 stackSize is private. Use: func_190916_E()
/**
* The Container to work with.
*/
@@ -100,7 +101,7 @@ public abstract class ContainerManager {
// Stack up on hand if equal or small enough, else throw held stack away
if (Util.isHoldingStack() && getItemStack(getInteractionSlotIndex()) != null && (
!Util.getHeldStack().isItemEqual(getItemStack(getInteractionSlotIndex()))
|| Util.getHeldStack().stackSize + getItemStack(getInteractionSlotIndex()).stackSize
|| Util.getHeldStack().getCount() + getItemStack(getInteractionSlotIndex()).getCount()
> getItemStack(getInteractionSlotIndex()).getMaxStackSize())) {
moveStackToInventory(-1);
}
@@ -112,9 +113,9 @@ public abstract class ContainerManager {
interact();
while (Util.isHoldingStack() &&
oldStackSize != Util.getHeldStack().stackSize) {
oldStackSize != Util.getHeldStack().getCount()) {
oldStackSize = Util.getHeldStack().stackSize;
oldStackSize = Util.getHeldStack().getCount();
interact();
}
@@ -160,12 +161,11 @@ public abstract class ContainerManager {
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;
int hotbarStartIndex = Util.client.player.openContainer.getInventory().size() - 9 - 1;
// NEW_1_9 Player inventory Shield fix
//if (Util.client.currentScreen instanceof GuiInventory) {
// hotbarStartIndex -= 1;
//}
if (Util.client.currentScreen instanceof GuiInventory) {
hotbarStartIndex -= 1;
}
int inputdelta;
KeyBinding[] hotbar = Util.client.gameSettings.keyBindsHotbar;
@@ -286,7 +286,7 @@ public abstract class ContainerManager {
if (source == null) {
Logger.debug("moveAll(i,i)", "Source ItemStack from Index == null");
} else {
move(srcIndex, destIndex, source.stackSize);
move(srcIndex, destIndex, source.getCount());
}
}
@@ -313,7 +313,7 @@ public abstract class ContainerManager {
}
// Test for max. moving Amount
int sourceSize = source.stackSize;
int sourceSize = source.getCount();
int movedAmount = Math.min(amount, sourceSize);
// Clear goal slot (May fail on full inventory!); only available if not holdling
@@ -358,15 +358,13 @@ public abstract class ContainerManager {
Slot slot = (Slot) (container.inventorySlots.get(index));
// NEW_1_11 No Null-Stacks anymore. Empty Stacks with air...
/*ItemStack returnStack = (slot == null) ? null : slot.getStack();
ItemStack returnStack = (slot == null) ? null : slot.getStack();
if(returnStack.func_190916_E() == 0 && returnStack.getItem() == Item.getItemFromBlock(Blocks.AIR)) {
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.getItemFromBlock(Blocks.AIR)) {
returnStack = null;
}
return returnStack;*/
return (slot == null) ? null : slot.getStack();
return returnStack;
} else if (index == -1 && Util.isHoldingStack()) {
return Util.getHeldStack();
@@ -444,7 +442,7 @@ public abstract class ContainerManager {
if (potentialGoalStack != null && stackToMove != null) {
if (potentialGoalStack.isItemEqual(stackToMove)) {
if (potentialGoalStack.stackSize + stackToMove.stackSize <= stackToMove.getMaxStackSize()) {
if (potentialGoalStack.getCount() + stackToMove.getCount() <= stackToMove.getMaxStackSize()) {
return i;
}
}
@@ -507,7 +505,7 @@ public abstract class ContainerManager {
int rightClickData = (rightClick) ? 1 : 0;
CraftingKeys.proxy.sendSlotClick(Util.client.playerController, container.windowId, index,
rightClickData, 0, Util.client.thePlayer);
rightClickData, 0, Util.client.player);
}
@@ -36,15 +36,15 @@ public class EnchantmentManager extends ContainerManager {
@Override
protected int specificKeyToSlotIndex() {
return mapKeyToSlot(-1, 0, -1, -1, 0, -1, -1, -1, -1);
// NEW_1_8 return mapKeyToSlot(-1, 0, 1, -1, 0, 1, -1, -1, -1);
//TODO: check for v1.11
return mapKeyToSlot(-1, 0, 1, -1, 0, 1, -1, -1, -1);
}
@Override
protected int getInventoryStartIndex() {
return 1;
// NEW_1_8 return 2;
// TODO: check for v1.11
return 2;
}
@Override
@@ -54,8 +54,8 @@ public class EnchantmentManager extends ContainerManager {
@Override
protected int[] getDropSlots() {
return new int[]{0};
// NEW_1_8 return new int[] {0, 1};
//TODO: check for v1.11
return new int[] {0, 1};
}
@Override
@@ -36,9 +36,8 @@ public class InventoryManager extends ContainerManager {
@Override
protected int specificKeyToSlotIndex() {
return mapKeyToSlot(-1, 1, 2, -1, 3, 4, -1, -1, -1);
// NEW_1_9 return mapKeyToSlot(-1, 1, 2, 45, 3, 4, 45, -1, -1);
//TODO: check for v1.11
return mapKeyToSlot(-1, 1, 2, 45, 3, 4, 45, -1, -1);
}
@Override
@@ -1,9 +1,8 @@
package de.skate702.craftingkeys.proxies;
// NEW_1_9 import net.minecraft.inventory.ClickType;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ClickType;
/**
* Client Proxy, extending Common Proxy.
@@ -16,9 +15,7 @@ public class CraftingKeysClientProxy extends CraftingKeysProxy {
public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, int action,
EntityPlayer player) {
controller.windowClick(windowId, slot, rightClick, action, player);
// NEW_1_9 controller.func_187098_a(windowId, slot, rightClick, ClickType.PICKUP, player);
// NEW_1_11 controller.windowClick(windowId, slot, rightClick, ClickType.PICKUP, player);
controller.windowClick(windowId, slot, rightClick, ClickType.PICKUP, player);
}
}
@@ -1,9 +1,7 @@
package de.skate702.craftingkeys.proxies;
// NEW_1_8 cpw.mods.fml => net.minecraftforge.fml
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.EntityPlayer;
@@ -61,8 +61,8 @@ public class InputUtil {
// Constants from Minecraft Source Code
x -= (guiContainer.width - 176) / 2;
y -= (guiContainer.height - 166) / 2;
return x >= slot.xDisplayPosition - 1 && x < slot.xDisplayPosition + 16 + 1
&& y >= slot.yDisplayPosition - 1 && y < slot.yDisplayPosition + 16 + 1;
return x >= slot.xPos - 1 && x < slot.xPos + 16 + 1
&& y >= slot.yPos - 1 && y < slot.yPos + 16 + 1;
} else {
return false;
}
@@ -1,8 +1,6 @@
package de.skate702.craftingkeys.util;
//NEW_1_9: net.minecraft.util.text.translation.I18n;
//NEW_1_11: net.minecraft.client.resources.I18n;
import net.minecraft.util.StatCollector;
import net.minecraft.client.resources.I18n;
public class LanguageLocalizer {
/**
@@ -12,8 +10,6 @@ public class LanguageLocalizer {
* @return localized The localized String
*/
public static String localize(String unloc) {
//NEW_1_9 return I18n.translateToLocal(unloc);
//NEW_1_9.4: return I18n.format(unloc);
return StatCollector.translateToLocal(unloc);
return I18n.format(unloc);
}
}
@@ -1,12 +1,10 @@
package de.skate702.craftingkeys.util;
// NEW_1_8 cpw.mods.fml => net.minecraftforge.fml
// NEW_1_9 net.minecraft.util.text.TextComponentTranslation;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.text.TextComponentTranslation;
/**
* Provides basic utility methods. For input methods, look at InputUtil.
@@ -34,7 +32,7 @@ public class Util {
* @return A item stack
*/
public static ItemStack getHeldStack() {
return client.thePlayer.inventory.getItemStack();
return client.player.inventory.getItemStack();
}
/**
@@ -42,9 +40,8 @@ public class Util {
*
* @return True, if held stack != null
*/
public static boolean isHoldingStack() {
// NEW_1_11 return (getHeldStack().func_190916_E() != 0);
return (getHeldStack() != null);
public static boolean isHoldingStack() {
return (getHeldStack().getCount() > 0);
}
/**
@@ -53,10 +50,10 @@ public class Util {
* @return True, if this is the first tick
*/
public static boolean isFirstInWorldTick() {
if (firstInWorldTick && client.theWorld != null) {
if (firstInWorldTick && client.world != null) {
firstInWorldTick = false;
return true;
} else if (client.theWorld == null) {
} else if (client.world == null) {
firstInWorldTick = true;
}
return false;
@@ -68,8 +65,8 @@ public class Util {
* @param lang_key key from lang-file
*/
public static void printMessage(String lang_key) {
client.thePlayer.addChatMessage(new ChatComponentTranslation(lang_key));
// NEW_1_9 client.thePlayer.addChatMessage(new TextComponentTranslation(lang_key));
String translated = (new TextComponentTranslation(lang_key)).getUnformattedComponentText();
client.player.sendChatMessage(translated);
}
}