The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
So, my mod implements a a new currency (Silver) and I am trying to make a gui container that, when the item is placed in the slot, it give a certain amount of money and takes the item. The problem is, the game crashes with a NullPointerException. This is caused by player being null; I know this because it saves the player username to a hashmap and the error is when getting the player username in my SilverKeeper. My question is, how can a get the player in a Tile Entity?
TileEntitySell:
package com.happycraft.happycraftmod.tileentity;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.happycraft.happycraftmod.utils.api.ExperienceKeeper;
import com.happycraft.happycraftmod.utils.api.SilverKeeper;
import com.happycraft.happycraftmod.utils.handlers.SilverValueHandler;
import com.happycraft.happycraftmod.utils.packets.PacketSilver;
import com.happycraft.happycraftmod.utils.packets.PacketType;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class TileEntitySell extends TileEntity implements IInventory {
private ItemStack[] inventory;
public SilverKeeper silver;
public World world;
public EntityPlayer player;
public SilverValueHandler silvervalues;
public ExperienceKeeper experience;
public Player par1player;
public TileEntitySell() {
inventory = new ItemStack[1];
this.player = setPlayerName(player);
}
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int i) {
int j = 0;
if (inventory[i] != null) {
for (int k = 0; k < inventory[i].stackSize; k++) {
Item item = inventory[i].getItem();
String s = item.getUnlocalizedName();
j = silvervalues.getSilverValue(s);
if (FMLCommonHandler.instance().getEffectiveSide().isServer())
silver.addSilver(this.player, j);
this.par1player = (Player) player;
PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketSilver(player.username, silver.getSilverTotal(this.player))),
(Player) player);
}
if (j != 0) {
inventory[i] = null;
}
}
return inventory[i];
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
inventory[i] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
itemstack.stackSize = getInventoryStackLimit();
}
}
@Override
public ItemStack decrStackSize(int i, int j) {
if (inventory[i] != null) {
if (inventory[i].stackSize <= j) {
ItemStack itemstack = inventory[i];
inventory[i] = null;
return itemstack;
}
ItemStack itemstack1 = inventory[i].splitStack(j);
if (inventory[i].stackSize == 0) {
inventory[i] = null;
}
return itemstack1;
} else {
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
return null;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this
&& player.getDistanceSq(xCoord + 0.5, yCoord + 0.5,
zCoord + 0.5) < 64;
}
@Override
public void openChest() {
}
@Override
public void closeChest() {
}
@Override
public String getInvName() {
return null;
}
public EntityPlayer setPlayerName(EntityPlayer player) {
return this.player = player;
}
@Override
public boolean isInvNameLocalized() {
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
}
SilverKeeper(Look at getSilverTotal with the EntityPlayer parm required):
package com.happycraft.happycraftmod.utils.api;
import java.util.HashMap;
import net.minecraft.entity.player.EntityPlayer;
/**
* addSilver and removeSilver are the only 2 you should use!
*
* @author HappyKiller1O1
*/
public class SilverKeeper {
private static HashMap<String, Integer> SilverValues = new HashMap<String, Integer>();
public static int getSilverTotal(EntityPlayer player) {
if (!SilverValues.containsKey(player.username)) {
return 0;
}
return SilverValues.get(player.username);
}
public static int getSilverTotal(String username) {
if (!SilverValues.containsKey(username)) {
return 0;
}
return SilverValues.get(username);
}
public static void setSilver(EntityPlayer player, int SilverValue) {
SilverValues.put(player.username, SilverValue);
}
/**
* Adds 1 Silver coin
*
* @param player
*/
public static void addSilver(EntityPlayer player) {
int i = getSilverTotal(player);
i++;
setSilver(player, i);
}
public static void addSilver(String username, int amount) {
int i = SilverValues.get(username);
i += amount;
SilverValues.put(username, i);
}
/**
* Add a specific amount of Silver
*
* @param player
* @param amount
*/
public static void addSilver(EntityPlayer player, int amount) {
int i = getSilverTotal(player);
i += amount;
setSilver(player, i);
}
/**
* Remove a specific amount of Silver coins
*
* @param player
* @param amount
*/
public static void removeSilver(EntityPlayer player, int amount) {
int i = getSilverTotal(player);
i -= amount;
setSilver(player, i);
}
}
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
The assigning was for testing but, your idea seems very likely to work. Could you provide a slight bit of example code for it? I would really enjoy a visual demonstration of what I need to do.
In the block class, you can see a lot of stuff in onBlockActivated method. This line is used to get the current tile entity for the block that the player "used":
...note that I need to cast it to my specific TE class, this is so I can operate with it's specific fields/methods (otherwise I will just get a generic tile entity which won't have my new stuff). You can see this later when I call "tryRemoveItem" with some parameters. tryRemoveItem is just a helper methods method, you can see in there how I talk to the tile entity from the block class. First I check a public field from it, itemSlotStatus, and it can call a method from this tile entity too - named "tryRemoveItem()". It has no parameters, as you can see from tile entity class it just returns an itemStack (or null if it can't). So, java stuff... you can have a method in your tile entity that takes EntityPlayer as an argument and does whatever you need.
For clarification/summary of what my shared code does, the Campfire is basically a machine for cooking food - but it has no gui, it will take food out of the players' hand (unless it already has maximum of 4 items in the campfire) or will remove cooked food from the campfire and give it to the player. Since I don't use a GUI, I don't need to mess around with packets or anything - everything is done server side.
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
Also, I took a look at your WIP mod and, I think you're doing a fine job. If I could, I would help you with creating it but, I am working on my own mod with similar expectations (Programmers and their expectations, huh? :P). Anyway, I can't wait to see what you do with it and if you need help with a leveling system or skills; those are already in my mod so I have a general knowledge of what to do. You're a marvelous programmer and I hope to work with you in future times.
Not quite, the other way around. You need to "send" the player to the tile entity, from the block class. The tile entity has no idea of what "player" is, if you want it to work on the player that activated it then you need to tell it which player activated it.
From onBlockActivated in the Block class, one of the parameters is player - this is the EntityPlayer that activated the block. So you need to tell the tile entity that this is the player it should operate on.
Something like this in your tile entity class:
public boolean doSomethingWithPlayer(EntityPlayer player)
{
// do something with the player
if (success)
return true;
else
return false;
}
...and something like this in your block class:
@Override
public boolean onBlockActivated(World world, int posX, int posY, int posZ, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
TileEntitySell tileEntity = (TileEntitySell) world.getTileEntity(posX, posY, posZ);
return tileEntity.doSomethingWithPlayer(player);
}
That's the general idea.
And thanks The skill/perk system isn't too difficult, in my opinion the GUI's and writing efficient client<>server synchronizing is the hardest part about that! The NPC system is the most difficult and I hope to work with ShadowMage in that regard, if not directly then he's already more than happy for me to implement his NPC code. But cool, it's still immature and I'm still new to modding so I'll accept contribution wherever I can get it - obviously everyone as their own ideas of how things should be, and I'm cool with friendly competition and sharing code for mutual benefit Mine is primarily a strategy mod, the role-playing aspects are strictly a second priority to that. But some of these aspects, like a skill to use advanced machines, magic, or to be a better combatant, are important for it - since the player gets to chose what they invest in for themselves and what they let their worker NPC's do. In fact a player could chose to be bad at machines/magic, combat, mining, and everything vanilla - instead putting all their skill focus towards making awesome NPC's for their Empire
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
I actually just fixed it by getting the player from the Minecraft class. XD Sometimes I am just silly and, I was wondering, I am trying to add perks but I just can't seem to figure out how I would make a perk system with a ever expanding menu with a scroll bar such as the select world menu. I feel that you might know how to do this. Any bright ideas?
I actually just fixed it by getting the player from the Minecraft class. XD Sometimes I am just silly and, I was wondering, I am trying to add perks but I just can't seem to figure out how I would make a perk system with a ever expanding menu with a scroll bar such as the select world menu. I feel that you might know how to do this. Any bright ideas?
That's actually not a good idea if you want compatibility with the server.
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
Actually, I grab the client only player (EntityClientPlayerMP) and, this will not, and I know this from experience, affect any compatibility with servers.
You mean getMinecraft? Well yeah that works, but only on the client. Using that means the mod will break if you try to run it on a (dedicated) server - so if you want to have SMP support in your mod you might want to change that
EDIT: As master801 said, it won't work on servers. getMinecraft() simply doesn't exist in server jar's. It's fine if you only want SSP but yeah, maybe make a note for later if you must... but really, it's very simple compared to what you have ahead so it might be best you do it now while it's fresh
Scroll bars are not something I've yet looked into, right now my (only) GUI just has dynamic pagination. But using glClip was suggested to me; drawing it all as one texture and clipping the texture as needed based on scroll I think is the general idea. But how to do the actual scroll-bar and such I really have no idea!
But I didn't realize the world selection screen has this, so surely we could check that out...
[Goes to check that out]
So it's GuiSelectWorld.class. It seems to have a nested class called "List" which extends GuiSlot, looks like it's easier than doing it dirty/manual with glClip and such. As for specifics I can't tell since it's mostly obfuscated of course. It seems that this list, or "container", will grow/scroll to match the number of "slots". I'm not sure what you mean by a scrolling GUI for a skill list, but mine would be graphical and wouldn't be ever-expanding - there would be one colum (or tab) for each skill tree, and each skill would be it's own icon - possibly with a number next to it if it has multiple levels. that descends vertically (where the first skill would be at the top). I can't think of a specific RPG that has this example, but I'll say like Dragon Age Origins only vertically since that's the most recent RPG I've played (EDIT: Incredible Adventures of Van Helsing is identical to how i want my skill tree to look, although it is far more fancy heheh. Picture here.)
The other type of skill I will have is only for NPC's, where each NPC has "experience" in a certain task e.g. lumbering, smithing, hunting/fishing, etc - and these would be a growing vertical list in their GUI. But this is still a while away for me.
Alas, I am working on the initial NPC's at the moment and expect to be working on conversation GUI's very soon - these will indeed be a fixed size and have a dynamic scroll bar based on content length. But I don't think this world select List class would help there, unless i wanted to have each line be a "slot" in the list... maybe it will be better to do it that way, too early for me to say. It still could take me a week to get this specifically done (I'm easily side tracked, and bugs happen lol) so yeah, won't be able to directly help until then sorry.
Feel free to give me more details on what you needed it for though, a crude mock-up would help a lot if you can be bothered to do that haha.
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
Well, a network is running a server for my mod and I use the getMinecraft() quite frequently throughout my mod and the server suits just fine. And, I don't know if you have ever played the game fallout but, that game inquires perks which, as you might know, give you certain advantages and disadvantages. My goal is to basically make a list where, every level up, you can choose a perk. I would need to use a scrolling list to be able to add more perks as I go. I also am in the process of making a chat GUI and actually, have gotton quite far. But again, I am not good with scrolling guis so it might take a bit. I think something you would really want to look at is the CubedMod. It was a unfinished mod but has some pretty cool preview videos that really inspired me to go all out with what I am doing. Also it might be good to mention that I am using 1.6.4 as my modding version. I am going to switch to 1.7 pretty soon though.
You're not using a *dedicated* server though, you're using the integrated server (the one built into the game). All the serious servers are dedicated and they have to be, because the dedicated server is the fastest way to run a minecraft server and when there are many players this is very important. Dedicated server Minecraft is a completely different "app" (jar file) and getMinecraft literally does not exist on the server. You can still use getMinecraft in your mod, it just must be client-side only - if the server tries to run it, like in the Block class (Blocks are run on server as well as client side) then the server will immediately crash when it gets to that part of the code. And it's a hard and nasty crash, depending on your code the world could be permanently broken until you remove/update the thing that's causing the crash.
In summary - getMinecraft() works fine on integrated server, I think, but dedicated servers will definitely crash.
Seriously, I won't go on about this - just trust me, it's a cold fact, if you want SMP compatibility, *only* use getMinecraft() in client-side tasks and *always* check for world.isRemote before doing so, unless it obvious (i.e. world.isRemote is important for blocks, they are run on both server and client; but renderers and gui's are only ever client so they don't need a side check).
Anyway, yeah of course I know Fallout - I know all legendary game franchises haha. I should have guessed you meant the perk system in it judging by the pipboy avatar!
Fair enough about the scroll stuff, but yeah as i said I can't help directly on this matter for the moment I'm afraid. I'll check out this CubedMod whatever it is [watches the Leveling and Perks Preview]... pretty cool! As a gamer I'm always interested in mods that try to make Minecraft more of a game rather than just throwing new things into the sandbox pile (I do like the sandbox aspects don't get me wrong, but you do get bored of building epic things to build/make for no reason other than to brag after a while heh). If you're doing something like this, maybe we can work together I will be mostly working on the strategy elements until further notice, because I'm honestly stuck on the whole adventuring/story side of things. I do want to do this still, but the strategy aspect is my main concern. Check the last couple of pages in my thread for details on this. If you've not seen it I made a compass, which is directly inspired by the Fallout 3/NV and Oblivion/Skyrim compass it will later show icons to represent locations and enemies too, but I'm not clear on how they'll work yet (enemies don't even spawn in my mod at the moment, I turn them off completely for the first part of the game otherwise it'll be too brutal). But anyway, enough talk about my mod. If you want to contribute or comment or whatever we can do that in the Empires thread
Regardless, I look forward to seeing the work you'll do.
I recommend updating to 1.7.x as soon as possible. While I've never modded on 1.6.x (I started a month or two ago and went straight to 1.7.10), I've seen enough to know that there are MANY changes. You might think that it's best to wait for Forge for 1.8, but really it'll be much easier to update a 1.7.10 mod to 1.8, since Forge/MCP have already changed a lot of things to try and predict the new 1.8 stuff (much of it is a guess, but others are definite e.g. the removal of item and block ID's).
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
I'll change it then. And, I'll have to go look at the compass; I am guessing you mean like the hud in Fallout (Which I have always wanted in minecraft). Also, Journey of Legends has some great quest files and, is open source. As for 1.7; I have been relenting to update because of how I couldn't seem to add biomes. After a while, my mod started to grow and now I have a bunch of files that will take me ages to update. Truthfully, if you can add biomes / dimensions again easily I'll update but I think I will have to stick to 1.6.4 for now considering my knowledge is based off it. I'll go talk to you on your thread a bit and look through to see if there is something you want to do that I know how to do. XD It's nice to meet someone that wants to make a mod that is more than just ores and blocks and such. Also, I love the banner "Open sauce" like damn that's good. XD
Yeah someone asked about biomes here recently, I did a search and couldn't find anything quickly - though I only spent a couple minutes looking, I remember reading about the new BiomeDictionary and I think perhaps everything is done there now (checks eclipse) yeah, looks like BiomeDictionary.registerBiomeType(biome, types) is the way to do it now. Dimensions I guess are done with DimensionManager, but I can't find any guide on this specifically either sorry. Hmm, well if you don't want to spend time experimenting and exploring, maybe stick with 1.6 for the moment then. I don't plan on any of these things for my mod (yet anyway) so I'm lucky there.
@Compass, here is the post (it has a picture). Extremely basic looking I know, just a placeholder as far as graphics go - but it functions perfectly
Regarding quests (I prefer the term "tasks" personally because Empires will be designed to be based on reality rather than mystical/fantasy stuff but they're essentially the same lol) I'll check it out, but it's not too difficult really. What *is* difficult, is how to actually implement them. I can make NPC's give them easily enough, or have them startable from anywhere easily enough - and also track them in the player journal and such, but the actual mechanics are difficult. I want them to generate structures/mobs/whatever on-demand i.e. when the player accepts them (otherwise they'll be futuristic things spawning in ancient age and that makes no sense) but in order to do that well I need to have some location awareness in the mod. This concept was labelled as the "topologic profiler" which would allow the mod to parse the world around the player(s) and act on it, with the goal of doing things like e.g. spawning a cave in the side of a mountain, which is the lair of a mutant bear (or something) that a quests asks you to kill. But the code required for this, i.e. to find the mountain and spawn the cave entrance in the side of it properly, is quite difficult, I'm sure you can imagine.
EDIT: Whoops, hit reply too early. Yeah I'll have a look at this Journey of Legends, is there something in particular that might interest me do you think? EDIT2: Found a spotlight for it, I see that you mean. Nice tip, thanks!
Anyway yeah, this thread is way off topic and we're bumping it with silly banter We can chat in PM/Skype or the Empires thread if you like, whatever suits.
@ Open sauce yeah it is haha, that was something Dulciphi said a while ago heh (a veteran player/tester/general friendly gal).
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
Back in 1.7.2 I tried biome dictionary with no success. I will just look into it and not be lazy. Mountains, I believe, are considered structures.So, I believe there is a method in World that allows you to find the nearest structure and I think you can go get that and move on from there. Or you can simply spawn a mountain structure in a random location within a certain amount of blocks from the player etc. I'll be adding quests to my mod pretty soon and, I will keep them as quests because my mod is meant to stay in a "mid-evil" type environment. For the JoL; I believe the level up system might grab your interest. I used it for my mod but I really want to make a gui for the leveling similar to the Fallout one (With the little arrow that goes up XD) but I am terrible with GL11 so that is far away. If you could, I would love to have your skype so we could chat although, my phone is not working at the moment so it might be a day or two before I can accept a friend request. Anyway, I am guessing you're quite good with GL11 and such considering how you made the compass so maybe you could help through Skype.
EDIT: Wow I'm talking a lot tonight, apologies! I'll make this my last post for this thread.
If mountains are considered structures and it's possible to get a handle on them, that'd be fantastic! The mountain was the hardest part! Dulciphi raised the idea of spawning a mountain with the cave in it, but really that'd be a bit strange - a mountain popping out of nowhere I'd want the mountain to be like a vanilla one too, with ore and stuff still in there and possibly trees/features around it or on top - so I'm not sure what to do there. But then again in later ages, there will be other tasks that involve more crazy things that probably will include dungeons being generated whenever a quest is accepted, and they'll just "pop-up out of nowhere" too. So yeah, dunno. I need more ideas on tasks/quests really to decide on how it's best to implement this "real-time generation" mechanic. But I'd be happy to work together on this if you like, we could develop a system for quests together - this way if both our mods were used together they could both integrate nicely in the same seamless way.
But yeah, within x blocks/chunks of the player is the main reason why it's simply a must that I do this during game time/on-demand instead of world generation. It also allows for biome-specific tasks/quests, e.g. if there's a lake nearby the hunter NPC could have some quest about something to do with water in order to learn the fishing profession (trying to think of a tasks that doesn't involve killing something here but I'm really stuck for ideas on that still, I dont want *all* tasks to be killing related).
Yeah that's cool, I assumed that you're going in a fantasy route. I hope I didn't give the impression that I'm not a fan of fantasy themed stuff (I did mention Dragon Age, didn't I?) just that, as you know, my mod will attempt to encompass a broader range. It is very likely that your mod will be playable much sooner than mine, I'm reaching very far with the claims of features in Empires haha! But that's cool, maybe when you release this mod you might be interested on working on the "Ava" faction fork on Empires, they'll be all fantasy and magical and such But no need to decide now, it'll be many months before any work on Tek/Ava can even start - and even then I will have a lot of work to do with Tek. Also one more thing about that, the whole Age thing is all experimental - someone raised the idea of having the split of Tek/Ava much earlier, i.e. at the end of the ancient age they can either go to Industrial Age (early Tek) or something like "Mystic Age" (early Ava). But yeah anyway, point is - everything about Empires is concept, so I welcome any ideas you might have - even if it's biased for your own mod in mind that's fine, as long as you're happy answering my many questions and need for details
Yeah I think I mentioned in the Empires thread, I don't really plan to have a "level up" system in Empires. I can't see how it'd fit in personally, simply because my focus is on the empire strategy and city building aspects. But don't take that the wrong way, this opens the door for us to have our mods work together if you're interested - and you can manage all that yourself, for the players who want a truly epic experience Reason for this is, not just because I have a massive enough amount of work already - but I'm sure you already realize, not all strategy/citybuilder players like RPG games and not all RPG players like strategy/citybuilder games. Personally I think they're nuts, but hey each to their own
Well, doing two little + and - buttons that add/minus to a number next to it is really quite easy, much easier than doing a scroll view!
I'm not adept with GL11 but I'm a quick learner (my professional job is primarily "R&D" in official terms, but really that involves RAD, Prototyping and Reverse Engineering 95% of the time - basically I'm a professional code hacker and cowboy programmer lol). Check out the Campfire for example, or perhaps the Player Log GUI - not amazing, but I like to think I am at least familiar with the concepts so far, decent for someone who only started Minecraft modding ~7 weeks ago I think heh. I'm reminded of the fantastic help I got from users here on the forum in my specific issues to get that far though, all credited in my mod info of course.
TileEntitySell:
SilverKeeper(Look at getSilverTotal with the EntityPlayer parm required):
Thanks in advance!
-Joey
Get the player from onBlockActivated or whatever, then send it to the tile entity instance via the usual method of block <> tile entity communication.
BlockCampfireLit.java
TileEntityCampfire.java
In the block class, you can see a lot of stuff in onBlockActivated method. This line is used to get the current tile entity for the block that the player "used":
...note that I need to cast it to my specific TE class, this is so I can operate with it's specific fields/methods (otherwise I will just get a generic tile entity which won't have my new stuff). You can see this later when I call "tryRemoveItem" with some parameters. tryRemoveItem is just a helper methods method, you can see in there how I talk to the tile entity from the block class. First I check a public field from it, itemSlotStatus, and it can call a method from this tile entity too - named "tryRemoveItem()". It has no parameters, as you can see from tile entity class it just returns an itemStack (or null if it can't). So, java stuff... you can have a method in your tile entity that takes EntityPlayer as an argument and does whatever you need.
For clarification/summary of what my shared code does, the Campfire is basically a machine for cooking food - but it has no gui, it will take food out of the players' hand (unless it already has maximum of 4 items in the campfire) or will remove cooked food from the campfire and give it to the player. Since I don't use a GUI, I don't need to mess around with packets or anything - everything is done server side.
And then in the onBlockActivated put this?
From onBlockActivated in the Block class, one of the parameters is player - this is the EntityPlayer that activated the block. So you need to tell the tile entity that this is the player it should operate on.
Something like this in your tile entity class:
...and something like this in your block class:
That's the general idea.
And thanks The skill/perk system isn't too difficult, in my opinion the GUI's and writing efficient client<>server synchronizing is the hardest part about that! The NPC system is the most difficult and I hope to work with ShadowMage in that regard, if not directly then he's already more than happy for me to implement his NPC code. But cool, it's still immature and I'm still new to modding so I'll accept contribution wherever I can get it - obviously everyone as their own ideas of how things should be, and I'm cool with friendly competition and sharing code for mutual benefit Mine is primarily a strategy mod, the role-playing aspects are strictly a second priority to that. But some of these aspects, like a skill to use advanced machines, magic, or to be a better combatant, are important for it - since the player gets to chose what they invest in for themselves and what they let their worker NPC's do. In fact a player could chose to be bad at machines/magic, combat, mining, and everything vanilla - instead putting all their skill focus towards making awesome NPC's for their Empire
That's actually not a good idea if you want compatibility with the server.
Just listen to CosmicDan on this one.
EDIT: As master801 said, it won't work on servers. getMinecraft() simply doesn't exist in server jar's. It's fine if you only want SSP but yeah, maybe make a note for later if you must... but really, it's very simple compared to what you have ahead so it might be best you do it now while it's fresh
Scroll bars are not something I've yet looked into, right now my (only) GUI just has dynamic pagination. But using glClip was suggested to me; drawing it all as one texture and clipping the texture as needed based on scroll I think is the general idea. But how to do the actual scroll-bar and such I really have no idea!
But I didn't realize the world selection screen has this, so surely we could check that out...
[Goes to check that out]
So it's GuiSelectWorld.class. It seems to have a nested class called "List" which extends GuiSlot, looks like it's easier than doing it dirty/manual with glClip and such. As for specifics I can't tell since it's mostly obfuscated of course. It seems that this list, or "container", will grow/scroll to match the number of "slots". I'm not sure what you mean by a scrolling GUI for a skill list, but mine would be graphical and wouldn't be ever-expanding - there would be one colum (or tab) for each skill tree, and each skill would be it's own icon - possibly with a number next to it if it has multiple levels. that descends vertically (where the first skill would be at the top). I can't think of a specific RPG that has this example, but I'll say like Dragon Age Origins only vertically since that's the most recent RPG I've played (EDIT: Incredible Adventures of Van Helsing is identical to how i want my skill tree to look, although it is far more fancy heheh. Picture here.)
The other type of skill I will have is only for NPC's, where each NPC has "experience" in a certain task e.g. lumbering, smithing, hunting/fishing, etc - and these would be a growing vertical list in their GUI. But this is still a while away for me.
Alas, I am working on the initial NPC's at the moment and expect to be working on conversation GUI's very soon - these will indeed be a fixed size and have a dynamic scroll bar based on content length. But I don't think this world select List class would help there, unless i wanted to have each line be a "slot" in the list... maybe it will be better to do it that way, too early for me to say. It still could take me a week to get this specifically done (I'm easily side tracked, and bugs happen lol) so yeah, won't be able to directly help until then sorry.
Feel free to give me more details on what you needed it for though, a crude mock-up would help a lot if you can be bothered to do that haha.
In summary - getMinecraft() works fine on integrated server, I think, but dedicated servers will definitely crash.
Seriously, I won't go on about this - just trust me, it's a cold fact, if you want SMP compatibility, *only* use getMinecraft() in client-side tasks and *always* check for world.isRemote before doing so, unless it obvious (i.e. world.isRemote is important for blocks, they are run on both server and client; but renderers and gui's are only ever client so they don't need a side check).
Anyway, yeah of course I know Fallout - I know all legendary game franchises haha. I should have guessed you meant the perk system in it judging by the pipboy avatar!
Fair enough about the scroll stuff, but yeah as i said I can't help directly on this matter for the moment I'm afraid. I'll check out this CubedMod whatever it is [watches the Leveling and Perks Preview]... pretty cool! As a gamer I'm always interested in mods that try to make Minecraft more of a game rather than just throwing new things into the sandbox pile (I do like the sandbox aspects don't get me wrong, but you do get bored of building epic things to build/make for no reason other than to brag after a while heh). If you're doing something like this, maybe we can work together I will be mostly working on the strategy elements until further notice, because I'm honestly stuck on the whole adventuring/story side of things. I do want to do this still, but the strategy aspect is my main concern. Check the last couple of pages in my thread for details on this. If you've not seen it I made a compass, which is directly inspired by the Fallout 3/NV and Oblivion/Skyrim compass it will later show icons to represent locations and enemies too, but I'm not clear on how they'll work yet (enemies don't even spawn in my mod at the moment, I turn them off completely for the first part of the game otherwise it'll be too brutal). But anyway, enough talk about my mod. If you want to contribute or comment or whatever we can do that in the Empires thread
Regardless, I look forward to seeing the work you'll do.
I recommend updating to 1.7.x as soon as possible. While I've never modded on 1.6.x (I started a month or two ago and went straight to 1.7.10), I've seen enough to know that there are MANY changes. You might think that it's best to wait for Forge for 1.8, but really it'll be much easier to update a 1.7.10 mod to 1.8, since Forge/MCP have already changed a lot of things to try and predict the new 1.8 stuff (much of it is a guess, but others are definite e.g. the removal of item and block ID's).
@Compass, here is the post (it has a picture). Extremely basic looking I know, just a placeholder as far as graphics go - but it functions perfectly
Regarding quests (I prefer the term "tasks" personally because Empires will be designed to be based on reality rather than mystical/fantasy stuff but they're essentially the same lol) I'll check it out, but it's not too difficult really. What *is* difficult, is how to actually implement them. I can make NPC's give them easily enough, or have them startable from anywhere easily enough - and also track them in the player journal and such, but the actual mechanics are difficult. I want them to generate structures/mobs/whatever on-demand i.e. when the player accepts them (otherwise they'll be futuristic things spawning in ancient age and that makes no sense) but in order to do that well I need to have some location awareness in the mod. This concept was labelled as the "topologic profiler" which would allow the mod to parse the world around the player(s) and act on it, with the goal of doing things like e.g. spawning a cave in the side of a mountain, which is the lair of a mutant bear (or something) that a quests asks you to kill. But the code required for this, i.e. to find the mountain and spawn the cave entrance in the side of it properly, is quite difficult, I'm sure you can imagine.
EDIT: Whoops, hit reply too early. Yeah I'll have a look at this Journey of Legends, is there something in particular that might interest me do you think? EDIT2: Found a spotlight for it, I see that you mean. Nice tip, thanks!
Anyway yeah, this thread is way off topic and we're bumping it with silly banter We can chat in PM/Skype or the Empires thread if you like, whatever suits.
@ Open sauce yeah it is haha, that was something Dulciphi said a while ago heh (a veteran player/tester/general friendly gal).
If mountains are considered structures and it's possible to get a handle on them, that'd be fantastic! The mountain was the hardest part! Dulciphi raised the idea of spawning a mountain with the cave in it, but really that'd be a bit strange - a mountain popping out of nowhere I'd want the mountain to be like a vanilla one too, with ore and stuff still in there and possibly trees/features around it or on top - so I'm not sure what to do there. But then again in later ages, there will be other tasks that involve more crazy things that probably will include dungeons being generated whenever a quest is accepted, and they'll just "pop-up out of nowhere" too. So yeah, dunno. I need more ideas on tasks/quests really to decide on how it's best to implement this "real-time generation" mechanic. But I'd be happy to work together on this if you like, we could develop a system for quests together - this way if both our mods were used together they could both integrate nicely in the same seamless way.
But yeah, within x blocks/chunks of the player is the main reason why it's simply a must that I do this during game time/on-demand instead of world generation. It also allows for biome-specific tasks/quests, e.g. if there's a lake nearby the hunter NPC could have some quest about something to do with water in order to learn the fishing profession (trying to think of a tasks that doesn't involve killing something here but I'm really stuck for ideas on that still, I dont want *all* tasks to be killing related).
Yeah that's cool, I assumed that you're going in a fantasy route. I hope I didn't give the impression that I'm not a fan of fantasy themed stuff (I did mention Dragon Age, didn't I?) just that, as you know, my mod will attempt to encompass a broader range. It is very likely that your mod will be playable much sooner than mine, I'm reaching very far with the claims of features in Empires haha! But that's cool, maybe when you release this mod you might be interested on working on the "Ava" faction fork on Empires, they'll be all fantasy and magical and such But no need to decide now, it'll be many months before any work on Tek/Ava can even start - and even then I will have a lot of work to do with Tek. Also one more thing about that, the whole Age thing is all experimental - someone raised the idea of having the split of Tek/Ava much earlier, i.e. at the end of the ancient age they can either go to Industrial Age (early Tek) or something like "Mystic Age" (early Ava). But yeah anyway, point is - everything about Empires is concept, so I welcome any ideas you might have - even if it's biased for your own mod in mind that's fine, as long as you're happy answering my many questions and need for details
Yeah I think I mentioned in the Empires thread, I don't really plan to have a "level up" system in Empires. I can't see how it'd fit in personally, simply because my focus is on the empire strategy and city building aspects. But don't take that the wrong way, this opens the door for us to have our mods work together if you're interested - and you can manage all that yourself, for the players who want a truly epic experience Reason for this is, not just because I have a massive enough amount of work already - but I'm sure you already realize, not all strategy/citybuilder players like RPG games and not all RPG players like strategy/citybuilder games. Personally I think they're nuts, but hey each to their own
Well, doing two little + and - buttons that add/minus to a number next to it is really quite easy, much easier than doing a scroll view!
I'm not adept with GL11 but I'm a quick learner (my professional job is primarily "R&D" in official terms, but really that involves RAD, Prototyping and Reverse Engineering 95% of the time - basically I'm a professional code hacker and cowboy programmer lol). Check out the Campfire for example, or perhaps the Player Log GUI - not amazing, but I like to think I am at least familiar with the concepts so far, decent for someone who only started Minecraft modding ~7 weeks ago I think heh. I'm reminded of the fantastic help I got from users here on the forum in my specific issues to get that far though, all credited in my mod info of course.
Sure thing, I'll send you my Skype name in a PM.