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.

captaincleric

Members
  • Joined

  • Last visited

Everything posted by captaincleric

  1. Well, it appears to be reading from the correct- Wait no, I'm stupid. It's trying to load from a .json of the same file name. Now I feel silly. So, now it says it's missing a .mtl file. I suppose I'll just generate one with Blender and hope for the best.
  2. currentLine = "{" I have no idea where it's getting that from, because my .obj doesn't contain any curly braces. Here's the .obj in its entirity.
  3. So I'm trying to load a .obj file I created in Blender, but I'm getting a really strange error: The real offender is this line: String data = fields[1]; in the OBJModel.java class. Why is this happening, and what can I do to stop it?
  4. I'll give it a shot, thank you. Will report back with progress tomorrow.
  5. How would I go about ticking the player's mana so that it slowly restores using capabilities?
  6. I've done all of these, now. Thanks for the tips!
  7. Oh dear. That's embarrassing. That was from my first day of Minecraft modding and I haven't updated it since. Sorry about that! And no, I'm not calling it client side, but I am trying to fetch players the client side way, stupidly. I won't make that mistake again.
  8. Unfortunately, that's a little beyond my current experience. I'm sorry.
  9. Just tried it with a blank ITickable implementation: same error.
  10. This: http://www.minecraftforge.net/forum/index.php?topic=19726.0 might be what you're looking for.
  11. Yup, I can see it in the IDE. Also, I've tried running it in both IDE and regular Minecraft. Same thing happens in both. Here's the Gist:
  12. Ah, sorry, it's the registerTickable() method that's throwing it. I tried rebuilding all my forge and gradle stuff, as well as a brand new install, but it still throws that error. I'm using Forge 1764, I believe. EDIT: I tried it with a fresh install of 1722, as well. No dice. Still get the same error.
  13. (Sorry for the double post, but I've been messing around a bit.) So I've got it calling, but now it tells me there's NoSuchMethod. Here's the offending line: (Called in an event hook's OnWorldLoad() function) MinecraftServer.getServer().registerTickable(PlayerManaTracker.Get(event.world)); Now, doing MinecraftServer.registerTickable() tells me I can't use a non-static function from a static instance.
  14. It's not, but then I'm not sure I'm trying to call it in the right place. My ServerProxy.Init() method is trying calling it, but that method never gets called, either. Is that correct? And I put a breakpoint on the update() method; it never, ever gets hit.
  15. I tried this, but it doesn't seem to be working. No errors or anything, just doesn't bother calling the update() function. Thanks for pointing this out; I've never heard of it before, so I'll give it a shot. Will report back with progress.
  16. Pretty much as the topic describes, I've got an ITickable object that isn't ticking, and I'm not sure why. (It used to work) Here's the class: package com.nosrick.masterofmagic.trackers; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import com.nosrick.masterofmagic.MoMMod; import com.nosrick.masterofmagic.items.wands.ItemBaseWand; import com.nosrick.masterofmagic.packets.PlayerManaChangePacket; import com.nosrick.masterofmagic.utils.PlayerUtils; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ITickable; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; public final class PlayerManaTracker extends WorldSavedData implements ITickable { protected static final String s_Key = "MoMCraftManaTracker"; protected Map m_ManaTracker; protected Map m_ManaTickers; protected static final int STARTING_MANA = 100; protected static final int MAX_MANA_TICKER = 600; protected NBTTagCompound m_NBT; public PlayerManaTracker() { super(s_Key); m_ManaTracker = new HashMap(); m_ManaTickers = new HashMap(); } public PlayerManaTracker(String mapName) { super(mapName); m_ManaTracker = new HashMap(); m_ManaTickers = new HashMap(); } public void ModMana(EntityPlayer player, int value) { if(m_ManaTracker == null) { m_ManaTracker = new HashMap(); } if(m_ManaTickers == null) { m_ManaTickers = new HashMap(); } if(m_ManaTracker.containsKey(player.getUniqueID())) { int mana = (Integer)m_ManaTracker.get(player.getUniqueID()); ItemStack itemStack = PlayerUtils.FindWand(player); if(itemStack == null) return; ItemBaseWand wand = (ItemBaseWand)itemStack.getItem(); mana = Math.min(wand.GetMaxMana(), mana + value); m_ManaTracker.put(player.getUniqueID(), mana); } else { m_ManaTracker.put(player.getUniqueID(), STARTING_MANA + value); } MoMMod.s_NetworkChannel.sendTo(new PlayerManaChangePacket(m_ManaTracker.get(player.getUniqueID()).toString()), (EntityPlayerMP) player); markDirty(); } public void SetMana(EntityPlayer player, int value) { if(m_ManaTracker.containsKey(player.getUniqueID())) { m_ManaTracker.put(player.getUniqueID(), value); } else { m_ManaTracker.put(player.getUniqueID(), STARTING_MANA); } MoMMod.s_NetworkChannel.sendTo(new PlayerManaChangePacket(Integer.toString(value)), (EntityPlayerMP) player); markDirty(); } public int GetMana(UUID uuid) { if(m_ManaTracker.containsKey(uuid)) { return (Integer)m_ManaTracker.get(uuid); } else { m_ManaTracker.put(uuid, STARTING_MANA); return STARTING_MANA; } } @Override public void update() { List<EntityPlayer> players = Minecraft.getMinecraft().theWorld.playerEntities; for(int i = 0; i < players.size(); i++) { EntityPlayer player = players.get(i); UUID uuid = player.getUniqueID(); if(m_ManaTickers.containsKey(uuid)) { int ticker = (Integer)m_ManaTickers.get(uuid); ticker -= 1; if(ticker <= 0) { ItemStack wandStack = PlayerUtils.FindWand(player); if(wandStack == null) return; ItemBaseWand wand = (ItemBaseWand)wandStack.getItem(); if(!m_ManaTracker.containsKey(uuid)) { m_ManaTracker.put(uuid, STARTING_MANA); } int mana = (Integer)m_ManaTracker.get(uuid); if(mana < wand.GetMaxMana()) { m_ManaTickers.put(uuid, MAX_MANA_TICKER); ModMana(player, 1); } } else { m_ManaTickers.put(uuid, ticker); } } else { m_ManaTickers.put(uuid, MAX_MANA_TICKER); } } } @Override public void readFromNBT(NBTTagCompound nbt) { String allPlayersMana = nbt.getString("manaTracker"); String[] playersAndMana = allPlayersMana.split(","); for(int i = 0; i < playersAndMana.length; i++) { String[] split = playersAndMana[i].split(":"); UUID playerID; int mana; playerID = UUID.fromString(split[0].trim()); mana = Integer.parseInt(split[1].trim()); m_ManaTracker.put(playerID, mana); } } @Override public void writeToNBT(NBTTagCompound nbt) { String allPlayersMana = ""; Object[] players; Object[] mana; players = m_ManaTracker.keySet().toArray(); mana = m_ManaTracker.values().toArray(); for(int i = 0; i < m_ManaTracker.size(); i++) { allPlayersMana += players[i].toString(); allPlayersMana += ":" + mana[i].toString() + ","; } allPlayersMana = (String)allPlayersMana.subSequence(0, allPlayersMana.length() - 1); nbt.setString("manaTracker", allPlayersMana); } public static PlayerManaTracker Get(World world) { PlayerManaTracker data = (PlayerManaTracker)world.loadItemData(PlayerManaTracker.class, s_Key); if (data == null) { data = new PlayerManaTracker(); world.setItemData(s_Key, data); } return data; } } Unfortunately, for some reason, update isn't being called at all.
  17. Thanks, this is much easier! Got it working now, thank you.
  18. Somehow, that entity does not exist when I try to look it up on the server. Let me explain what I'm trying to do: When the user mouses over the wand in their inventory, a tooltip displays how much mana they have. The client sends a packet to the server to request the player's mana. The server then looks up the player (tried both EntityID and UUID) and their mana, then sends the player's identifier and mana back to the client, so that they can display it in the tooltip. Is there a better way of doing this, or am I just doing it wrong? (I'll post a whole ton of code if you need me to.)
  19. I'm having some trouble retrieving the player on the client side, as when the server sends a packet containing the only player's UUID, the client can't find that player. Why would this be? Here is the offending line: EntityPlayer player = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(playerID); playerID comes from a packet, which comes from the server. The server simply retrieves the requesting player's UUID using getPersistantID().
  20. Well, now I just feel silly. Thank you! It works now.
  21. I know this is more of a Java problem now (and I am truly thankful for the help), but it always seems to fail to find the asset, even though I appear to be pointing it to the correct path. InputStream stream = TextResource.class.getResourceAsStream("assets/" + MoMMod.MODID + "/text/life_magic.txt"); Now, I went into the .jar and looked for this file; it's there, so I don't know why it isn't finding it.
  22. Is this possible? I've created a TextResource class as detailed below: But I have no idea where it's looking for these files, or if it's doing it correctly. Every time I run it, it throws the exception saying the file can't be found, even though the path appears to be correct. Does anyone know anything about this, or is it better to load a file from outside of the jar?
  23. The signature you're looking for is: public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

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.