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.

WildBamaBoy

Members
  • Joined

  • Last visited

Everything posted by WildBamaBoy

  1. Not since everything has been grouped into packages, no. Having a lot of imports doesn't hurt anything, so just leave them.
  2. I'm trying to remove one of whatever item the player is holding when they right click one of my entities. Everything works fine until you only have one of that item left, then, about 50% of the time, as soon as the item is removed it is placed back in your inventory. This item that is placed back in the inventory has a stackSize of 0, and crashes the game when you place it. It also causes items in the inventory to duplicate or disappear. Here's various bits of code having to do with interaction with my entity. If I'm handling inventories completely wrong please correct me. interact() if (itemStack != null) { //Only process gifts on the client. if (this.worldObj.isRemote) { doGift(itemStack); } } super.interact(player); doGift() @SideOnly(Side.CLIENT) protected void doGift(ItemStack itemStack) { //Check the acceptable gifts for the item stack's item ID. if (DataStore.acceptableGifts.containsKey(itemStack.itemID)) { int heartIncrease = DataStore.acceptableGifts.get(itemStack.itemID); hearts += heartIncrease; PacketDispatcher.sendPacketToServer(PacketCreator.createFieldValuePacket(entityId, "hearts", hearts)); removeItemFromPlayer(itemStack); //Say the appropriate phrase based on hearts increase. if (heartIncrease <= 5) { say(Localization.getString(this, "gift.small")); } else if (heartIncrease > 5 && heartIncrease < 10) { say(Localization.getString(this, "gift.regular")); } else { say(Localization.getString(this, "gift.great")); } } //The gift wasn't contained in the acceptable gifts map. else { hearts -= new Random().nextInt(9) + 5; say(Localization.getString(this, "gift.bad")); } } removeItemFromPlayer() public static void removeItemFromPlayer(ItemStack itemStack) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; itemStack.stackSize--; if (itemStack.stackSize <= 0) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } MCA.instance.syncPlayerInventory(player); } syncPlayerInventory() public void syncPlayerInventory(EntityPlayer player) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { EntityPlayer playerOnClient = player; EntityPlayer playerOnServer = (EntityPlayer) getServerSideEntity(player); playerOnServer.inventory = playerOnClient.inventory; } else { EntityPlayer playerOnServer = player; EntityPlayer playerOnClient = (EntityPlayer) getClientSideEntity(player); playerOnClient.inventory = playerOnServer.inventory; } }
  3. I'd say for some reason it's failing to get an instance of the player from the client world. Check the playerID when its sent and when its received. Make sure it's what it should be. Also could you not just cast the player provided to EntityClientPlayerMP like you did server-side?
  4. Users are getting random crashes while entities in my mod are following them around. I have also began getting this type of error but in a different context. I have this error report from a user whose game crashed while my entity was set to follow them. No mention of my mod, but it only happens when it is installed and an entity is following them. ---- Minecraft Crash Report ---- // Hey, that tickles! Hehehe! Time: 11/18/12 11:37 AM Description: Exception getting block type in world java.lang.IllegalStateException: Entity is already tracked! at ii.a(EntityTracker.java:161) at ii.a(EntityTracker.java:115) at ij.a(SourceFile:24) at xv.a(World.java:1514) at in.a(WorldServer.java:819) at xv.a(World.java:3722) at zs.c(Chunk.java:1023) at im.c(ChunkProviderServer.java:134) at im.d(ChunkProviderServer.java:150) at xv.e(World.java:498) at xv.a(World.java:381) at or.f(SourceFile:287) at or.m(SourceFile:273) at or.a(SourceFile:63) at ou.a(SourceFile:48) at in.b(WorldServer.java:142) at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:657) at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:587) at bdo.q(IntegratedServer.java:110) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:494) at fy.run(SourceFile:856) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at ii.a(EntityTracker.java:161) at ii.a(EntityTracker.java:115) at ij.a(SourceFile:24) at xv.a(World.java:1514) at in.a(WorldServer.java:819) at xv.a(World.java:3722) at zs.c(Chunk.java:1023) at im.c(ChunkProviderServer.java:134) at im.d(ChunkProviderServer.java:150) at xv.e(World.java:498) -- Requested block coordinates -- Details: Found chunk: true Location: World: (203,65,-810), Chunk: (at 11,4,6 in 12,-51; contains blocks 192,0,-816 to 207,255,-801), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513) Stacktrace: at xv.a(World.java:381) at or.f(SourceFile:287) at or.m(SourceFile:273) at or.a(SourceFile:63) at ou.a(SourceFile:48) at in.b(WorldServer.java:142) -- Affected level -- Details: Level name: Blah Bhah Chirp All players: 1 total; [iq['Fishcat'/74, l='Blah Bhah Chirp', x=370.59, y=64.42, z=-805.48]] Chunk stats: ServerChunkCache: 544 Drop: 0 Level seed: -7685121701639027226 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: 2;7,3x1,52x24,8x12;2;stronghold,biome_1,village,decoration,dungeon,mineshaft Level spawn location: World: (320,4,-780), Chunk: (at 0,0,4 in 20,-49; contains blocks 320,0,-784 to 335,255,-769), Region: (0,-2; contains chunks 0,-64 to 31,-33, blocks 0,0,-1024 to 511,255,-513) Level time: 29589 game time, 29589 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 133145 (now: false), thunder time: 32026 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:657) at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:587) at bdo.q(IntegratedServer.java:110) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:494) at fy.run(SourceFile:856) -- System Details -- Details: Minecraft Version: 1.4.4 Operating System: Windows 7 (x86) version 6.1 Java Version: 1.7.0_07, Oracle Corporation Java VM Version: Java HotSpot™ Client VM (mixed mode), Oracle Corporation Memory: 257555760 bytes (245 MB) / 519110656 bytes (495 MB) up to 1037959168 bytes (989 MB) JVM Flags: 2 total; -Xms512m -Xmx1024m AABB Pool Size: 1446 (80976 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v7.21 FML v4.4.4.442 Minecraft Forge 6.3.0.372 4 mods loaded, 4 mods active mcp [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available FML [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available Forge [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available MCA [Minecraft Comes Alive] (mca.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 238 (13328 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [iq['Fishcat'/74, l='Blah Bhah Chirp', x=370.59, y=64.42, z=-805.48]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'forge,fml' I'm also getting this crash, but it's when I try to spawn in an entity using an event hook. The purpose of this event hook is to remove the old "Testificate" villagers when they spawn and replace them with my own version of villagers. EDIT: This happened on only one world so far, but that world would not load again even without the event hook running. @ForgeSubscribe public void entityJoinedWorldEventHandler(EntityJoinWorldEvent event) { if (!event.world.isRemote) { if (MCA.instance.worldPropertiesManager != null) { if (MCA.instance.worldPropertiesManager.worldProperties.overwriteTestificates) { if (event.entity instanceof EntityVillager) { event.setCanceled(true); EntityVillager villager = (EntityVillager)event.entity; EntityVillagerAdult newVillager = new EntityVillagerAdult(event.world, villager.getProfession()); newVillager.setPositionAndRotation(villager.posX, villager.posY, villager.posZ, villager.rotationYaw, villager.rotationPitch); event.world.spawnEntityInWorld(newVillager); villager.setDead(); } } } } } But I get this error while the game loads: 2012-11-18 14:56:06 [iNFO] [sTDERR] java.lang.IllegalStateException: Entity is already tracked! 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.EntityTracker.addEntityToTracker(EntityTracker.java:161) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.EntityTracker.addEntityToTracker(EntityTracker.java:115) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.WorldManager.obtainEntitySkin(WorldManager.java:30) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.World.obtainEntitySkin(World.java:1514) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.WorldServer.obtainEntitySkin(WorldServer.java:819) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.World.addLoadedEntities(World.java:3722) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.Chunk.onChunkLoad(Chunk.java:1023) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.ChunkProviderServer.loadChunk(ChunkProviderServer.java:134) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:313) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.IntegratedServer.loadAllWorlds(IntegratedServer.java:71) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.IntegratedServer.startServer(IntegratedServer.java:87) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:456) 2012-11-18 14:56:06 [iNFO] [sTDERR] at net.minecraft.src.ThreadMinecraftServer.run(ThreadMinecraftServer.java:17) Why is this happening?
  5. What's the proper way of adding items without using ModLoader's functions? I'm using Forge v6.0.1.341. Here's the code for the item. package mca; import net.minecraft.src.CreativeTabs; public class ItemBabyGirl extends ItemBaby { public ItemBabyGirl(int i) { super(i); setItemName("Baby Girl"); gender = "Female"; setCreativeTab(CreativeTabs.tabMisc); } } And the class it extends from: package mca; import net.minecraft.src.EntityPlayer; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.World; public class ItemBaby extends Item { public String gender; public ItemBaby(int i) { super(i); maxStackSize = 1; } @Override public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int i, int j, int k, int l, float m, float n, float o) { if (MCA.instance.worldPropertiesManager.worldProperties.babyReadyToGrow) { if (!entityPlayer.worldObj.isRemote) { entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null); EntityPlayerChild entityPlayerChild = new EntityPlayerChild(world, entityPlayer, MCA.instance.worldPropertiesManager.worldProperties.babyName, gender); entityPlayerChild.setLocationAndAngles(i, j + 1, k, entityPlayer.rotationYaw, entityPlayer.rotationPitch); world.spawnEntityInWorld(entityPlayerChild); entityPlayer.triggerAchievement(MCA.instance.achievementBabyGrowUp); MCA.instance.worldPropertiesManager.worldProperties.babyExists = false; MCA.instance.worldPropertiesManager.worldProperties.babyReadyToGrow = false; MCA.instance.worldPropertiesManager.worldProperties.minutesBabyExisted = 0; MCA.instance.worldPropertiesManager.worldProperties.babyName = "null"; MCA.instance.worldPropertiesManager.saveWorldProperties(); } } return true; } } And the code for the eggs: package mca; import java.util.HashMap; import java.util.Map; import java.util.Random; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Side; import net.minecraft.src.Block; import net.minecraft.src.CreativeTabs; import net.minecraft.src.EntityPlayer; import net.minecraft.src.Facing; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.World; public class ItemEggMale extends Item { public ItemEggMale(int par1) { super(par1); setHasSubtypes(true); setCreativeTab(CreativeTabs.tabMisc); } public boolean requiresMultipleRenderPasses() { return true; } public int getIconFromDamageForRenderPass(int par1, int par2) { if (par2 > 0) { return super.getIconFromDamageForRenderPass(par1, par2) + 16; } else { return super.getIconFromDamageForRenderPass(par1, par2); } } public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par3World.isRemote) { return true; } int i = par3World.getBlockId(par4, par5, par6); par4 += Facing.offsetsXForSide[par7]; par5 += Facing.offsetsYForSide[par7]; par6 += Facing.offsetsZForSide[par7]; double d = 0.0D; if (par7 == 1 && i == Block.fence.blockID || i == Block.netherFence.blockID) { d = 0.5D; } if (spawnVillager(par3World, par1ItemStack.getItemDamage(), (double)par4 + 0.5D, (double)par5 + d, (double)par6 + 0.5D) && !par2EntityPlayer.capabilities.isCreativeMode) { par1ItemStack.stackSize--; } return true; } public static boolean spawnVillager(World par0World, int par1, double par2, double par4, double par6) { EntityVillager entityVillager = new EntityVillager(par0World, "Male", new Random().nextInt(); if (entityVillager != null) { entityVillager.setLocationAndAngles(par2, par4, par6, par0World.rand.nextFloat() * 360F, 0.0F); if (!par0World.isRemote) { par0World.spawnEntityInWorld(entityVillager); for (Map.Entry<Integer, Integer> mapEntry : MCA.instance.idsMap.entrySet()) { if (mapEntry.getValue() > entityVillager.mcaID) { entityVillager.mcaID = mapEntry.getValue(); } } entityVillager.mcaID++; MCA.instance.idsMap.put(entityVillager.entityId, entityVillager.mcaID); MCA.instance.log(entityVillager.mcaID); } } return entityVillager != null; } } package mca; import java.util.HashMap; import java.util.Map; import java.util.Random; import net.minecraft.src.Block; import net.minecraft.src.CreativeTabs; import net.minecraft.src.EntityPlayer; import net.minecraft.src.Facing; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.World; public class ItemEggFemale extends Item { public ItemEggFemale(int par1) { super(par1); setHasSubtypes(true); setCreativeTab(CreativeTabs.tabMisc); } public boolean requiresMultipleRenderPasses() { return true; } public int getIconFromDamageForRenderPass(int par1, int par2) { if (par2 > 0) { return super.getIconFromDamageForRenderPass(par1, par2) + 16; } else { return super.getIconFromDamageForRenderPass(par1, par2); } } public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par3World.isRemote) { return true; } int i = par3World.getBlockId(par4, par5, par6); par4 += Facing.offsetsXForSide[par7]; par5 += Facing.offsetsYForSide[par7]; par6 += Facing.offsetsZForSide[par7]; double d = 0.0D; if (par7 == 1 && i == Block.fence.blockID || i == Block.netherFence.blockID) { d = 0.5D; } if (spawnVillager(par3World, par1ItemStack.getItemDamage(), (double)par4 + 0.5D, (double)par5 + d, (double)par6 + 0.5D) && !par2EntityPlayer.capabilities.isCreativeMode) { par1ItemStack.stackSize--; } return true; } public static boolean spawnVillager(World par0World, int par1, double par2, double par4, double par6) { int profession = new Random().nextInt(; if (profession == 4) profession = 0; EntityVillager entityVillager = new EntityVillager(par0World, "Female", profession); if (entityVillager != null) { entityVillager.setLocationAndAngles(par2, par4, par6, par0World.rand.nextFloat() * 360F, 0.0F); if (!par0World.isRemote) { par0World.spawnEntityInWorld(entityVillager); for (Map.Entry<Integer, Integer> mapEntry : MCA.instance.idsMap.entrySet()) { if (mapEntry.getValue() > entityVillager.mcaID) { entityVillager.mcaID = mapEntry.getValue(); } } entityVillager.mcaID++; MCA.instance.idsMap.put(entityVillager.entityId, entityVillager.mcaID); MCA.instance.log(entityVillager.mcaID); } } return entityVillager != null; } }
  6. Just moved to Forge from ModLoader. While testing I noticed that the icon of one of my items overlaps the Leather Tunic that already exists in Minecraft and a couple of other odd problems with icons. https://dl.dropbox.com/u/64124307/Minecraft%20Comes%20Alive/Development/jars/screenshots/2012-11-12_01.03.02.png[/img] The first item is my item. The one beside that is the Leather Tunic, and beside that are the two mob eggs that I have added. Note that I do not use Forge's built in method of creating mob eggs, instead I created the egg classes and icons myself. Notice that the eggs have blue arrows on the top left and bottom right. These are not present in the actual icon file. Why is this happening and how do I fix it? I still use ModLoader's methods for adding items if that could be the problem. I am unsure of how to properly do the same using Forge, or if it is any different at all. itemBabyGirl = new ItemBabyGirl(modPropertiesManager.modProperties.itemID_BabyGirl).setIconIndex(ModLoader.addOverride("/gui/items.png", "/MCA/ItemBabyGirl.png")).setItemName("BabyGirl");

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.