mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Fix multiple GUI containers for ML containers. Sorry ultimatechest that
this fix took so long, a bug report at github.com/cpw/FML would help, next time ;)
This commit is contained in:
1 parent
853f54bcc2
commit
1a232cf766
2 files changed
+31
-10
No files matched your search
@@ -1,21 +1,27 @@
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class ModLoaderGuiHelper implements IGuiHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
private int id;
|
||||
private Set<Integer> ids;
|
||||
private Container container;
|
||||
private int currentID;
|
||||
|
||||
ModLoaderGuiHelper(BaseModProxy mod, int id)
|
||||
ModLoaderGuiHelper(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
this.id = id;
|
||||
this.ids = Sets.newHashSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,9 +36,10 @@ public class ModLoaderGuiHelper implements IGuiHandler
|
||||
return ModLoaderHelper.getClientSideGui(mod, player, ID, x, y, z);
|
||||
}
|
||||
|
||||
public void injectContainer(Container container)
|
||||
public void injectContainerAndID(Container container, int ID)
|
||||
{
|
||||
this.container = container;
|
||||
this.currentID = ID;
|
||||
}
|
||||
|
||||
public Object getMod()
|
||||
@@ -40,4 +47,9 @@ public class ModLoaderGuiHelper implements IGuiHandler
|
||||
return mod;
|
||||
}
|
||||
|
||||
public void associateId(int additionalID)
|
||||
{
|
||||
this.ids.add(additionalID);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,8 +20,10 @@ import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -60,7 +62,8 @@ public class ModLoaderHelper
|
||||
{
|
||||
public static IModLoaderSidedHelper sidedHelper;
|
||||
|
||||
private static Map<Integer, ModLoaderGuiHelper> guiHelpers = Maps.newHashMap();
|
||||
private static Map<BaseModProxy, ModLoaderGuiHelper> guiHelpers = Maps.newHashMap();
|
||||
private static Map<Integer, ModLoaderGuiHelper> guiIDs = Maps.newHashMap();
|
||||
|
||||
public static void updateStandardTicks(BaseModProxy mod, boolean enable, boolean useClock)
|
||||
{
|
||||
@@ -161,15 +164,21 @@ public class ModLoaderHelper
|
||||
|
||||
public static void buildGuiHelper(BaseModProxy mod, int id)
|
||||
{
|
||||
ModLoaderGuiHelper handler = new ModLoaderGuiHelper(mod, id);
|
||||
guiHelpers.put(id, handler);
|
||||
NetworkRegistry.instance().registerGuiHandler(mod, handler);
|
||||
ModLoaderGuiHelper handler = guiHelpers.get(mod);
|
||||
if (handler == null)
|
||||
{
|
||||
handler = new ModLoaderGuiHelper(mod);
|
||||
guiHelpers.put(mod,handler);
|
||||
NetworkRegistry.instance().registerGuiHandler(mod, handler);
|
||||
}
|
||||
handler.associateId(id);
|
||||
guiIDs.put(id, handler);
|
||||
}
|
||||
|
||||
public static void openGui(int id, EntityPlayer player, Container container, int x, int y, int z)
|
||||
{
|
||||
ModLoaderGuiHelper helper = guiHelpers.get(id);
|
||||
helper.injectContainer(container);
|
||||
ModLoaderGuiHelper helper = guiIDs.get(id);
|
||||
helper.injectContainerAndID(container, id);
|
||||
player.openGui(helper.getMod(), id, player.field_70170_p, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user