Jump to content

WildBamaBoy

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by WildBamaBoy

  1. It's for 1.6, but maybe this will help: https://github.com/WildBamaBoy/modjam-dec-2013/blob/master/Forge/mcp/src/minecraft/spellbound/item/ItemBookOfSpells.java
  2. Hey, thanks for the fast reply. I'll definitely be looking into that. By "items can have many localized names", did you mean unlocalized? Which item does this? If you meant localized, then wouldn't it be simpler to enforce unlocalized names as registry names since they do not change? While I can't think of any benefit to this right now (except in my situation), it might be helpful for something we're not thinking of at the moment.
  3. Once a player logs in, I have to assign a client entity's inventory so that their held item, worn armor, etc. shows up immediately to the player instead of when their inventory is eventually accessed and assigned by Minecraft's S2FPacketSetSlot packet. The player can place any item or block in this inventory, so the entity is basically a moving chest. The player can also change out their weapon, armor, etc. which will be displayed for all clients. Since item IDs are a thing of the past, this has been broken. My method before was to tell the client about the inventory items on login by sending a string for each occupied slot: [slot ID]:[item ID]:[stack size]:[stack damage] Where a damaged iron chestplate in slot 6, for example, would have the values: 6:307:1:40 The client would parse this information and add the item to the inventory for displaying purposes. Now, I've tried identifying the item by replacing the item ID with the item's unlocalized name. I strip off the "item." and ".name," leaving the base item name. Turning the string I send into: [slot ID]:[item name]:[stack size]:[stack damage] Which, for the same iron chestplate, would now translate to: 6:chestplateIron:1:40 But the iron chestplate in the item registry doesn't have that name. It is called "iron_chestplate". Because of this, I've had to resort to using item IDs anyway. Server-side: Item.getIdFromItem(stack.getItem()) Client-side: Item.getItemById(itemId) And it works. To my understanding, this could be a problem with mod items if the server or connected clients do not share the same underlying item IDs, right? Unless there's some other unique identifier for an item that can be sent across the network (i.e. its "name" that is added to the item registry), this is my only option. There doesn't seem to be a reliable way to get an item via its name constant from the item registry since the name constant on that item doesn't seem to be remembered in the item itself, like the unlocalized name is. Granted, some name constants do match the item's base unlocalized name, but most do not. Ensuring that they do would provide a solution to this problem.
  4. Actually, just forget it. I'm quite happy with my own build script. Thanks for your help though.
  5. I really appreciate your help. This is all new to me, remember. I'm not familiar with gradle, maven, or anything like that. The core was published, apparently, but gradle still doesn't know where it is when building MCA. I'm not sure what else to tell it, or how. This is a lot more frustrating than it has to be, but I'm probably making it more complicated than it really is. I may end up modifying my original build script to copy the core's source where it needs to be and then build, if that would work. Although I'd like others to know how to implement the core correctly since it's open source.
  6. Something like this? It can't find the core. It's in a completely separate folder with another copy of gradlew, the minecraft source, etc. and its src/main/java is a linked folder in MCA's eclipse workspace. I don't understand how it is supposed to know where "com.radixshock.radixcore" is supposed to be, or how to tell it that. The core's relevant build.gradle section: [...] apply plugin: 'forge' version = "1.0.0" group= "com.radixshock.radixcore" archivesBaseName = "RadixCore" [...] MCA's relevant section [...] dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT' classpath 'com.radixshock.radixcore:RadixCore:1.0.0' } [...]
  7. Trying to build MCA using Gradle. It now uses another separate "mod" that contains core functions, interfaces, etc. that I plan to reuse. When building, Gradle can't find any references to this other mod. How do I point it in the right direction? My file setup is probably very weird. I'm not sure what it's generally supposed to be with multiple mods, plus I'm using Git and I'm not very experienced with it. Gradle |_src |_main |_ java |_ mca |_ [mca's packages] |_ radixcore (this is the other mod's repository from GitHub) My Eclipse workspace is as follows: Minecraft |_ src/main/java |_ [mca's packages] |_ src/main/resources |_ [mca's resorces] |_ radixcore (Shortcut to the src/main/java folder of the radixcore project)
  8. I'm adding a sapling class with twelve different sub-blocks. The saplings show the correct texture when placed in the world, but when in the inventory they always show the icon of the first sapling. I've checked and getIcon() is always being given a metadata value of zero. If I change meta to any other appropriate number then that sapling's icon is shown. I cannot figure out why this is happening. I do the exact same thing with my leaves and logs and it works great. Sapling class: package arrowsplus; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockArrowTreeSapling extends BlockFlower { public static final String[] woodType = new String[] {"aspen", "cottonwood", "alder", "sycamore", "gum", "softmaple", "ash", "beech", "hardmaple", "hickory", "mahogany", "sypherus"}; @SideOnly(Side.CLIENT) private Icon[] saplingIcon; protected BlockArrowTreeSapling(int par1) { super(par1); this.setCreativeTab(ArrowsPlus.instance.tabArrowsPlus); this.setTickRandomly(true); } @Override public Block func_111022_d(String par1Str) { this.field_111026_f = "arrowsPlus:tree"; return this; } @SideOnly(Side.CLIENT) public Icon getIcon(int side, int meta) { //-----------------> Meta is always zero. return this.saplingIcon[meta]; } public int damageDropped(int meta) { return meta; } @SideOnly(Side.CLIENT) public void getSubBlocks(int itemId, CreativeTabs creativeTab, List listSubBlocks) { listSubBlocks.add(new ItemStack(itemId, 1, 0)); listSubBlocks.add(new ItemStack(itemId, 1, 1)); listSubBlocks.add(new ItemStack(itemId, 1, 2)); listSubBlocks.add(new ItemStack(itemId, 1, 3)); listSubBlocks.add(new ItemStack(itemId, 1, 4)); listSubBlocks.add(new ItemStack(itemId, 1, 5)); listSubBlocks.add(new ItemStack(itemId, 1, 6)); listSubBlocks.add(new ItemStack(itemId, 1, 7)); listSubBlocks.add(new ItemStack(itemId, 1, ); listSubBlocks.add(new ItemStack(itemId, 1, 9)); listSubBlocks.add(new ItemStack(itemId, 1, 10)); listSubBlocks.add(new ItemStack(itemId, 1, 11)); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { this.saplingIcon = new Icon[woodType.length]; for (int i = 0; i < this.saplingIcon.length; ++i) { this.saplingIcon[i] = iconRegister.registerIcon(this.func_111023_E() + "_" + woodType[i] + "_sapling"); } } } They are registered as such in preInit() blockArrowTreeSapling = new BlockArrowTreeSapling(modPropertiesManager.modProperties.blockId_ArrowLogSapling).func_111022_d("tree"); GameRegistry.registerBlock(blockArrowTreeSapling, ItemBlockSapling.class, "Arrow Saplings"); for (int i = 0; i < 12; i++) { ItemStack saplingStack = new ItemStack(blockArrowTreeSapling, 1, i); LanguageRegistry.addName(saplingStack, saplingNames[i]); } The ItemBlock for the saplings package arrowsplus; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class ItemBlockSapling extends ItemBlock { public static final String[] saplingNames = new String[] {"Aspen Sapling", "Cottonwood Sapling", "Alder Sapling", "Sycamore Sapling", "Gum Sapling", "Soft Maple Sapling", "Ash Sapling", "Beech Sapling", "Hard Maple Sapling", "Hickory Sapling", "Mahogany Sapling", "Sypherus Sapling"}; public ItemBlockSapling(int id) { super(id); setHasSubtypes(true); setUnlocalizedName("ItemBlockSapling"); } @Override public int getMetadata(int damageValue) { ArrowsPlus.instance.log(damageValue); return damageValue; } public String getUnlocalizedName(ItemStack par1ItemStack) { return saplingNames[par1ItemStack.getItemDamage()]; } }
  9. If I could be pointed to some documentation of these "facilities" I'd gladly use them. And I know my method is bad, but it does/has worked without networking issues until now. Guess it has to go.
  10. Problems with Minecraft Comes Alive: Users of my mod that have Forge 7.7.1.624 and above (so far) report problems that are not present on the recommended version that I link them to: 7.7.1.611. Description I use a certain packet to update the client with the same randomly selected information that the server selected and keep it updated. This is the process: Client entity doesn't have a texture -> Sends "sync request" packet to Server containing entity id -> Server handles "sync request" by serializing and sending back the entity with the provided id -> Client searches for entity with the same id as the one that was just received and deserialized -> ERROR. ID doesn't match any entities on the client. Client side entity is never updated. Packet is not properly handled. This problem was fixed by adding the entity id to the sync packet by itself, alongside the entity that was serialized. The client side entity was successfully updated but still did not receive its texture. Instead it used the default char.png. I specifically tell my entities to write their textures and entityIds when being serialized; for some reason this data wasn't written correctly. /** * Writes this object to an object output stream. (Serialization) * * @param out The object output stream that this object should be written to. * * @throws IOException This exception should never happen. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(texture); out.writeObject(entityId); } /** * Reads this object from an object input stream. (Deserialization) * * @param in The object input stream that this object should be read from. * * @throws IOException This exception should never happen. * @throws ClassNotFoundException This exception should never happen. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); texture = (String)in.readObject(); entityId = (Integer)in.readObject(); } Log verifying that some error has occurred with the entity id. They do not match when on previous versions they do! To see this output, you must use the command "/mca.debug on" before allowing a villager from the mod to spawn. After I fixed the problem with the entity ID, I also had to add the texture to the packet so that the client would actually receive the right texture data. My writeObject and readObject methods are being skipped. Why? More verification that these methods are skipped: the entity's inventory must also be serialized and sent back and forth. When I try to serialize the inventory for a packet, I get a NotSerializableException on a field. I override the serialization with writeObject and readObject, and I do not allow defaultWriteObject() to run so that I won't have the problem with a field not being serializable. It only writes what I tell it to. This is the error I get when trying to serialize an Inventory: 2013-04-04 23:10:27 [iNFO] [sTDERR] java.io.NotSerializableException: net.minecraft.item.ItemStack 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeObject0(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeArray(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeObject0(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeSerialData(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeObject0(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.io.ObjectOutputStream.writeObject(Unknown Source) 2013-04-04 23:10:27 [iNFO] [sTDERR] at mods.MCA.PacketCreator.createInventoryPacket(PacketCreator.java:432) 2013-04-04 23:10:27 [iNFO] [sTDERR] at mods.MCA.EntityVillagerAdult.interact(EntityVillagerAdult.java:678) 2013-04-04 23:10:27 [iNFO] [sTDERR] at net.minecraft.entity.player.EntityPlayer.interactWith(EntityPlayer.java:1222) 2013-04-04 23:10:27 [iNFO] [sTDERR] at net.minecraft.client.multiplayer.PlayerControllerMP.func_78768_b(PlayerControllerMP.java:462) 2013-04-04 23:10:27 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1291) 2013-04-04 23:10:27 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1796) 2013-04-04 23:10:27 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:831) 2013-04-04 23:10:27 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:756) 2013-04-04 23:10:27 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source) I specifically include the writeObject() method in Inventory to skip the default serialization and prevent this problem. You can view this for yourself in both versions of the source code. Why does this happen? And why only on later versions of Forge? Source Code (Broken on 624+, perfect on 611-) - https://dl.dropbox.com/u/64124307/Broken%20Source.zip Source Code (Semi-Fixed for later Forge versions, Inventory packet kills the game. Gift a sword to a villager.) - https://dl.dropbox.com/u/64124307/Semi-Fixed%20Source.zip Files of interest: PacketHandler.java, createSyncPacket(), createSyncRequestPacket(), createInventoryPacket() PacketCreator.java, handleSync(), handleSyncRequest(), handleInventory() EntityVillagerAdult.java, interact() EntityBase.java, writeObject(), readObject() Inventory.java, writeObject(), readObject() While it seems entirely wrong to blame Forge for what appears to be a problem with serialization (I have no idea how you can screw with built-in java), the exact same code works flawlessly on Forge 611 and has been working for months! I don't know what else to blame.
  11. GameRegistry. Don't use ModLoader.
  12. Take the check for world.isRemote off. A block change must happen both client (world.isRemote) and server (!world.isRemote) side in order for it to stay there.
  13. If you're here you should be using Forge, not ModLoader. Use LanguageRegistry.addName not ModLoader.addName. And you should probably check out this tutorial: http://www.minecraftforge.net/wiki/Category:Generic_Mod
  14. Got that all figured out but now it's having some problem with packets. Client Side 2012-12-24 15:16:04 [iNFO] [sTDOUT] Connecting to 127.0.0.1, 25565 2012-12-24 15:16:06 [iNFO] [sTDOUT] Minecraft Comes Alive CLIENT: SENT SYNC REQUEST 173 2012-12-24 15:16:06 [iNFO] [sTDOUT] Minecraft Comes Alive CLIENT: [b@2158592a 2012-12-24 15:16:06 [iNFO] [sTDOUT] Minecraft Comes Alive CLIENT: SENT SYNC REQUEST 177 2012-12-24 15:16:06 [iNFO] [sTDOUT] Minecraft Comes Alive CLIENT: [b@15de4ebf Server Side 2012-12-24 15:16:06 [iNFO] [sTDOUT] Minecraft Comes Alive SERVER: Received packet: MCA_SYNC_REQ 2012-12-24 15:16:06 [iNFO] [sTDERR] java.lang.NullPointerException 2012-12-24 15:16:06 [iNFO] [sTDERR] at java.io.ByteArrayInputStream.<init>(Unknown Source) 2012-12-24 15:16:06 [iNFO] [sTDERR] at mca.PacketHandler.handleSyncRequest(PacketHandler.java:458) 2012-12-24 15:16:06 [iNFO] [sTDERR] at mca.PacketHandler.onPacketData(PacketHandler.java:95) 2012-12-24 15:16:06 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:243) 2012-12-24 15:16:06 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:233) 2012-12-24 15:16:06 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:71) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.handleCustomPayload(NetServerHandler.java:1111) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.TcpConnection.processReadPackets(TcpConnection.java:454) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:137) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:57) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.server.dedicated.DedicatedServerListenThread.networkTick(DedicatedServerListenThread.java:34) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:702) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:270) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:598) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) 2012-12-24 15:16:06 [iNFO] [sTDERR] java.io.IOException: Bad packet id 172 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet.readPacket(Packet.java:151) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.TcpConnection.readPacket(TcpConnection.java:320) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.TcpConnection.readNetworkPacket(TcpConnection.java:540) 2012-12-24 15:16:06 [iNFO] [sTDERR] at net.minecraft.network.TcpReaderThread.run(TcpReaderThread.java:23) 2012-12-24 15:16:06 [iNFO] [Minecraft] Player172 lost connection: disconnect.genericReason The data is sent correctly, as you can see in the Client log. In the case of the MCA_SYNC_REQ packet it is an entity's ID. However when the server receives it, data is null. If I skip sending the sync packet, I can successfully log in to the server. However when I send any other kind of packet, the same thing happens: no data in the received packet when there was data in it when it was sent. I have a feeling this is something simple I'm missing. Here's my updated source, all hard references to the client removed: https://dl.dropbox.com/u/64124307/Minecraft%20Comes%20Alive/Build/SRC.zip
  15. Alright, here's all of my code. https://dl.dropbox.com/u/64124307/Minecraft%20Comes%20Alive/Build/MCA%20v3.1.0%20-%20Source.zip
  16. I've checked those too and found nothing. Here's the classes the entity extends. EntityBase: http://pastebin.com/45r45ZYW EntitySerializable: http://pastebin.com/n767G0iD
  17. 1) I'll do that. 2.)My bad, I removed javadoc like an idiot so that just the code was visible. Egg: http://pastebin.com/Vef8fngk EntityVillagerAdult: http://pastebin.com/hiDcfvXN
  18. Whenever I try to spawn an entity that belongs to my mod in SMP, it throws this error and crashes. 2012-12-23 21:33:03 [sEVERE] [Minecraft] Encountered an unexpected exception NoClassDefFoundError java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityClientPlayerMP at mca.ItemEggMale.spawnVillager(ItemEggMale.java:105) at mca.ItemEggMale.onItemUse(ItemEggMale.java:83) at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:135) at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:424) at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:579) at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79) at net.minecraft.network.TcpConnection.processReadPackets(TcpConnection.java:454) at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:137) at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:57) at net.minecraft.server.dedicated.DedicatedServerListenThread.networkTick(DedicatedServerListenThread.java:34) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:702) at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:270) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:598) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497) at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) Caused by: java.lang.ClassNotFoundException: net.minecraft.client.entity.EntityClientPlayerMP at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:179) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 15 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/EntityClientPlayerMP for invalid side SERVER at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:38) at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:222) at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:171) ... 17 more I understand what the error means, but neither the egg nor the entity reference EntityClientPlayerMP anywhere. The only kind of player I use is EntityPlayer. Code for the egg: http://pastebin.com/HHReW9R2 Code for the entity: http://pastebin.com/1jjAsd6N Why is this happening if I don't use EntityClientPlayerMP?
  19. Got it figured out. I was handling my inventory GUI completely wrong, nothing to do with the code I provided.
  20. Where the client changes a value, I send a "fieldValue" packet to the server, which assigns that field's value to the server-side entity. As in: hearts += heartIncrease; PacketDispatcher.sendPacketToServer(PacketCreator.createFieldValuePacket(entityId, "hearts", hearts)); I played around with removeItemFromPlayer without any real progress, so I tried throwing out some more packets when the player's inventory changed. I believe I may have found a solution, currently testing it.
  21. The new Forge update organized Minecraft's source into packages, effectively breaking all of your previous imports. If you're using Eclipse, click your mod's package and press Ctrl+Shift+O to make Eclipse try to resolve the import errors. Whatever it doesn't fix, you'll have to find and type it in as an import. It usually does this with Block, Item, etc, since Forge contains classes with those names.
×
×
  • Create New...

Important Information

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