Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Shuyin76

Members
  • Joined

  • Last visited

Everything posted by Shuyin76

  1. OKay, I understand now ! Thank you very much ! Here is the method I added in the custom tile entity as suggested from diesieben07: @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { if(newSate.getBlock() instanceof ProtectedDoor) { return false; } return true; } [/Code]
  2. So... It works very good ! thanks a lot ! I just have a problem with the playAuxSFXAtEntity which does not work server side... is there an equivalent ? (It will permit me to avoid using nbt synchronization between the client and the server tiles)
  3. Okay, I didn't know this method ever exists ! I'll try this when I can ! Thanks !
  4. Hello every body ! I have a problem with my custom door : when i right click on it (and open/close the door) it seems the attached tile entity is destroyed and respawn so it delete all the data saved in it... I don't know what to do... Here is my custom door block code public class ProtectedDoor extends BlockDoor implements ITileEntityProvider{ private final String name = "ProtectedDoor"; public ProtectedDoor() { super(Material.wood); GameRegistry.registerBlock(this, name); setUnlocalizedName(Test.MODID + "_" + name); setHardness(3f); setResistance(20f); setHarvestLevel("axe", 2); // TODO Auto-generated constructor stub } public String getName() { return name; } @Override public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { if(!worldIn.isRemote) { IBlockState state = worldIn.getBlockState(pos); BlockPos blockpos1 = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down(); ProtectedTileEntity t = (ProtectedTileEntity) worldIn.getTileEntity(new BlockPos(blockpos1)); if(t != null) { t.setDatas(playerIn, worldIn); } } super.onBlockClicked(worldIn, pos, playerIn); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { BlockPos blockpos1 = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down(); IBlockState iblockstate1 = pos.equals(blockpos1) ? state : worldIn.getBlockState(blockpos1); if (iblockstate1.getBlock() != this) { return false; } else { state = iblockstate1.cycleProperty(OPEN); ProtectedTileEntity t = (ProtectedTileEntity) worldIn.getTileEntity(new BlockPos(blockpos1)); if(t != null) { if(t.TryToOpen(playerIn, !((Boolean)state.getValue(OPEN)).booleanValue())) { worldIn.setBlockState(blockpos1, state, 2); worldIn.markBlockRangeForRenderUpdate(blockpos1, pos); worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0); return true; } } } return false; } @Override @SideOnly(Side.CLIENT) public Item getItem(World worldIn, BlockPos pos) { return Item.getByNameOrId("shuyintestmod:"+ItemProtectedDoor.getName()); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? null : Item.getByNameOrId("shuyintestmod:"+ItemProtectedDoor.getName()); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { // TODO Auto-generated method stub return new ProtectedTileEntity(); } } And my custom tile entity public class ProtectedTileEntity extends TileEntity{ private String owner=""; private String password=""; private int UUID = (new Random()).nextInt(10000); @Override public Packet getDescriptionPacket() { NBTTagCompound tagCompound = new NBTTagCompound(); newWriteNBT(tagCompound); return new net.minecraft.network.play.server.S35PacketUpdateTileEntity(this.pos, 1, tagCompound); } @Override public void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.S35PacketUpdateTileEntity pkt) { newReadNBT(pkt.getNbtCompound()); } public void setDatas(EntityPlayer player, World world) { if(this.owner.equals("")) { this.owner = player.getDisplayNameString(); player.addChatMessage(new ChatComponentText("Proprietaire de la porte : " + this.owner)); world.markBlockForUpdate(pos); } if(player.inventory.getCurrentItem() != null) { ItemStack key = player.inventory.getCurrentItem(); if(key.getItem() instanceof MetalKey) { if(player.isSneaking() && player.getDisplayNameString().equals(owner)) { this.password = key.getDisplayName(); player.addChatMessage(new ChatComponentText("La serrure a ete changee : " + this.password)); world.markBlockForUpdate(pos); } } } } public boolean TryToOpen(EntityPlayer player, boolean open) { boolean creative = player.capabilities.isCreativeMode; boolean mauvaiseCle = false; if(player.inventory.getCurrentItem() != null) { ItemStack key = player.inventory.getCurrentItem(); if(key.getItem() instanceof MetalKey) { if(key.getDisplayName().equals(password)) { return true; } else { mauvaiseCle = true; } } } player.addChatMessage(new ChatComponentText("Proprietaire : " + this.owner + ", mdp : " + this.UUID)); if(password == "") return true; if(creative || open){ return true; } else{ if(!mauvaiseCle) player.addChatMessage(new ChatComponentText("La porte est fermee !")); else player.addChatMessage(new ChatComponentText("Ce n'est pas la bonne cle !")); return false; } } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); newReadNBT(nbt); System.out.println("reading protected datas : " + this.owner + " | " + this.password); } public void newWriteNBT(NBTTagCompound nbt) { nbt.setString("Owner", owner); nbt.setString("Password", password); } public void newReadNBT(NBTTagCompound nbt) { this.owner = nbt.getString("Owner"); this.password = nbt.getString("Password"); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); newWriteNBT(nbt); System.out.println("saving protected datas : " + this.owner + " | " + this.password); } } If you find some mistake not in relation with my problem, don't hesitate to tell me about it ! Thanks in advance !
  5. OK I'll do that ! Here is my custom Entity class, I hope this will help someone for the dataWatcher or simply create a custom entity ! public class EntityNPCM extends EntityMob{ protected int careerId; protected boolean canWander; public EntityNPCM(World par1World) { super(par1World); canWander = false; updateTasks(); this.setCanPickUpLoot(false); if(this.getCustomNameTag().isEmpty()) this.setCustomNameTag("MALE_NPC"); } private void updateTasks() { this.tasks.taskEntries.clear(); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F)); this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F)); if(canWander) this.tasks.addTask(9, new EntityAIWander(this, 0.4D)); } @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, 0); this.dataWatcher.addObject(17, 0); } @Override public int getTalkInterval() { return 200; } @Override protected boolean canDespawn() { return false; } //function used in my render class to get the good careerId @SideOnly(Side.CLIENT) public int getClientCarrerId() { return this.dataWatcher.getWatchableObjectInt(16); } @SideOnly(Side.CLIENT) public boolean isClientMale() { return this.dataWatcher.getWatchableObjectInt(17) == 0; } public void setCarrerId(short id) { this.careerId = id; } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); tagCompound.setInteger("Career", this.careerId); tagCompound.setBoolean("Wander", canWander); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ @Override public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.canWander = tagCompund.getBoolean("Wander"); this.careerId = tagCompund.getInteger("Career"); this.dataWatcher.updateObject(16, this.careerId); updateTasks(); } @Override protected String getHurtSound() { return "shuyintestmod:hurtM"; } @Override protected String getDeathSound() { return "shuyintestmod:deathM"; } @Override protected String getLivingSound() { return "shuyintestmod:livingM"; } @Override public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); boolean flag = itemstack != null && (itemstack.getItem() == Items.spawn_egg || itemstack.getItem() == Items.name_tag); if (!flag && this.isEntityAlive() && !this.worldObj.isRemote) { if(itemstack != null) { if(itemstack.getItem() instanceof ItemTest) { if(player.isSneaking()) { this.setDead(); } else { canWander = !canWander; if(canWander) player.addChatMessage(new ChatComponentText(this.getCustomNameTag() + " will now be wandering.")); else player.addChatMessage(new ChatComponentText(this.getCustomNameTag() + " will stand still.")); updateTasks(); } return true; } } if(player.capabilities.isCreativeMode && player.isSneaking()) { this.careerId++; if(this.careerId > 5) this.careerId = 0; this.dataWatcher.updateObject(16, this.careerId); } else { player.addChatMessage(new ChatComponentText(this.getCustomNameTag() + " : Mon ID = "+ this.careerId + " : " + getUniqueID().toString())); } return true; } else { return super.interact(player); } } }
  6. Aand... It works ! Thank you very much for your precious help ! AAahh if only I knew about datawatcher sooner ! Ernio, "Do not declare Resource with every render pass, save those as static files somewhere and just reference them." Do I have to create a list of strings and create the new Resource location in the getEntityTexture Method or It's best to create a list of ResourceLocation directly ? I will post my custom Entity class later for help
  7. OK, Client side the getcarrerId returns always 0. Here is my Updated entity class : public class EntityNPCM extends EntityMob{ protected short careerId; public EntityNPCM(World par1World) { super(par1World); this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F)); this.tasks.addTask(9, new EntityAIWander(this, 0.6D)); this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F)); this.setCanPickUpLoot(false); if(this.getCustomNameTag().isEmpty()) this.setCustomNameTag("NPC"); } @Override public int getTalkInterval() { return 200; } @Override protected boolean canDespawn() { return false; } public short getCarrerId() { if(this.worldObj.isRemote) { System.out.println("getting careerId in Client :" + this.careerId); } else { System.out.println("getting careerId in Server :" + this.careerId); } return this.careerId; } public void setCarrerId(short id) { this.careerId = id; } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); tagCompound.setShort("Career", this.careerId); System.out.println("sauvegarde NBT NPC :" + this.careerId +" " + getCustomNameTag() + " : " + getUniqueID().toString()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ @Override public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.careerId = tagCompund.getShort("Career"); System.out.println("charge NBT NPC :" + this.careerId+" " + getCustomNameTag() + " : " + getUniqueID().toString()); } @Override protected String getHurtSound() { return "shuyintestmod:hurtM"; } @Override protected String getDeathSound() { return "shuyintestmod:deathM"; } @Override protected String getLivingSound() { return "shuyintestmod:livingM"; } @Override public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); boolean flag = itemstack != null && (itemstack.getItem() == Items.spawn_egg || itemstack.getItem() == Items.name_tag); if (!flag && this.isEntityAlive()) { if(!this.worldObj.isRemote) { if(itemstack != null) { if(itemstack.getItem() instanceof ItemTest) { this.setDead(); return true; } } if(player.capabilities.isCreativeMode && player.isSneaking()) { this.careerId++; if(careerId > 5) careerId = 0; } else { player.addChatMessage(new ChatComponentText(this.getCustomNameTag() + " : Mon ID = "+ this.careerId + " : " + getUniqueID().toString())); } } return true; } else { return super.interact(player); } } }
  8. OK It works server side fine now, thank you very much ! But I have a problem : my entities don't render correctly ! They have the default skin but normally when I shift + right click on them, they have to change skin(switch the careerId). It worked before but wasn't saved. Here, the careerId is saved but the entities don't change their skins. Here is my Render class : public class RenderNPC extends RenderLiving { public RenderNPC(ModelBiped model, float shadowSize) { super(Minecraft.getMinecraft().getRenderManager(), model, shadowSize); } @Override protected boolean canRenderName(Entity Entity) { return true; } @Override protected ResourceLocation getEntityTexture(Entity par1Entity) { if(par1Entity instanceof EntityNPCM) { ResourceLocation textureLocation; EntityNPCM entity = (EntityNPCM) par1Entity; if(entity.getCarrerId()<0 || entity.getCarrerId()>5 ) textureLocation = new ResourceLocation(Test.MODID + ":" + "textures/models/entityNPC" + (par1Entity instanceof EntityNPCF ? "F" : "M") + "0.png"); else textureLocation = new ResourceLocation(Test.MODID + ":" + "textures/models/entityNPC" + (par1Entity instanceof EntityNPCF ? "F" : "M") + entity.getCarrerId()+ ".png"); return textureLocation; } else return null; } } which is called client side only RenderingRegistry.registerEntityRenderingHandler(EntityNPCM.class, new RenderNPC(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityNPCF.class, new RenderNPC(new ModelBiped(), 0.5F));
  9. OK I can spawn my custom entity. But.. should I spawn it Server side, client side or both ? I tried all the solution : - serveur side : spawn the correct entity but I can't interract with it -Client side : spawn an herited entity and I can interract with it but not saving anything -both : spawn the two entities
  10. OK what should I use instead of RegsiterGlobal EntityID ? It tried without but I can't see my spawn egg anymore (it's obvious I know) but even with adding EntityList.entityEggs.put(entityID, new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor)); at the end of my register, I can only see an egg that can't spawn anything !
  11. OK here is my commonProxy class I register my two entities here (both client and server side) I need to register them only server side ? public class CommonProxy { public static Item testItem; public static Item itemProtectedDoor; public static Block protectedDoor; public static void registerEntity(Class entityClass, String name) { int entityID = EntityRegistry.findGlobalUniqueEntityId(); long seed = name.hashCode(); Random rand = new Random(seed); int primaryColor = rand.nextInt() * 16777215; int secondaryColor = rand.nextInt() * 16777215; EntityRegistry.registerGlobalEntityID(entityClass, name, entityID,primaryColor,secondaryColor); EntityRegistry.registerModEntity(entityClass, name, entityID, Test.instance, 64, 1, true); } public void preInit(FMLPreInitializationEvent e) { testItem = new ItemTest(); protectedDoor = new ProtectedDoor(); itemProtectedDoor = new ItemProtectedDoor(protectedDoor); registerEntity(EntityNPCM.class, "entityNPCM"); registerEntity(EntityNPCF.class, "entityNPCF"); } public void init(FMLInitializationEvent e) { registerEventListeners(); registerRenderers(); } public void postInit(FMLPostInitializationEvent e) { } public void registerEventListeners() { MinecraftForge.EVENT_BUS.register(new EventHandlerTest()); } public void registerRenderers() { } } (both client and server proxy extends to this method. I override the registerRenderers only client side) in my custom entity class, I need to modify my interact method like this ? @Override public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); boolean flag = itemstack != null && (itemstack.getItem() == Items.spawn_egg || itemstack.getItem() == Items.name_tag); if (!flag && this.isEntityAlive()) { if(!this.worldObj.isRemote) { if(itemstack != null) { if(itemstack.getItem() instanceof ItemTest) { this.setDead(); return true; } } if(player.capabilities.isCreativeMode && player.isSneaking()) { this.careerId++; if(careerId > 5) careerId = 0; } else { player.addChatMessage(new ChatComponentText(this.getCustomNameTag() + " : Mon ID = "+ this.careerId + " : " + getUniqueID().toString())); } } return true; } else { return super.interact(player); } }
  12. OK, since when I set this for both sides, when I right click on them, I receive two messages, how do I make sure I execute the execute method only once ?
  13. So I'm testing the save with the two methods and a debug in each : [23:21:48] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.NPCExtendedProperties:loadNBTData:31]: charge NPC :0 POupoule : 3892f46a-f22c-4720-b2ce-41bacbcaf0dc [23:21:48] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.EntityNPCM:func_70037_a:83]: charge NBT NPC :0 POupoule : 3892f46a-f22c-4720-b2ce-41bacbcaf0dc [23:21:50] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.NPCExtendedProperties:loadNBTData:31]: charge NPC :0 NPC : b5b17f2a-b5fc-4b3e-a380-27905785a363 [23:21:50] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.EntityNPCM:func_70037_a:83]: charge NBT NPC :0 NPC : b5b17f2a-b5fc-4b3e-a380-27905785a363 -- Here, I suppose I'm playing, and I set the careerId to 2 for the NPC POupoule and 1 for the other -- [23:22:01] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.NPCExtendedProperties:saveNBTData:17]: sauvegarde NPC :0 POupoule : 3892f46a-f22c-4720-b2ce-41bacbcaf0dc [23:22:01] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.EntityNPCM:func_70014_b:71]: sauvegarde NBT NPC :0 POupoule : 3892f46a-f22c-4720-b2ce-41bacbcaf0dc [23:22:01] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.NPCExtendedProperties:saveNBTData:17]: sauvegarde NPC :0 NPC : b5b17f2a-b5fc-4b3e-a380-27905785a363 [23:22:01] [server thread/INFO] [sTDOUT/]: [com.shuyin.test.EntityNPCM:func_70014_b:71]: sauvegarde NBT NPC :0 NPC : b5b17f2a-b5fc-4b3e-a380-27905785a363 But you can see, the custom name of the entity can be read but not the careerId.(always 0) If I set the careerId to 3 for example during the save, It will load 3 but the careerId will be 0 on my real Entity. EDIT : I noticed that the UUID of the Entity wasn't the same that the UUID showed in the log. In the custom entity class, do you have to specify a serverSide for the Write/read to NBT method ? And for the IEEP, do you have to register them in server side only ?
  14. OK, you suggest I make something like that ? in my custom entity class @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); tagCompound.setInteger("Career", this.careerId); } @Override public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.careerId = tagCompund.getInteger("Career"); } I already tried this and it don't work And I'm sure I registered my IEEP because I can see my logs when loading and saving nbt.
  15. OK, I changed it but it don't work. I'm not sure but It seems to save correctly but when saving, it got 0 from career but have the good CustomName.(I changed the career level during the game and I'm sure the entity have a career lvl different than 0.
  16. Hello every body ! I'm using forge 11.14.1.1354 and I would like to create a custom entity. I already succeeded in that but I just can't save any new attribute ! I'm using a class implementing IExtendedEntityProperties to save the new fields but it doesn't seem to work. Here is my Custom entity class: I want to save the career field. import java.util.ArrayList; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIVillagerInteract; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.ai.EntityAIWatchClosest2; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.stats.StatList; import net.minecraft.util.ChatComponentText; import net.minecraft.village.MerchantRecipeList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityNPCM extends EntityMob{ protected short careerId; public EntityNPCM(World par1World) { super(par1World); this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F)); this.tasks.addTask(9, new EntityAIWander(this, 0.6D)); this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F)); this.setCanPickUpLoot(false); if(this.getCustomNameTag().isEmpty()) this.setCustomNameTag("NPC"); } @Override public int getTalkInterval() { return 200; } @Override protected boolean canDespawn() { return false; } public short getCarrerId() { return this.careerId; } public void setCarrerId(short id) { this.careerId = id; } @Override protected String getHurtSound() { return "shuyintestmod:hurtM"; } @Override protected String getDeathSound() { return "shuyintestmod:deathM"; } @Override protected String getLivingSound() { return "shuyintestmod:livingM"; } @Override public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); boolean flag = itemstack != null && (itemstack.getItem() == Items.spawn_egg || itemstack.getItem() == Items.name_tag); if (!flag && this.isEntityAlive()) { if(this.worldObj.isRemote) { if(itemstack.getItem() instanceof ItemTest) { this.setDead(); return true; } if(player.capabilities.isCreativeMode && player.isSneaking()) { this.careerId++; if(careerId > 5) careerId = 0; } else { player.addChatMessage(new ChatComponentText(this.getCustomNameTag() + " : Mon ID = "+ this.careerId + " : " + getUniqueID().toString())); } } return true; } else { return super.interact(player); } } } And here is my ExtendedProperties class : package com.shuyin.test; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; public class NPCExtendedProperties implements IExtendedEntityProperties { public final static String extendedPropertiesName = "extendedPropertiesNPC"; protected EntityNPCM entity; protected World theWorld; @Override public void saveNBTData(NBTTagCompound compound) { // TODO Auto-generated method stub System.out.println("sauvegarde NPC :" + entity.getCarrerId() +" " + entity.getCustomNameTag() + " : " + entity.getUniqueID().toString()); NBTTagCompound subCompound = new NBTTagCompound(); compound.setTag(extendedPropertiesName, subCompound); subCompound.setShort("career", entity.getCarrerId()); //compound.setShort("career", entity.getCarrerId()); } @Override public void loadNBTData(NBTTagCompound compound) { // TODO Auto-generated method stub NBTTagCompound subcompound = (NBTTagCompound) compound.getTag(extendedPropertiesName); entity.setCarrerId(subcompound.getShort("career")); System.out.println("charge NPC :" + entity.getCarrerId()+" " + entity.getCustomNameTag() + " : " + entity.getUniqueID().toString()); } @Override public void init(Entity entity, World world) { // TODO Auto-generated method stub this.entity = (EntityNPCM)entity; theWorld = world; } } My entity can spawn, send me a message when I right click, It's career lvl change when I shift+right click but it don't save. With the log I can see the custom save and custom load happening but they just always take 0 when they save the field. I'm sorry I juste can't use the code balise. If someone can say me how to use it, I don't understand...
  17. Up. Any idea ?
  18. here is my keyInputHandler (i use it for open my GUI) : import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; public class KeyInputHandler extends CommonProxy{ @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent eventK) { EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; if(KeyBindings.deck.isPressed()) if(player != null && Main.instance != null && player.worldObj != null){ if(!Main.liste.containsKey(player.getUniqueID())) Main.liste.put(player.getUniqueID(), new DeckTile()); player.openGui(Main.instance, 30, player.worldObj, (int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ)); } } @SubscribeEvent public void onMouseInput(InputEvent.MouseInputEvent eventM){ EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; //not used ftm } } and my main class : import java.util.HashMap; import java.util.UUID; import shuyin.yugioh.fm.items.Carte; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid=Main.MODID, name = Main.MODNAME, version=Main.VERSION) public class Main { public static HashMap<UUID, DeckTile> liste; @SidedProxy(clientSide= "shuyin.yugioh.fm.KeyInputHandler", serverSide= "shuyin.yugioh.fm.CommonProxy") public static KeyInputHandler proxy = new KeyInputHandler(); public static CommonProxy gui = new CommonProxy(); public static final String MODID = "yugfm"; public static final String MODNAME = "testModGui"; public static final String VERSION = "0.0.1"; public static Item carte; @Instance ( MODID ) public static Main instance; public static CreativeTabs tabCard = new CreativeTabs("tabName") { public Item getTabIconItem() { return Items.arrow; } }; @EventHandler public void preInit(FMLPreInitializationEvent e) { } @EventHandler public void init(FMLInitializationEvent e) { instance = this; liste = new HashMap<UUID, DeckTile>(); KeyBindings.init(); carte = new Carte(); GameRegistry.registerItem(carte, MODID + ":" + "test"); GameRegistry.registerTileEntity(DeckTile.class, MODID); NetworkRegistry.INSTANCE.registerGuiHandler(this, gui); FMLCommonHandler.instance().bus().register(proxy); } @EventHandler public void postInit(FMLPostInitializationEvent e) { } }
  19. I'm sorry i don't undestand, what do you mean by "debug with it" ?
  20. Here is my GuiHandler code : import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.network.IGuiHandler; public class CommonProxy implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if ( ID == DeckGui.GUI_ID){ return new DeckContainer(player.inventory, Main.liste.get(player.getUniqueID())); } // TODO Auto-generated method stub return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if ( ID == DeckGui.GUI_ID){ return new DeckGui(player.inventory, Main.liste.get(player.getUniqueID())); } // TODO Auto-generated method stub return null; } } The Main.list is a HashMap with UUID keys and DeckTile .
  21. Yep i said the wrong methode in my first message but i overrided the good one ^^ here is my container code : package shuyin.test.fy; 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.Item; import net.minecraft.item.ItemStack; public class DeckContainer extends Container{ protected DeckTile tile_entity; public DeckContainer(InventoryPlayer player_inventory, DeckTile tile){ this.tile_entity = tile; int k = 0; for(int j = 0 ; j < 5 ; j++){ for(int i = 0 ; i < 8 ; i++){ addSlotToContainer(new CardSlot(tile_entity, k, 17 + i * 18, 11 + j*18)); k++; } } bindPlayerInventory(player_inventory); System.out.println(this.inventorySlots.size()); } protected void bindPlayerInventory(InventoryPlayer player_inventory){ for(int i = 0; i < 3; i++){ for(int j = 0; j < 9; j++){ addSlotToContainer(new Slot(player_inventory, j + i * 9 + 9, 8 + j * 18, 140 + i * 18)); } } for(int i = 0; i < 9; i++){ addSlotToContainer(new Slot(player_inventory, i, 8 + i * 18, 198)); } } @Override public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) { System.out.println( par1+" " + par2 + " " + par3); System.out.println(this.inventorySlots.size()); return null; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ ItemStack stack = null; Slot slot_object = (Slot) inventorySlots.get(slot); if(slot_object != null && slot_object.getHasStack()){ ItemStack stack_in_slot = slot_object.getStack(); stack = stack_in_slot.copy(); if(slot == 0){ if(!mergeItemStack(stack_in_slot, 1, inventorySlots.size(), true)){ return null; } } else if(!mergeItemStack(stack_in_slot, 0, 1, false)){ return null; } if(stack_in_slot.stackSize == 0){ slot_object.putStack(null); } else{ slot_object.onSlotChanged(); } } return stack; } @Override public boolean canInteractWith(EntityPlayer player) { return tile_entity.isUseableByPlayer(player); } } It's very strange because i wrote some debug messages that appears in my console when i play there is nothing weird...
  22. Hello everybody ! I begin in modding with forge and i want to do some custome gui. And i made it works ! My custom gui is opened with the J key and all slots are well placed (There are 40 slots in the container plus all the slots of the player inventory. But when i click on a slot with a number greater than 44, my game crashes. I use a custom container and a custom tileEntity and in my custom container, there is a clickSlot method overriden(ftm it returns null). But when it crashes, it says there is an error on this method... Here is the error report : ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 27/05/14 23:30 Description: Ticking memory connection java.lang.IndexOutOfBoundsException: Index: 63, Size: 45 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.slotClick(Container.java:302) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:948) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.slotClick(Container.java:302) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:948) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@559eae50 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_05, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 678128456 bytes (646 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 4994 (279664 bytes; 0 MB) allocated, 4868 (272608 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.01-pre FML v7.2.156.1060 Minecraft Forge 10.12.1.1060 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.156.1060} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.1.1060} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available yugfm{0.0.1} [YuGiOh FM] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 1808 (101248 bytes; 0 MB) allocated, 1637 (91672 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player878'/366, l='New World', x=180,50, y=72,00, z=203,50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.