Jump to content

[Still need help] Gui with container, help!


PlatonCraft

Recommended Posts

There is an error.

 

i dont know what should i do

 

---- Minecraft Crash Report ----

// I bet Cylons wouldn't have this problem.

 

Time: 21.08.13 19:41

Description: Rendering screen

 

java.lang.ArrayIndexOutOfBoundsException: 2

at platon.mods.unenchant.TileEntityUnEnchTbl.getStackInSlot(TileEntityUnEnchTbl.java:25)

at net.minecraft.inventory.Slot.getStack(Slot.java:91)

at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:404)

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:150)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1036)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:934)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:826)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)

at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at platon.mods.unenchant.TileEntityUnEnchTbl.getStackInSlot(TileEntityUnEnchTbl.java:25)

at net.minecraft.inventory.Slot.getStack(Slot.java:91)

at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:404)

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:150)

 

-- Screen render details --

Details:

Screen name: platon.mods.unenchant.GuiUnEnchTbl

Mouse location: Scaled: (213, 119). Absolute: (427, 240)

Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player376'/313, l='MpServer', x=239,81, y=71,62, z=85,25]]

Chunk stats: MultiplayerChunkCache: 360

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: World: (240,64,124), Chunk: (at 0,4,12 in 15,7; contains blocks 240,0,112 to 255,255,127), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 231802 game time, 26783 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 109 total; [EntityClientPlayerMP['Player376'/313, l='MpServer', x=239,81, y=71,62, z=85,25], EntitySkeleton['Скелет'/71, l='MpServer', x=160,91, y=54,00, z=11,53], EntityCreeper['Крипер'/76, l='MpServer', x=175,50, y=30,00, z=114,50], EntityCreeper['Крипер'/77, l='MpServer', x=169,38, y=32,00, z=121,59], EntitySkeleton['Скелет'/72, l='MpServer', x=173,66, y=17,00, z=20,53], EntityChicken['Курица'/73, l='MpServer', x=163,53, y=67,00, z=22,78], EntityCow['Корова'/74, l='MpServer', x=167,81, y=70,00, z=74,66], EntityZombie['Зомби'/75, l='MpServer', x=163,69, y=16,00, z=88,63], EntityCreeper['Крипер'/85, l='MpServer', x=182,56, y=52,00, z=12,03], EntityCreeper['Крипер'/84, l='MpServer', x=184,69, y=51,00, z=11,56], EntitySheep['Овца'/87, l='MpServer', x=191,06, y=70,00, z=21,41], EntityBat['Летучая мышь'/86, l='MpServer', x=195,45, y=10,03, z=16,57], EntityCreeper['Крипер'/83, l='MpServer', x=178,43, y=54,81, z=12,61], EntityZombie['Зомби'/93, l='MpServer', x=190,09, y=26,00, z=113,50], EntitySkeleton['Скелет'/92, l='MpServer', x=176,34, y=30,00, z=112,69], EntitySilverfish['Чешуйница'/95, l='MpServer', x=186,89, y=71,00, z=116,81], EntitySkeleton['Скелет'/94, l='MpServer', x=187,69, y=26,00, z=112,50], EntityBat['Летучая мышь'/89, l='MpServer', x=175,57, y=16,59, z=71,70], EntitySkeleton['Скелет'/88, l='MpServer', x=184,25, y=13,00, z=61,78], EntitySkeleton['Скелет'/91, l='MpServer', x=179,61, y=28,00, z=110,36], EntitySkeleton['Скелет'/90, l='MpServer', x=183,50, y=34,00, z=68,50], EntityBat['Летучая мышь'/103, l='MpServer', x=193,25, y=31,10, z=7,75], EntitySilverfish['Чешуйница'/96, l='MpServer', x=188,72, y=71,00, z=125,51], EntitySkeleton['Скелет'/110, l='MpServer', x=201,31, y=50,00, z=41,66], EntityCow['Корова'/111, l='MpServer', x=196,78, y=71,00, z=103,81], EntityZombie['Зомби'/108, l='MpServer', x=204,28, y=39,00, z=21,84], EntitySpider['Паук'/109, l='MpServer', x=208,56, y=52,00, z=22,75], EntityBat['Летучая мышь'/106, l='MpServer', x=196,31, y=13,10, z=16,25], EntitySkeleton['Скелет'/107, l='MpServer', x=207,50, y=40,00, z=24,50], EntityBat['Летучая мышь'/104, l='MpServer', x=192,07, y=45,75, z=7,49], EntitySilverfish['Чешуйница'/112, l='MpServer', x=201,46, y=72,00, z=114,82], EntitySlime['Слизень'/125, l='MpServer', x=211,31, y=38,00, z=102,31], EntityCow['Корова'/124, l='MpServer', x=217,91, y=70,00, z=17,50], EntityCow['Корова'/123, l='MpServer', x=222,22, y=69,00, z=24,78], EntitySkeleton['Скелет'/122, l='MpServer', x=223,41, y=44,00, z=21,00], EntityCow['Корова'/121, l='MpServer', x=220,13, y=69,00, z=8,09], EntitySkeleton['Скелет'/120, l='MpServer', x=209,50, y=49,00, z=9,50], EntityZombie['Зомби'/137, l='MpServer', x=238,03, y=40,00, z=84,56], EntityZombie['Зомби'/136, l='MpServer', x=238,31, y=43,00, z=93,84], EntityCreeper['Крипер'/139, l='MpServer', x=239,00, y=47,00, z=99,72], EntitySkeleton['Скелет'/138, l='MpServer', x=240,09, y=37,00, z=95,50], EntityBat['Летучая мышь'/141, l='MpServer', x=231,47, y=37,10, z=107,25], EntityZombie['Зомби'/140, l='MpServer', x=236,50, y=45,00, z=97,16], EntitySilverfish['Чешуйница'/143, l='MpServer', x=224,21, y=71,00, z=103,59], EntityCow['Корова'/142, l='MpServer', x=236,50, y=70,00, z=108,53], EntitySquid['Спрут'/128, l='MpServer', x=220,53, y=60,00, z=148,47], EntitySkeleton['Скелет'/133, l='MpServer', x=227,50, y=51,00, z=14,50], EntityZombie['Зомби'/135, l='MpServer', x=233,06, y=51,00, z=18,59], EntitySkeleton['Скелет'/134, l='MpServer', x=228,94, y=51,00, z=16,53], EntityPig['Свинья'/152, l='MpServer', x=252,50, y=63,00, z=145,25], EntityCow['Корова'/153, l='MpServer', x=245,13, y=63,00, z=162,69], EntityZombie['Зомби'/155, l='MpServer', x=258,00, y=39,00, z=9,50], EntityZombie['Зомби'/156, l='MpServer', x=263,21, y=38,67, z=10,47], EntityBat['Летучая мышь'/157, l='MpServer', x=258,66, y=41,10, z=12,75], EntityBat['Летучая мышь'/158, l='MpServer', x=267,25, y=38,00, z=12,44], EntityZombie['Зомби'/144, l='MpServer', x=233,50, y=36,00, z=113,50], EntitySkeleton['Скелет'/150, l='MpServer', x=240,94, y=49,00, z=22,31], EntityZombie['Зомби'/151, l='MpServer', x=248,09, y=35,00, z=98,38], EntityOcelot['Оцелот'/163, l='MpServer', x=265,22, y=69,00, z=66,69], EntityPig['Свинья'/162, l='MpServer', x=264,50, y=71,00, z=62,47], EntitySkeleton['Скелет'/161, l='MpServer', x=262,50, y=64,00, z=44,06], EntityCow['Корова'/160, l='MpServer', x=270,97, y=65,00, z=13,53], EntityPig['Свинья'/167, l='MpServer', x=260,47, y=56,00, z=156,50], EntityZombie['Зомби'/166, l='MpServer', x=263,47, y=46,00, z=127,97], EntityCreeper['Крипер'/165, l='MpServer', x=268,31, y=45,29, z=117,69], EntitySkeleton['Скелет'/164, l='MpServer', x=271,63, y=19,00, z=121,88], EntitySkeleton['Скелет'/186, l='MpServer', x=275,22, y=20,00, z=125,56], EntityItem['item.item.rottenFlesh'/187, l='MpServer', x=276,69, y=67,13, z=122,09], EntityBat['Летучая мышь'/184, l='MpServer', x=283,34, y=52,00, z=107,51], EntityCreeper['Крипер'/185, l='MpServer', x=279,00, y=21,00, z=127,41], EntityCow['Корова'/190, l='MpServer', x=287,16, y=66,00, z=143,56], EntityPig['Свинья'/191, l='MpServer', x=272,47, y=71,00, z=140,06], EntityBat['Летучая мышь'/188, l='MpServer', x=283,24, y=20,50, z=128,79], EntityBat['Летучая мышь'/189, l='MpServer', x=285,41, y=48,72, z=129,75], EntityCreeper['Крипер'/178, l='MpServer', x=287,00, y=36,00, z=14,37], EntityCreeper['Крипер'/179, l='MpServer', x=286,72, y=36,00, z=15,75], EntityZombie['Зомби'/176, l='MpServer', x=285,09, y=33,00, z=7,41], EntityEnderman['Эндермен'/177, l='MpServer', x=284,28, y=35,00, z=13,59], EntitySkeleton['Скелет'/182, l='MpServer', x=278,53, y=26,00, z=34,69], EntityCow['Корова'/183, l='MpServer', x=275,69, y=73,00, z=57,47], EntitySkeleton['Скелет'/180, l='MpServer', x=282,52, y=55,00, z=5,55], EntityCreeper['Крипер'/181, l='MpServer', x=274,94, y=38,00, z=24,53], EntitySheep['Овца'/205, l='MpServer', x=294,75, y=63,00, z=89,94], EntitySheep['Овца'/204, l='MpServer', x=296,19, y=63,00, z=90,19], EntityBat['Летучая мышь'/207, l='MpServer', x=288,22, y=49,77, z=106,41], EntitySheep['Овца'/206, l='MpServer', x=298,19, y=63,00, z=87,19], EntitySheep['Овца'/201, l='MpServer', x=302,50, y=68,00, z=37,53], EntityCreeper['Крипер'/200, l='MpServer', x=291,63, y=36,00, z=16,66], EntitySheep['Овца'/203, l='MpServer', x=295,91, y=63,00, z=73,38], EntitySheep['Овца'/202, l='MpServer', x=303,81, y=67,00, z=35,53], EntityZombie['Зомби'/198, l='MpServer', x=293,54, y=34,00, z=2,93], EntityBat['Летучая мышь'/193, l='MpServer', x=278,31, y=62,38, z=156,36], EntityPig['Свинья'/192, l='MpServer', x=274,53, y=59,00, z=155,50], EntityPig['Свинья'/194, l='MpServer', x=277,91, y=64,00, z=157,34], EntitySheep['Овца'/220, l='MpServer', x=311,50, y=71,00, z=67,50], EntityPig['Свинья'/221, l='MpServer', x=305,53, y=63,00, z=84,59], EntitySheep['Овца'/222, l='MpServer', x=304,50, y=69,00, z=95,50], EntitySheep['Овца'/223, l='MpServer', x=316,53, y=71,00, z=90,84], EntityCow['Корова'/216, l='MpServer', x=308,91, y=63,00, z=32,13], EntityOcelot['Оцелот'/217, l='MpServer', x=304,51, y=63,54, z=31,64], EntitySheep['Овца'/218, l='MpServer', x=313,30, y=75,00, z=46,45], EntitySheep['Овца'/219, l='MpServer', x=318,53, y=71,00, z=77,47], EntityZombie['Зомби'/213, l='MpServer', x=318,55, y=26,00, z=7,97], EntityPig['Свинья'/214, l='MpServer', x=318,63, y=75,00, z=15,53], EntityCow['Корова'/215, l='MpServer', x=307,03, y=63,00, z=31,50], EntitySheep['Овца'/208, l='MpServer', x=303,50, y=69,00, z=97,50], EntityZombie['Зомби'/209, l='MpServer', x=290,50, y=48,00, z=130,03], EntityPig['Свинья'/225, l='MpServer', x=321,52, y=66,00, z=164,85], EntityPig['Свинья'/224, l='MpServer', x=305,78, y=70,00, z=125,75]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2298)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:844)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)

at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

-- System Details --

Details:

Minecraft Version: 1.6.2

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 788159232 bytes (751 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 17636 (987616 bytes; 0 MB) allocated, 1473 (82488 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 15, tcache: 0, allocated: 3, tallocated: 63

FML: MCP v8.04 FML v6.2.35.804 Minecraft Forge 9.10.0.804 8 mods loaded, 8 mods active

mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{6.2.35.804} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{9.10.0.804} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

CodeChickenCore{0.9.0.1}

[CodeChicken Core] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
NotEnoughItems{1.6.0.5} [Not Enough Items] (NotEnoughItems 1.6.0.5.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
IronChest{1.0} [iron Chests] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
flintstonetools{1.1.3a} [Flintstone Tools] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
unenchtbl{0.1.1} [unenchanting Table] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 6800 Series GL version 4.3.12414 Compatibility Profile Context 13.150.100.1000, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Pack: Default
Current Language: Р СѓСЃСЃРєРёР№ (Р РѕСЃСЃРёСЏ)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 1077 (60312 bytes; 0 MB) allocated, 316 (17696 bytes; 0 MB) used[/spoiler]
I found a tutorial, but i still dont know what should i do
here it is: http://www.minecraftforum.net/topic/1924178-forge-162-micros-furnace-tutorials/



[spoiler= Base]
package platon.mods.unenchant;

import platon.mods.flintstonetools.FlintBase;
import platon.mods.flintstonetools.ItemFlintHoe;
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.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.BaseMod;
import net.minecraft.src.ModLoader;
@Mod (modid = EnchantBase.modid, name = "Unenchanting Table", version = "0.1.1") 
@NetworkMod (clientSideRequired = true, serverSideRequired = false)
public class EnchantBase extends BaseMod{

public static Block unenchtbl = new BlockUnEnchTbl(648).setUnlocalizedName("unenchtbl");

public static final String modid = "unenchtbl";

public static EnchantBase instance = new EnchantBase();

@EventHandler
public void init(FMLInitializationEvent event)
{
GameRegistry.registerBlock(unenchtbl);
//GameRegistry.addRecipe(new ItemStack(FlintBase.flinthoe, 1), new Object[]{ " XX", " # ", " # ", Character.valueOf('X'), Item.flint, ('#'), Item.stick});
GameRegistry.registerTileEntity(TileEntityUnEnchTbl.class, "tileEntityUnEnchTbl");
LanguageRegistry.instance().addNameForObject(unenchtbl, "en_US", "Unenchantment Table");
LanguageRegistry.instance().addNameForObject(unenchtbl, "ru_RU", "Стол снятий зачарований");
ModLoader.registerContainerID(this, 1);
}

public GuiContainer getContainerGUI(EntityClientPlayerMP player,int id, int x, int y, int z)
{
switch(id){
	case 1:
		return new GuiUnEnchTbl (player, player.worldObj, x, y, z);
	default:
		return null;
}
}

public String getVersion(){return "0.1.1";}
public void load(){}
}

 

 

[spoiler=Block]

package platon.mods.unenchant;


import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockUnEnchTbl extends BlockContainer {

public BlockUnEnchTbl(int par1)
{
super(par1, Material.rock);
this.setHardness(3.0F);
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setResistance(5.0F);
this.setLightValue(0.0F);
}

@Override
public void registerIcons(IconRegister reg){
this.blockIcon = reg.registerIcon("unenchant:BlockUnEnchTbl");
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c)
{
TileEntityUnEnchTbl unenchtbl = (TileEntityUnEnchTbl) world.getBlockTileEntity(x, y, z);

if(player instanceof EntityPlayerMP && unenchtbl !=null)
{
	ModLoader.serverOpenWindow((EntityPlayerMP) player, new ContainerUnEnchTbl(player, world, x, y, z), 1, x, y, z);
}
else
{
	ModLoader.openGUI((EntityPlayerSP) player, new GuiUnEnchTbl(player, world, x, y, z));
}
return true;
}

public TileEntity createNewTileEntity(World par1World)
{
return new TileEntityUnEnchTbl();
}
}

 

 

 

[spoiler=TileEntity]

package platon.mods.unenchant;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntityUnEnchTbl extends TileEntity implements ISidedInventory {

ItemStack[] itemslots = new ItemStack[2];

private String localizedName;

public int playersCurrentlyUsingTbl;

private String StuffName;

public int getSizeInventory() {
	return this.itemslots.length;
}

public ItemStack getStackInSlot(int j) {
	return this.itemslots[j];
}

public ItemStack decrStackSize(int i, int j) {
	return null;
}

public ItemStack getStackInSlotOnClosing(int i) {
	return null;
}

public void setInventorySlotContents(int i, ItemStack itemstack) {

}

@Override
public void writeToNBT(NBTTagCompound nbt){
	super.writeToNBT(nbt);
	NBTTagList nbttaglist = new NBTTagList();

	for(int i = 0; i < this.itemslots.length; i++){
		if(this.itemslots[i] !=null){
			NBTTagCompound tag = new NBTTagCompound();
			tag.setByte("Slot", (byte) i);

			this.itemslots[i].writeToNBT(tag);

			nbttaglist.appendTag(tag);
		}
	}

	nbt.setTag("Stuff", nbttaglist);

	if(this.isInvNameLocalized()){
		nbt.setString("StuffName", this.StuffName);
	}
}
@Override
public void readFromNBT(NBTTagCompound nbt){
	super.readFromNBT(nbt);

	NBTTagList nbttaglist = nbt.getTagList("Stuff");
	this.itemslots = new ItemStack[this.getSizeInventory()];

	for(int i = 0; i < nbttaglist.tagCount(); i++){
		int var1 = nbt.getByte("Slot") & 255;

		if(var1 <= 0 && var1 < this.itemslots.length){
			this.itemslots[var1] = ItemStack.loadItemStackFromNBT(nbt);
		}
	}

	if(nbt.hasKey("StuffName")){
		this.StuffName = nbt.getString("StuffName");
	}
}

public String getInvName() {
	return this.isInvNameLocalized() ? this.localizedName : "container.UnEnchTbl";
}

public boolean isInvNameLocalized() {
	return this.localizedName != null && this.localizedName.length() > 0;
}

/**
 * Setting the localizedName Variable
 * @param localizedName
 */
public void func_94043_a(String par1Str){
	this.localizedName = par1Str;
}

public int getInventoryStackLimit() {
	return 64;
}

public boolean isUseableByPlayer(EntityPlayer entityplayer) {
	return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)xCoord+0.5D, (double)yCoord+0.5D, (double)zCoord+0.5D) <= 64.0D ;
}

public void openChest() {
}

public void closeChest() {

}

public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	return true;
}

public int[] getAccessibleSlotsFromSide(int var1) {
	return null;
}

public boolean canInsertItem(int i, ItemStack itemstack, int j) {
	return false;
}

public boolean canExtractItem(int i, ItemStack itemstack, int j) {
	return false;
}

}

 

 

 

[spoiler=Container]

package platon.mods.unenchant;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ContainerUnEnchTbl extends Container {

private IInventory itemSlot;

public ContainerUnEnchTbl(EntityPlayer player, World world, int x, int y, int z){
	TileEntityUnEnchTbl unenchtbl = (TileEntityUnEnchTbl) world.getBlockTileEntity(x, y, z);
	IInventory inv = player.inventory;

	for(int j = 0; j < unenchtbl.getSizeInventory();j++){
		inv.setInventorySlotContents(j, null);
	}

	for(int j = 0; j < unenchtbl.getSizeInventory();j++)
	{
		inv.setInventorySlotContents(j, unenchtbl.getStackInSlot(j));
	}

	this.itemSlot = unenchtbl;
	int var3;


		this.addSlotToContainer(new Slot(unenchtbl, 1, 14, 15));
		this.addSlotToContainer(new Slot(unenchtbl, 2, 14, 10));

         for (var3 = 0; var3 < 3; ++var3)
         {
                 for (int var4 = 0; var4 < 9; ++var4)
                 {
                         this.addSlotToContainer(new Slot(inv, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
                 }
         }
         for (var3 = 0; var3 < 9; ++var3)
         {
                 this.addSlotToContainer(new Slot(inv, var3, 8 + var3 * 18, 142));
         }
	}

public boolean canInteractWith(EntityPlayer entityplayer) {
	return this.itemSlot.isUseableByPlayer(entityplayer);
}

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
         ItemStack var3 = null;
         Slot var4 = (Slot)this.inventorySlots.get(par2);
         if (var4 != null && var4.getHasStack())
         {
                 ItemStack var5 = var4.getStack();
                 var3 = var5.copy();
                 if (par2 == 2)
                 {
                         if (!this.mergeItemStack(var5, 3, 39, true))
                         {
                                 return null;
                         }
                         var4.onSlotChange(var5, var3);
                 }
                 else if (par2 != 1 && par2 != 0)
                 {
                	 if (par2 >= 3 && par2 < 30)
                         {
                                 if (!this.mergeItemStack(var5, 30, 39, false))
                                 {
                                         return null;
                                 }
                         }
                         else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false))
                         {
                                 return null;
                         }
                 }
                 else if (!this.mergeItemStack(var5, 3, 39, false))
                 {
                         return null;
                 }
                 if (var5.stackSize == 0)
                 {
                         var4.putStack((ItemStack)null);
                 }
                 else
                 {
                         var4.onSlotChanged();
                 }
                 if (var5.stackSize == var3.stackSize)
                 {
                         return null;
                 }
                 var4.onPickupFromSlot(par1EntityPlayer, var5);
         }
         return var3;
}
}

 

 

[spoiler=Gui]

package platon.mods.unenchant;

import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiUnEnchTbl extends GuiContainer{

public GuiUnEnchTbl(EntityPlayer player, World world, int x, int y, int z) {

	super(new ContainerUnEnchTbl(player, world, x, y, z));

}

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
	this.fontRenderer.drawString("Стол Снятия Зачарований", 0, 0, 4210752);
	this.fontRenderer.drawString("Инвентарь", 0, 0, 4210752);
}

protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	this.mc.renderEngine.func_110577_a(new ResourceLocation("unenchant", "gui/unenchtblgui.png"));

	this.xSize=176;
	this.ySize=166;

	int var1 = (this.width-this.xSize)/2;
	int var2 = (this.height-this.ySize)/2;

	this.drawTexturedModalRect(var1, var2, 0, 0, this.xSize, this.ySize);
}

}

 

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

well start by posting the error...

 

 

Sorry, my bad. I have already. :)

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

You are genius, i am stupid. I thought that index is not should be in array.

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

I have one more question: When i put item to created by me slot it destoyes the item. how can i fix that?

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

I have one more question: When i put item to created by me slot it destoyes the item. how can i fix that?

You are opening your GUI wrongly. You need an IGUiHandler and then use EntityPlayer.openGui

 

 

I created following class

[spoiler=IGUIHandler]

package platon.mods.unenchant;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class GuiHandlerUnEnchant implements IGuiHandler
{
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
switch(id)
{
case 0: return new ContainerUnEnchTbl(player, world, x, y, z);
}
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
switch(id)
{
case 0: return new GuiUnEnchTbl(player, world, x, y, z);
}
return null;
}
}

 

 

 

How to register it? And where should i call EntityPlayer.openGui. Tell me fullly, please.

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

I did it. When i click any thing in inventory it doesnt moving and i getting error  "A mod tried to open a gui on the server without being a NetworkMod" And when come out yo menu there is an error

 

 

2013-08-22 00:41:17 [sEVERE] [ForgeModLoader] A TileEntity type platon.mods.unenchant.TileEntityUnEnchTbl has throw an exception trying to write state. It will not persist. Report this to the mod author

java.lang.IllegalArgumentException: Empty string not allowed

at net.minecraft.nbt.NBTTagString.<init>(NBTTagString.java:24)

at net.minecraft.nbt.NBTTagCompound.setString(NBTTagCompound.java:145)

at platon.mods.unenchant.TileEntityUnEnchTbl.writeToNBT(TileEntityUnEnchTbl.java:60)

at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:317)

at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:127)

at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:232)

at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:284)

at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:897)

at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:358)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:591)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

 

I fixed it by setting  "private String StuffName" equal to "StuffName". Now error dissapeared but I do not know whether it was possible to do so.

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

What i need to do to be a @NetworkMod

 

I have @NetworkMod (clientSideRequired = true, serverSideRequired = false) this.

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

[spoiler=EnchantBase]

package platon.mods.unenchant;

 

import platon.mods.flintstonetools.FlintBase;

import platon.mods.flintstonetools.ItemFlintHoe;

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.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;

import cpw.mods.fml.common.network.NetworkRegistry;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraft.block.Block;

import net.minecraft.client.entity.EntityClientPlayerMP;

import net.minecraft.client.gui.inventory.GuiContainer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.src.BaseMod;

import net.minecraft.src.ModLoader;

import net.minecraftforge.common.Configuration;

@Mod (modid = EnchantBase.modid, name = "Unenchanting", version = "0.1.1")

@NetworkMod (clientSideRequired = true, serverSideRequired = false)

public class EnchantBase extends BaseMod{

 

@Instance("EnchantBase")

public static EnchantBase instance = new EnchantBase();

 

public static Block unenchtbl = new BlockUnEnchTbl(648).setUnlocalizedName("unenchtbl");

 

public static final String modid = "EnchantBase";

 

public static String unenchtblname = "Unenchantment Table";

 

private GuiHandlerUnEnchant guiHandler = new GuiHandlerUnEnchant();

 

@EventHandler

public void preinit(FMLPreInitializationEvent event)

{

Configuration config = new Configuration(event.getSuggestedConfigurationFile());

config.load();

config.addCustomCategoryComment("unenchtbl", "You may change the default name of Unenchantment Table to whatever you want");

unenchtblname = config.get("unenchtbl", "unenchtbllocalizedname", unenchtblname).getString();

config.save();

}

 

@EventHandler

public void init(FMLInitializationEvent event)

{

GameRegistry.registerBlock(unenchtbl);

//GameRegistry.addRecipe(new ItemStack(FlintBase.flinthoe, 1), new Object[]{ " XX", " # ", " # ", Character.valueOf('X'), Item.flint, ('#'), Item.stick});

GameRegistry.registerTileEntity(TileEntityUnEnchTbl.class, "tileEntityUnEnchTbl");

LanguageRegistry.addName(unenchtbl, unenchtblname);

LanguageRegistry.instance().addNameForObject(unenchtbl, "ru_RU", "Стол снятия зачарований");

ModLoader.registerContainerID(this, 1);

NetworkRegistry.instance().registerGuiHandler(this, guiHandler);

 

if (unenchtbl.getLocalizedName() == "Стол снятия зачарований"){

TileEntityUnEnchTbl.func_94043_a(unenchtblname);

}

else{

    TileEntityUnEnchTbl.func_94043_a("Стол снятия зачаровани");

}

}

 

public GuiContainer getContainerGUI(EntityClientPlayerMP player,int id, int x, int y, int z)

{

switch(id){

case 1:

return new GuiUnEnchTbl (player, player.worldObj, x, y, z);

default:

return null;

}

}

 

public String getVersion(){return "0.1.1";}

public void load(){}

}

 

 

 

[spoiler=Block]

package platon.mods.unenchant;


import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockUnEnchTbl extends BlockContainer {

public BlockUnEnchTbl(int par1)
{
super(par1, Material.rock);
this.setHardness(3.0F);
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setResistance(5.0F);
this.setLightValue(0.0F);
}

@Override
public void registerIcons(IconRegister reg){
this.blockIcon = reg.registerIcon("unenchant:BlockUnEnchTbl");
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c)
{
TileEntityUnEnchTbl unenchtbl = (TileEntityUnEnchTbl) world.getBlockTileEntity(x, y, z);
if(player instanceof EntityPlayerMP && unenchtbl !=null)
{
	player.openGui(EnchantBase.modid, 1, world, x, y, z);
	ModLoader.serverOpenWindow((EntityPlayerMP) player, new ContainerUnEnchTbl(player, world, x, y, z), 1, x, y, z);
}
else
{
	ModLoader.openGUI((EntityPlayerSP) player, new GuiUnEnchTbl(player, world, x, y, z));
}
return true;
}

public TileEntity createNewTileEntity(World par1World)
{
return new TileEntityUnEnchTbl();
}
}

 

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

But if i'll delete all ModLoader strings, what should i paste instead of them?

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Now my OnBlockUse is

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c)
{
player.openGui(EnchantBase.instance, 1, world, x, y, z);
return true;
}

I didn't changed anything else

When i click my block, animation does but gui doesn't opens and no errors

What should i change also?

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

I copied OnBlockActivated from tutorial, now in opens, but when i open it , items from first and second slot disappears.

When i trying to put item to my own slots in blocks they're also disappears

 

My code in archive https://mega.co.nz/#!jccCwKJL!aZ1C0jbz_KFPz-9SaNJQ41TWESxUy7h5BDrO6SdEhwM

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

I changed id from 0 to 1 which i registereg and block stopped to open completely

I registering id with this  "ModLoader.registerContainerID(this, 1);"

 

I changed 0 to 1 in GuiHandler, problem is pre previous. Things disapperars

 

http://pastebin.com/ttPWwvji

http://pastebin.com/nSMjqfFF

http://pastebin.com/2As32ubj

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

removed, nothing changed.

 

I fixed one problem. Now the only problem is when i put something to slots in block(both of them) that disappears

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

I fixed a half of second problem. Now i can put items in the slots, but i cant get 'em out of slots  :)  :)

 

[spoiler=TileEntity]

package platon.mods.unenchant;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntityUnEnchTbl extends TileEntity implements ISidedInventory {

ItemStack[] itemslots = new ItemStack[2];

public static String localizedName;

public int getSizeInventory() {
	return this.itemslots.length;
}

public ItemStack getStackInSlot(int i) {
	return this.itemslots[i];
}

public ItemStack decrStackSize(int i, int j) {
	return null;
}

public ItemStack getStackInSlotOnClosing(int i) {
	return null;
}

public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
	this.itemslots[par1] = par2ItemStack;
        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
                par2ItemStack.stackSize = this.getInventoryStackLimit();
        }
}

public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
         super.readFromNBT(par1NBTTagCompound);
         NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");
         this.itemslots = new ItemStack[this.getSizeInventory()];
         for (int i = 0; i < nbttaglist.tagCount(); ++i)
         {
                 NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                 byte b0 = nbttagcompound1.getByte("Slot");
                 if (b0 >= 0 && b0 < this.itemslots.length)
                 {
                         this.itemslots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                 }
         }
         
         if (par1NBTTagCompound.hasKey("CustomName"))
         {
                 this.localizedName = par1NBTTagCompound.getString("CustomName");
         }
}
/**
         * Writes a tile entity to NBT.
         */
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
         super.writeToNBT(par1NBTTagCompound);
         NBTTagList nbttaglist = new NBTTagList();
         for (int i = 0; i < this.itemslots.length; ++i)
         {
                 if (this.itemslots[i] != null)
                 {
                         NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                         nbttagcompound1.setByte("Slot", (byte)i);
                         this.itemslots[i].writeToNBT(nbttagcompound1);
                         nbttaglist.appendTag(nbttagcompound1);
                 }
         }
         par1NBTTagCompound.setTag("Items", nbttaglist);
         if (this.isInvNameLocalized())
         {
                 par1NBTTagCompound.setString("CustomName", this.localizedName);
         }
}


public String getInvName() {
	return this.isInvNameLocalized() ? this.localizedName : "container.UnEnchTbl";
}

public boolean isInvNameLocalized() {
	return this.localizedName != null && this.localizedName.length() > 0;
}

/**
 * Setting the localizedName Variable
 * @param localizedName
 */
public static void func_94043_a(String par1Str){
	localizedName = par1Str;
}

public int getInventoryStackLimit() {
	return 1;
}

public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
         return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}

public void openChest() {
}

public void closeChest() {

}

public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	return true;
}

public int[] getAccessibleSlotsFromSide(int var1) {
	return null;
}

public boolean canInsertItem(int i, ItemStack itemstack, int j) {
	return true;
}

public boolean canExtractItem(int i, ItemStack itemstack, int j) {
	return true;
}

}

 

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Just implement? and what inventory? which class is it?

I misunderstood what i need to write to code and where.

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Your inventory is your TileEntity. You have the method implemented but it just returns null.

 

Hah thanks man, i have one more problem i want to put to second slot only books and nothing else. How can i make it?

 

I writed that String and it doesn't work. Or i should call it from somewhere?

	public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	return i == 0 ? true : (itemslots[i].getItem().itemID == ItemBook.book.itemID);
}

For that time i want to put if first slot with id 0 anything.

 

Also i writed that expression

	public int[] getAccessibleSlotsFromSide(int par1) {
	if (par1 == 0)
		return slot_top;
	else
		return slot_bottom;
}

Is it useful? And what it does?

 

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

You have to make a Slot subclass and use that instead. In there override isItemValid.

 

Am i need to create new SlotUnEnchTbl class that extends TileEntity? Or it must extends the Slot class. Am i need to replace

this.addSlotToContainer(new Slot(unenchtbl, 1, 16, 49));

to

this.addSlotToContainer(new SlotUnEnchTbl(unenchtbl, 1, 16, 49));

??

 

 

And in http://www.minecraftforum.net/topic/1924178-forge-162-micros-furnace-tutorials/ tutorial guy doesn't creates any Slot class, but he has definition that in bottom slot you can put only permitted things (they're also in the TileEntity class)

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Doesn't works.  :( 

 

[spoiler=My TileEntity]

package platon.mods.unenchant;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntityUnEnchTbl extends TileEntity implements ISidedInventory {

ItemStack[] itemslots = new ItemStack[2];

public static String localizedName;

private static final int[] slot_top = {0};
private static final int[] slot_bottom = {1};

public int getSizeInventory() {
	return this.itemslots.length;
}

public ItemStack getStackInSlot(int i) {
	return this.itemslots[i];
}

public ItemStack decrStackSize(int par1, int par2)
{
         if (this.itemslots[par1] != null)
         {
                 ItemStack itemstack;
                 if (this.itemslots[par1].stackSize <= par2)
                 {
                         itemstack = this.itemslots[par1];
                         this.itemslots[par1] = null;
                         return itemstack;
                 }
                 else
                 {
                         itemstack = this.itemslots[par1].splitStack(par2);
                         if (this.itemslots[par1].stackSize == 0)
                         {
                                 this.itemslots[par1] = null;
                         }
                         return itemstack;
                 }
         }
         else
         {
                 return null;
         }
}

public ItemStack getStackInSlotOnClosing(int par1) {
        if (this.itemslots[par1] != null)
        {
                ItemStack itemstack = this.itemslots[par1];
                this.itemslots[par1] = null;
                return itemstack;
        }
        else
        {
                return null;
        }
}

public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
	this.itemslots[par1] = par2ItemStack;
        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
                par2ItemStack.stackSize = this.getInventoryStackLimit();
        }
}

public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
         super.readFromNBT(par1NBTTagCompound);
         NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");
         this.itemslots = new ItemStack[this.getSizeInventory()];
         for (int i = 0; i < nbttaglist.tagCount(); ++i)
         {
                 NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                 byte b0 = nbttagcompound1.getByte("Slot");
                 if (b0 >= 0 && b0 < this.itemslots.length)
                 {
                         this.itemslots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                 }
         }
         
         if (par1NBTTagCompound.hasKey("CustomName"))
         {
                 this.localizedName = par1NBTTagCompound.getString("CustomName");
         }
}
/**
         * Writes a tile entity to NBT.
         */
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
         super.writeToNBT(par1NBTTagCompound);
         NBTTagList nbttaglist = new NBTTagList();
         for (int i = 0; i < this.itemslots.length; ++i)
         {
                 if (this.itemslots[i] != null)
                 {
                         NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                         nbttagcompound1.setByte("Slot", (byte)i);
                         this.itemslots[i].writeToNBT(nbttagcompound1);
                         nbttaglist.appendTag(nbttagcompound1);
                 }
         }
         par1NBTTagCompound.setTag("Items", nbttaglist);
         if (this.isInvNameLocalized())
         {
                 par1NBTTagCompound.setString("CustomName", this.localizedName);
         }
}


public String getInvName() {
	return this.isInvNameLocalized() ? this.localizedName : "container.UnEnchTbl";
}

public boolean isInvNameLocalized() {
	return this.localizedName != null && this.localizedName.length() > 0;
}

/**
 * Setting the localizedName Variable
 * @param localizedName
 */
public static void func_94043_a(String par1Str){
	localizedName = par1Str;
}

public int getInventoryStackLimit() {
	return 1;
}

public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
         return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}

public void openChest() {
}

public void closeChest() {

}

public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) {
	return par2ItemStack != null ? par2ItemStack.getItem().itemID == Item.book.itemID : false;
}

public int[] getAccessibleSlotsFromSide(int par1) {
	if (par1 == 0)
		return slot_top;
	else
		return slot_bottom;
}

public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3){
	return isItemValidForSlot(1, par2ItemStack);
}

public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) {
	return isItemValidForSlot(1, par2ItemStack);
}

}

 

 

I want to put only books in second slot with id 1.  By the way if i set canInsertItem and canExtractItem to false, i still may put and take things. What should i do to make it work?

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Now I think that these methods are for calling only. Thing that i wanted isn't very important to me. So I'll ask another question if I'll get in trouble

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Now I've got a problem

I created my own method is TileEntity

	public void UnEnchantment ()
{
	if (isItemValidForSlot(0, this.itemslots[0]))
	{
		System.out.println("HAHA!!");
	}
	else
	{
		System.out.println("Crying!!");
	}
}

 

And it doesn't works. I ain't see my Strings in console or anywhere else. What shoud i do to make mod call it?

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) {
	return par1 == 1 && par2ItemStack != null ? par2ItemStack.getItem().itemID == Item.book.itemID : false;
}

 

Like that? Anyway, nevermind. It doesn't important for me. I'm just begian learning java. So my knowledge is small. i know how to call my own method. I don't know where from should i call it.

[spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler][spoiler=Spoiler]LOL,Its nothing interesting here

[spoiler=Spoiler]And here too

[spoiler=Spoiler]But that image is pretty good

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.