Jump to content

Recommended Posts

Posted

There is an error.

 

i dont know what should i do

 

  Reveal hidden contents

 

 

[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

 

 

 

 

 

 

 

 

 

 

 

 

Posted
  On 8/21/2013 at 3:40 PM, hydroflame said:

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted
  On 8/21/2013 at 7:24 PM, diesieben07 said:

  Quote

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

  Reveal hidden contents

 

 

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

[spoiler=EnchantBase]

  Quote
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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted
  On 8/21/2013 at 10:37 PM, PlatonCraft said:

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);"

Remove that, it is useless.

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted
  On 8/22/2013 at 9:08 AM, diesieben07 said:

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted
  On 8/22/2013 at 9:57 AM, diesieben07 said:

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

Use the itemstack argument...itemstack!=null?itemstack.getItem().itemID==...

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

Posted

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

 

 

 

 

 

 

 

 

 

 

 

 

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm developing a Forge mod for Minecraft 1.16.5 to run on CatServer (version 1.16.5-1d8d6313, Forge 36.2.39). My mod needs to get the player's UUID from a ServerPlayerEntity object within a Forge ServerChatEvent handler. When I use serverPlayerEntity.getUUID(), my mod compiles fine, but I get a java.lang.NoSuchMethodError: net.minecraft.entity.player.ServerPlayerEntity.getUUID()Ljava/util/UUID; at runtime. I cannot use serverPlayerEntity.getUniqueID() as it causes a compile error (cannot find symbol). Is there a known issue with this on CatServer, or a recommended way for a Forge mod to reliably get a player's UUID from ServerPlayerEntity in this environment? My goal is to pass this UUID to the LuckPerms API (which is running as a Bukkit plugin and successfully connected via ServicesManager). erorr ChatMod: FMLServerStartedEvent received. Attempting to initialize LuckPerms connection... [22:45:20] [Server thread/INFO]: ⚙️ Початок ініціалізації LuckPerms API через Bukkit Services Manager... [22:45:20] [Server thread/INFO]: ✅ Bukkit ServicesManager успішно отримано. [22:45:20] [Server thread/INFO]: ✅ Реєстрацію сервісу LuckPerms знайдено. [22:45:20] [Server thread/INFO]: ✅ API LuckPerms успішно отримано від Bukkit plugin! [22:45:20] [Server thread/INFO]: Використовується реалізація: me.lucko.luckperms.common.api.LuckPermsApiProvider [22:45:20] [Server thread/INFO]: ✅ LuckPerms API схоже що успішно ініціалізовано через Bukkit Services Manager. [22:45:24] [User Authenticator #1/INFO]: UUID of player Hiklee is 92cd7721-2652-3867-896b-2ceba5b99306 [22:45:25] [Server thread/INFO]: Using new advancement loading for net.minecraft.advancements.PlayerAdvancements@24cb7a68 [22:45:26] [Server thread/INFO]: Hiklee[/127.0.0.1:41122] logged in with entity id 210 at (92.23203876864889, 95.6183020148442, 68.24087802017877) [22:45:28] [Async Chat Thread - #0/INFO]: ✅ Скасовано стандартне відправлення чату! [22:45:28] [Async Chat Thread - #0/ERROR]: Exception caught during firing event: net.minecraft.entity.player.ServerPlayerEntity.getUUID()Ljava/util/UUID; Index: 1 Listeners: 0: NORMAL 1: ASM: class com.example.chatmod.ChatEventHandler onPlayerChat(Lnet/minecraftforge/event/ServerChatEvent;)V java.lang.NoSuchMethodError: net.minecraft.entity.player.ServerPlayerEntity.getUUID()Ljava/util/UUID; at com.example.chatmod.ChatPacketHandler.getPlayerPrefix(ChatPacketHandler.java:46) at com.example.chatmod.ChatEventHandler.onPlayerChat(ChatEventHandler.java:32) at net.minecraftforge.eventbus.ASMEventHandler_1_ChatEventHandler_onPlayerChat_ServerChatEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:303) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) at net.minecraftforge.common.ForgeHooks.onServerChatEvent(ForgeHooks.java:493) at net.minecraft.network.play.ServerPlayNetHandler.chat(ServerPlayNetHandler.java:1717) at net.minecraft.network.play.ServerPlayNetHandler.func_244548_c(ServerPlayNetHandler.java:1666) at net.minecraft.network.play.ServerPlayNetHandler.func_147354_a(ServerPlayNetHandler.java:1605) at net.minecraft.network.play.client.CChatMessagePacket.lambda$handle$0(CChatMessagePacket.java:34) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750
    • Thank you so much for your help, I'll try it as soon as I can. I have a genuine question because I'm not familiar with the matter: Can a recipe error cause something as serious as the AMD error?
    • When i try to launch my modpack, the instance crashes and this is sent to the logs: Time: 2025-05-27 23:07:18 Description: Rendering overlay Below is the full log: https://mclo.gs/jP5G2EH
    • Make a test without delightful
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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