jopi
Попрошайка
- 1,421
- 30
- 260
Я знаю что тут были уже темы про эту проблему. Я их всех в какой раз пересмотрел И НИЧЕГО НЕ ПРОИСХОДИТ.
Наверное по этому я пишу эту тему не так-ли капитан очевидность который пишет мне что такие темы уже были...
Проблема заключается в том, что не открывается гуи через блок, на 1.5.2 работает, тут нет и опять, уже решал но потерял исходный код.
Код:
Наверное по этому я пишу эту тему не так-ли капитан очевидность который пишет мне что такие темы уже были...
Проблема заключается в том, что не открывается гуи через блок, на 1.5.2 работает, тут нет и опять, уже решал но потерял исходный код.
Код:
Viod:
package by.fxg.diverse;
import by.fxg.diverse.common.GuiHandler;
import by.fxg.diverse.common.ServerProxy;
import by.fxg.diverse.common.block.BlockRegistry;
import by.fxg.diverse.common.item.ItemRegistry;
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.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
@Mod(modid = "Viod", name = "Viod", version = "0.1")
public class Viod {
@Instance("Viod")
public static Viod instance;
@SidedProxy(clientSide = "by.fxg.diverse.client.ClientProxy", serverSide = "by.fxg.diverse.common.ServerProxy")
public static ServerProxy proxy;
public static BlockRegistry blocks;
public static ItemRegistry items;
public static GuiHandler guiHandler;
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
this.guiHandler = new GuiHandler();
this.items = new ItemRegistry().init();
this.blocks = new BlockRegistry().init();
NetworkRegistry.instance().registerGuiHandler(Viod.instance, new GuiHandler());
proxy.init();
}
}
GuiHandler:
package by.fxg.diverse.common;
import by.fxg.diverse.common.block.container.ContainerBlockPress;
import by.fxg.diverse.common.block.gui.GuiBlockPress;
import by.fxg.diverse.common.tile.TilePress;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
switch (ID) {
case 1000:
if (tile instanceof TilePress)
return new ContainerBlockPress(player.inventory, (TilePress)tile);
break;
default:
return null;
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
switch (ID) {
case 1000:
if (tile instanceof TilePress)
return new GuiBlockPress(player.inventory,(TilePress)tile);
break;
default:
return null;
}
return null;
}
}
Метод блока откуда вызываю код.:
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
if (par1World.isRemote) {
return true;
} else if (!par5EntityPlayer.isSneaking()) {
TilePress var10 = (TilePress) par1World.getBlockTileEntity(par2, par3, par4);
if (var10 != null) {
//Тайл есть и проверку эту проходит, уже проверял ранее. Строка ниже попросту не срабатывает и гуи не открывается.
par5EntityPlayer.openGui(Viod.instance, 1000, par1World, par2, par3, par4);
}
return true;
} else {
return false;
}
}