Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d4ba2ef6d | ||
|
|
4e6398d7f1 | ||
|
|
c5791690f6 | ||
|
|
95916ca608 | ||
|
|
5f3a6cbc7d | ||
|
|
ef02ecf902 |
@@ -23,3 +23,5 @@ run
|
||||
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
|
||||
/mcmodsrepo
|
||||
+5
-4
@@ -4,24 +4,25 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle'
|
||||
|
||||
version = '1.0.3'
|
||||
group = 'de.skate702.craftingkeys' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'craftingkeys'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17)
|
||||
compileJava.options.encoding = "UTF-8"
|
||||
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
||||
mappings channel: 'official', version: '1.19'
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
@@ -68,7 +69,7 @@ minecraft {
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.16.5-36.2.20'
|
||||
minecraft 'net.minecraftforge:forge:1.19-41.0.62'
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package de.skate702.craftingkeys;
|
||||
|
||||
|
||||
import net.minecraft.client.gui.screen.EnchantmentScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.inventory.*;
|
||||
import net.minecraft.client.gui.screens.inventory.EnchantmentScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ExtensionPoint;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import de.skate702.craftingkeys.manager.*;
|
||||
@@ -16,6 +15,14 @@ import de.skate702.craftingkeys.util.Util;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.client.gui.screens.inventory.AnvilScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.BrewingStandScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.CraftingScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.DispenserScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.FurnaceScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
|
||||
|
||||
/**
|
||||
* The Main Class of the Mod with the important onTick-Method. Some Methods are
|
||||
* based on the open-source Inventory Tweaks. Big Thanks for that!
|
||||
@@ -37,7 +44,7 @@ public class CraftingKeys {
|
||||
instance = this;
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> "client side mod only", (remoteversionstring,networkbool) -> networkbool));
|
||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> "client side mod only", (remote, isServer) -> isServer));
|
||||
Logger.info("load(e)", "Registered Mod.");
|
||||
}
|
||||
|
||||
@@ -51,55 +58,55 @@ public class CraftingKeys {
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent tick) {
|
||||
|
||||
Screen currentScreen = Util.client.currentScreen;
|
||||
Screen currentScreen = Util.client.screen;
|
||||
|
||||
if (currentScreen != null) {
|
||||
|
||||
if (currentScreen instanceof CraftingScreen) {
|
||||
|
||||
ContainerManager con = CraftingManager.getInstance(
|
||||
((CraftingScreen) currentScreen).getContainer());
|
||||
((CraftingScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof InventoryScreen) {
|
||||
|
||||
ContainerManager con = InventoryManager.getInstance(
|
||||
((InventoryScreen) currentScreen).getContainer());
|
||||
((InventoryScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof MerchantScreen) {
|
||||
|
||||
ContainerManager con = VillagerManager.getInstance(
|
||||
((MerchantScreen) currentScreen).getContainer());
|
||||
((MerchantScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof FurnaceScreen) {
|
||||
|
||||
ContainerManager con = FurnaceManager.getInstance(
|
||||
((FurnaceScreen) currentScreen).getContainer());
|
||||
((FurnaceScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof DispenserScreen) {
|
||||
|
||||
ContainerManager con = DispenserManager.getInstance(
|
||||
((DispenserScreen) currentScreen).getContainer());
|
||||
((DispenserScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof BrewingStandScreen) {
|
||||
|
||||
ContainerManager con = BrewingManager.getInstance(
|
||||
((BrewingStandScreen) currentScreen).getContainer());
|
||||
((BrewingStandScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof EnchantmentScreen) {
|
||||
|
||||
ContainerManager con = EnchantmentManager.getInstance(
|
||||
((EnchantmentScreen) currentScreen).getContainer());
|
||||
((EnchantmentScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof AnvilScreen) {
|
||||
ContainerManager con = AnvilManager.getInstance(
|
||||
((AnvilScreen) currentScreen).getContainer());
|
||||
((AnvilScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.skate702.craftingkeys.config;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@@ -22,12 +22,12 @@ public class Config {
|
||||
private static int keyLowerLeft = KeyEvent.VK_Z;
|
||||
private static int keyLowerCenter = KeyEvent.VK_X;
|
||||
private static int keyLowerRight = KeyEvent.VK_C;
|
||||
private static int keyStack = Minecraft.getInstance().gameSettings.keyBindSneak.getKey().getKeyCode();
|
||||
private static int keyInteract = Minecraft.getInstance().gameSettings.keyBindSprint.getKey().getKeyCode();
|
||||
private static int keyStack = Minecraft.getInstance().options.keyShift.getKey().getValue();
|
||||
private static int keyInteract = Minecraft.getInstance().options.keySprint.getKey().getValue();
|
||||
private static final int keyDrop = KeyEvent.VK_SPACE;
|
||||
|
||||
public static boolean isKeyDown(int keyCode) {
|
||||
return InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), keyCode);
|
||||
return InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), keyCode);
|
||||
}
|
||||
|
||||
public static boolean isKeyTopLeftPressed() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Anvil GUI Inventory.
|
||||
@@ -14,7 +14,7 @@ public class AnvilManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private AnvilManager(Container container) {
|
||||
private AnvilManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class AnvilManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static AnvilManager getInstance(Container container) {
|
||||
public static AnvilManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new AnvilManager(container);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Brewing Stand GUI Inventory.
|
||||
@@ -15,7 +15,7 @@ public class BrewingManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private BrewingManager(Container container) {
|
||||
private BrewingManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BrewingManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static BrewingManager getInstance(Container container) {
|
||||
public static BrewingManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new BrewingManager(container);
|
||||
} else {
|
||||
|
||||
@@ -5,13 +5,13 @@ import de.skate702.craftingkeys.config.Config;
|
||||
import de.skate702.craftingkeys.util.InputUtil;
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import de.skate702.craftingkeys.util.Util;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.gui.screen.inventory.InventoryScreen;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Provides all needed methods to handle and manage a gui inventory. Does also provide frames for own implementations.
|
||||
@@ -21,14 +21,14 @@ public abstract class ContainerManager {
|
||||
/**
|
||||
* The Container to work with.
|
||||
*/
|
||||
Container container;
|
||||
AbstractContainerMenu container;
|
||||
|
||||
/**
|
||||
* Creates a new ContainerManager with the given container.
|
||||
*
|
||||
* @param container The container to work with
|
||||
*/
|
||||
ContainerManager(Container container) {
|
||||
ContainerManager(AbstractContainerMenu container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class ContainerManager {
|
||||
public void acceptKey() {
|
||||
|
||||
// Get hovered slot and goal slotIndex of pressed key (if pressed)
|
||||
Slot currentHoveredSlot = InputUtil.getSlotAtMousePosition(Util.client.currentScreen);
|
||||
Slot currentHoveredSlot = InputUtil.getSlotAtMousePosition(Util.client.screen);
|
||||
int slotIndex = specificKeyToSlotIndex();
|
||||
|
||||
// Handle accepted key
|
||||
@@ -61,7 +61,7 @@ public abstract class ContainerManager {
|
||||
!Util.isHoldingStack()) { // MOVE FROM SLOT
|
||||
|
||||
Logger.info("acceptKey()", "Key for index " + slotIndex + " pressed.");
|
||||
onSpecificKeyPressed(currentHoveredSlot.slotNumber, slotIndex);
|
||||
onSpecificKeyPressed(currentHoveredSlot.index, slotIndex);
|
||||
|
||||
|
||||
} else if (Util.isHoldingStack()) { // MOVE FROM HAND
|
||||
@@ -98,7 +98,7 @@ public abstract class ContainerManager {
|
||||
// Handles Interaction with items held
|
||||
// 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().sameItem(getItemStack(getInteractionSlotIndex()))
|
||||
|| Util.getHeldStack().getCount() + getItemStack(getInteractionSlotIndex()).getCount()
|
||||
> getItemStack(getInteractionSlotIndex()).getMaxStackSize())) {
|
||||
moveStackToInventory(-1);
|
||||
@@ -159,32 +159,32 @@ 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.player.openContainer.getInventory().size() - 9 - 1;
|
||||
int hotbarStartIndex = Util.client.player.containerMenu.getItems().size() - 9 - 1;
|
||||
|
||||
if (Util.client.currentScreen instanceof InventoryScreen) {
|
||||
if (Util.client.screen instanceof InventoryScreen) {
|
||||
hotbarStartIndex -= 1;
|
||||
}
|
||||
|
||||
int inputdelta;
|
||||
KeyBinding[] hotbar = Util.client.gameSettings.keyBindsHotbar;
|
||||
KeyMapping[] hotbar = Util.client.options.keyHotbarSlots;
|
||||
|
||||
if (Config.isKeyDown(hotbar[0].getKey().getKeyCode())) {
|
||||
if (Config.isKeyDown(hotbar[0].getKey().getValue())) {
|
||||
inputdelta = 1;
|
||||
} else if (Config.isKeyDown(hotbar[1].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[1].getKey().getValue())) {
|
||||
inputdelta = 2;
|
||||
} else if (Config.isKeyDown(hotbar[2].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[2].getKey().getValue())) {
|
||||
inputdelta = 3;
|
||||
} else if (Config.isKeyDown(hotbar[3].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[3].getKey().getValue())) {
|
||||
inputdelta = 4;
|
||||
} else if (Config.isKeyDown(hotbar[4].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[4].getKey().getValue())) {
|
||||
inputdelta = 5;
|
||||
} else if (Config.isKeyDown(hotbar[5].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[5].getKey().getValue())) {
|
||||
inputdelta = 6;
|
||||
} else if (Config.isKeyDown(hotbar[6].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[6].getKey().getValue())) {
|
||||
inputdelta = 7;
|
||||
} else if (Config.isKeyDown(hotbar[7].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[7].getKey().getValue())) {
|
||||
inputdelta = 8;
|
||||
} else if (Config.isKeyDown(hotbar[8].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[8].getKey().getValue())) {
|
||||
inputdelta = 9;
|
||||
} else {
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ public abstract class ContainerManager {
|
||||
// if there could not be meant another stack at mouse position. cool logic!
|
||||
if (!Util.isHoldingStack()) {
|
||||
|
||||
if (currentHoveredSlot == null || !currentHoveredSlot.getHasStack()) {
|
||||
if (currentHoveredSlot == null || !currentHoveredSlot.hasItem()) {
|
||||
Logger.info("handleNumKey()", "Trying output to hotbar speedup.");
|
||||
onInteractionKeyPressed();
|
||||
}
|
||||
@@ -306,13 +306,13 @@ public abstract class ContainerManager {
|
||||
int movedAmount = Math.min(amount, sourceSize);
|
||||
|
||||
// Clear goal slot (May fail on full inventory!); only available if not holdling
|
||||
if (destination != null && !source.isItemEqual(destination) && srcIndex >= 0) {
|
||||
if (destination != null && !source.sameItem(destination) && srcIndex >= 0) {
|
||||
moveStackToInventory(destIndex);
|
||||
destination = getItemStack(destIndex);
|
||||
}
|
||||
|
||||
// Move some
|
||||
if (destination == null || source.isItemEqual(destination)) {
|
||||
if (destination == null || source.sameItem(destination)) {
|
||||
|
||||
if (srcIndex >= 0) {
|
||||
leftClick(srcIndex);
|
||||
@@ -342,14 +342,14 @@ public abstract class ContainerManager {
|
||||
*/
|
||||
ItemStack getItemStack(int index) {
|
||||
|
||||
if (index >= 0 && index < container.inventorySlots.size()) {
|
||||
if (index >= 0 && index < container.slots.size()) {
|
||||
|
||||
Slot slot = (Slot) (container.inventorySlots.get(index));
|
||||
Slot slot = (Slot) (container.slots.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.getItem();
|
||||
|
||||
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.getItemFromBlock(Blocks.AIR)) {
|
||||
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.byBlock(Blocks.AIR)) {
|
||||
returnStack = null;
|
||||
}
|
||||
|
||||
@@ -425,12 +425,12 @@ public abstract class ContainerManager {
|
||||
private int calcInventoryDestination(ItemStack stackToMove) {
|
||||
|
||||
// First run: Try to find a nice stack to put items on additionally
|
||||
for (int i = getInventoryStartIndex(); i < container.inventorySlots.size(); i++) {
|
||||
for (int i = getInventoryStartIndex(); i < container.slots.size(); i++) {
|
||||
|
||||
ItemStack potentialGoalStack = getItemStack(i);
|
||||
|
||||
if (potentialGoalStack != null && stackToMove != null) {
|
||||
if (potentialGoalStack.isItemEqual(stackToMove)) {
|
||||
if (potentialGoalStack.sameItem(stackToMove)) {
|
||||
if (potentialGoalStack.getCount() + stackToMove.getCount() <= stackToMove.getMaxStackSize()) {
|
||||
return i;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ public abstract class ContainerManager {
|
||||
}
|
||||
|
||||
// Second run: Find a free slot
|
||||
for (int i = getInventoryStartIndex(); i < container.inventorySlots.size(); i++) {
|
||||
for (int i = getInventoryStartIndex(); i < container.slots.size(); i++) {
|
||||
if (getItemStack(i) == null) {
|
||||
return i;
|
||||
}
|
||||
@@ -493,7 +493,7 @@ public abstract class ContainerManager {
|
||||
|
||||
int rightClickData = (rightClick) ? 1 : 0;
|
||||
|
||||
CraftingKeys.proxy.sendSlotClick(Util.client.playerController, container.windowId, index,
|
||||
CraftingKeys.proxy.sendSlotClick(Util.client.gameMode, container.containerId, index,
|
||||
rightClickData, 0, Util.client.player);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Crafting GUI Inventory.
|
||||
@@ -15,7 +15,7 @@ public class CraftingManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private CraftingManager(Container container) {
|
||||
private CraftingManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CraftingManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static CraftingManager getInstance(Container container) {
|
||||
public static CraftingManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new CraftingManager(container);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Dispenser GUI Inventory.
|
||||
@@ -15,7 +15,7 @@ public class DispenserManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private DispenserManager(Container container) {
|
||||
private DispenserManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class DispenserManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static DispenserManager getInstance(Container container) {
|
||||
public static DispenserManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new DispenserManager(container);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Enchantment Table GUI Inventory.
|
||||
@@ -15,7 +15,7 @@ public class EnchantmentManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private EnchantmentManager(Container container) {
|
||||
private EnchantmentManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class EnchantmentManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static EnchantmentManager getInstance(Container container) {
|
||||
public static EnchantmentManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new EnchantmentManager(container);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Furnace GUI Inventory.
|
||||
@@ -15,7 +15,7 @@ public class FurnaceManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private FurnaceManager(Container container) {
|
||||
private FurnaceManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FurnaceManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static FurnaceManager getInstance(Container container) {
|
||||
public static FurnaceManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new FurnaceManager(container);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.skate702.craftingkeys.manager;
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Inventory GUI Inventory.
|
||||
@@ -15,7 +15,7 @@ public class InventoryManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private InventoryManager(Container container) {
|
||||
private InventoryManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class InventoryManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static InventoryManager getInstance(Container container) {
|
||||
public static InventoryManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new InventoryManager(container);
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.skate702.craftingkeys.manager;
|
||||
|
||||
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
||||
/**
|
||||
* Manages a Villager GUI Inventory.
|
||||
@@ -16,7 +16,7 @@ public class VillagerManager extends ContainerManager {
|
||||
*
|
||||
* @param container The container from a crafting GUI
|
||||
*/
|
||||
private VillagerManager(Container container) {
|
||||
private VillagerManager(AbstractContainerMenu container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class VillagerManager extends ContainerManager {
|
||||
* @param container A container from a GUI
|
||||
* @return manager-singleton
|
||||
*/
|
||||
public static VillagerManager getInstance(Container container) {
|
||||
public static VillagerManager getInstance(AbstractContainerMenu container) {
|
||||
if (instance == null) {
|
||||
instance = new VillagerManager(container);
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package de.skate702.craftingkeys.proxies;
|
||||
|
||||
import net.minecraft.client.multiplayer.PlayerController;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -24,9 +24,9 @@ public class CraftingKeysProxy {
|
||||
* @param player The current player (from Client)
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void sendSlotClick(PlayerController controller, int windowId, int slot, int rightClick, @SuppressWarnings("SameParameterValue") int action,
|
||||
PlayerEntity player) {
|
||||
controller.windowClick(windowId, slot, rightClick, ClickType.PICKUP, player);
|
||||
public void sendSlotClick(MultiPlayerGameMode controller, int windowId, int slot, int rightClick, @SuppressWarnings("SameParameterValue") int action,
|
||||
Player player) {
|
||||
controller.handleInventoryMouseClick(windowId, slot, rightClick, ClickType.PICKUP, player);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package de.skate702.craftingkeys.util;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
|
||||
/**
|
||||
* This class provides methods to interact with the Mouse and key input.
|
||||
@@ -27,8 +27,8 @@ public class InputUtil {
|
||||
* @return Returns the slot (or null)
|
||||
*/
|
||||
public static Slot getSlotAtMousePosition(Screen screen) {
|
||||
if (screen instanceof ContainerScreen) {
|
||||
return ((ContainerScreen) screen).getSlotUnderMouse();
|
||||
if (screen instanceof AbstractContainerScreen) {
|
||||
return ((AbstractContainerScreen) screen).getSlotUnderMouse();
|
||||
} else {
|
||||
Logger.debug("getSlotAtMousePosition(gui)", "guiContainer == null");
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.skate702.craftingkeys.util;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
|
||||
public class LanguageLocalizer {
|
||||
/**
|
||||
@@ -10,6 +10,6 @@ public class LanguageLocalizer {
|
||||
* @return localized The localized String
|
||||
*/
|
||||
public static String localize(String unloc) {
|
||||
return I18n.format(unloc);
|
||||
return I18n.get(unloc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package de.skate702.craftingkeys.util;
|
||||
|
||||
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Provides basic utility methods. For input methods, look at InputUtil.
|
||||
@@ -31,7 +32,7 @@ public class Util {
|
||||
* @return A item stack
|
||||
*/
|
||||
public static ItemStack getHeldStack() {
|
||||
return client.player.inventory.getItemStack();
|
||||
return ((AbstractContainerScreen<?>)client.screen).getMenu().getCarried();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,10 +50,10 @@ public class Util {
|
||||
* @return True, if this is the first tick
|
||||
*/
|
||||
public static boolean isFirstInWorldTick() {
|
||||
if (firstInWorldTick && client.world != null) {
|
||||
if (firstInWorldTick && client.level != null) {
|
||||
firstInWorldTick = false;
|
||||
return true;
|
||||
} else if (client.world == null) {
|
||||
} else if (client.level == null) {
|
||||
firstInWorldTick = true;
|
||||
}
|
||||
return false;
|
||||
@@ -64,8 +65,7 @@ public class Util {
|
||||
* @param lang_key key from lang-file
|
||||
*/
|
||||
public static void printMessage(String lang_key) {
|
||||
String translated = new TranslationTextComponent(lang_key).getUnformattedComponentText();
|
||||
client.player.sendChatMessage(translated);
|
||||
client.player.displayClientMessage(Component.translatable(lang_key), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml" #mandatory
|
||||
loaderVersion = "[36,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
loaderVersion = "[41,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
license = "All rights reserved"
|
||||
[[mods]] #mandatory
|
||||
modId = "craftingkeys" #mandatory
|
||||
@@ -14,12 +14,12 @@ description = "Simple better crafting! Crafing Keys enables new inventory key-bi
|
||||
[[dependencies.craftingkeys]] #optional
|
||||
modId = "forge" #mandatory
|
||||
mandatory = true #mandatory
|
||||
versionRange = "[36,)" #mandatory
|
||||
versionRange = "[41,)" #mandatory
|
||||
ordering = "NONE"
|
||||
side = "CLIENT"
|
||||
[[dependencies.craftingkeys]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.16.5,)"
|
||||
versionRange = "[1.19,)"
|
||||
ordering = "NONE"
|
||||
side = "CLIENT"
|
||||
|
||||
Reference in New Issue
Block a user