-
Posts
440 -
Joined
-
Last visited
Everything posted by Flenix
-
(Sorry, won't let me quote you Alexiy) I've got as far as using scaled res; I just can't get my head around the math behind implementing it. I'm usually quite good at doing clever math calculations - it took me seconds to do what I was told was "impossible" and round a double to two decimal places, but I just can't get this one for some reason.
-
Hey guys, Sorry for this post, I probably seem a bit stupid but I can't get my head around this at all. I've asked 3 times on IRC but annoyingly every time, the person helping mysteriously disappears half way through... Anyway, what I want to do is have an overlay rendered on the screen. However, the overlay's position is set in the config file. So, for example, if the xPos number in the config was 60, the image would start rendering at 60,0 along the top of the screen. Initially, it works fine - but when the screen is rescaled (eg, full screen mode), they don't move to the correct position. I understand I need to use ScaledResolution, and I've got the integers for scaledWidth and scaledHeight. What I don't understand, is how to make those numbers interact with mine, to keep my stuff in the correct place. Can anyone give me a hand with this?
-
Hey guys, I'm working on a mod which does a total overhaul of the GUI system for general player info (health, hunger, the hotbar and so on). I've set it up so the entire mod is configurable, with just under 100 options to you can specify exactly where every widget should appear, when and if it should render and so on. I've also added a load of "widgets" with useful bits of info on (For example, coordinates, gamemode etc) Now, as the GUI is rendered constantly and can be altered later, I had an idea; I want to send a packet from the server to the client when the player joins, which sets the client's config to match the servers. That way, a server can design the layout how they like, and clients automatically have the layout pre-configured, per server, with no effort required on the players part. My question is; what is the best way to actually set this system up? I can send the packet with the info from the server to the client, but would I need a new "temporary config" class or can I just write it directly to the existing config? Is there maybe another issue I've overlooked somewhere? Thanks
-
Hey guys, Firstly, I apologize. I know I have seen a similar topic posted before, but nearly half an hour of searching and I can't find it for the life of me... Anyway; My food items use the onUpdate method to alter it's own NBT data. It does this in order to tick down a timer which will eventually make the food mouldy. However, the in-hand item texture tends to "flicker" randomly - just like when you right-click a block with an item. I'm assuming this is from the NBT being updated every tick, but initially it was annoying me. Now, I've noticed a bigger problem - due to this updating, the food doesn't display it's eaten animation properly. The animation starts, then it does it's flicker thing, and resets the animation. The problem here is this actually interferes with the ability to eat; you still eat as normal, but rapidly right-clicking will eat faster (when it shouldn't eat at all), and sometimes you'll eat one more after you stop holding right-click. So, does anyone know of any possible solution for my issues? If it's of any use, here's my class. Apologies for all the if statements, if you have a better idea to tidy that I'm all ears too http://pastebin.com/BuNYfngf
-
Finer control. Right now, I can only give between 1 and 20 for eating something. So, if I wanted the player to make a complex meal, there'd be no point - I'll explain in detail: Say you wanted to make a burger, you need these ingredients: 2 bread 2 lettuce tomato burger cheese bacon fries So, with just all the raw ingredients, and assuming it ALL gives one point each, that stuff would already restore 9 hunger points (almost half the bar). Something like a burger meal, I'd only want at the MOST to restore 10 points. Currently, why would the player bother with all the cooking and preparation for the sake of a single point? However, if I could raise the value to say 100, I could make my burger restore around 35-40 points. I could be a bit more varied with the ingredients too; salads being 1, bread 2, meats 3 (Giving a total of roughly 16) - This way, it'd be pretty stupid of the player to eat them raw, and they'll have to use my advanced cooking mechanics to make those ingredients into something interesting. See my point? I don't mind doing a bit of learning, as I imagine switching stuff over would be relatively simple to do compared to a lot of things. I would much rather go for a higher integer over a float though; if I chose a float, I can imagine all sorts of problems and conflicts with other mods which add food. EDIT: Would it maybe be easier/more reliable/generally better for me to disable and then recreate the food bar? If so how would I go about doing such a thing?
-
Hey guys, I want to modify the food bar. Right now, it's simply a value out of 20- in my opinion that really doesn't give us much creative freedom. So, I want to boost that limit to say, 100. Is something like this possible? Would I need to use ASM/Reflection or is there something clever I can do? I've never done anything like that before, how complicated is it considering I'm only really changing an integer (and I suppose potentially the bar's rendering; but we'll cross that bridge later and ignore it for now)
-
Hey guys, I'm trying to alter my item's display name based on it's current state. It's for food, so for example raw or burned (obvious), but also whether it was grilled, fried, roasted or whatever. The state of the food is stored in NBT- a float for how much it's been cooked (frozen -> raw -> undercooked -> cooked -> burned), and an integer for HOW it was cooked (only takes effect on the cooked status) For now I'm just focusing with the float. What I ideally want to do is pull both the state and the name of the food from the .lang file, then mash 'em together. However, even when I just directly return the exact name I want, it adds ".name" to the end. If I try and pull multiple strings and add them together, it returns what I typed, instead of checking the .lang files. Any ideas? It's worth pointing out I'm doing this in the getUnlocalizedName method (as advised in IRC), and I'm very new to using .lang files- this is my first time trying to use them.
-
Hey guys, I'm trying to set my block up so the texture changes depending on a value saved in the Tile Entities NBT. However, it seems the texture doesn't "refresh", so it never gets it's new state. Does anyone know a way to handle such a thing, or do I need to use TESR for it? I'd rather not mess around with metadata if I can help it. (Thinking about it, would TESR be better anyway? I'm texturing a gauge, each value from the NBT sets the gauge a little higher- I think it's how the Battery Cells in redpower worked? But maybe I can render the bar seperately with TESR? I dunno)
-
Hey guys, I'm trying to make an item which decays. While it's in your inventory, the onUpdate method triggers NBT which increases by 1 each time the method is called. However, when placed into a chest, it seems the onUpdate method stops; my timer no longer ticks. Firstly, is there any way to stop this happening? HOWEVER- I have certain containers (added by my mod), which I want this exact effect to happen. So, I need to stop it happening in most chests etc, but in these particular blocks it needs to freeze just like that. Anyone got any ideas?
-
Tile Entites, GUIs and player-entered information
Flenix replied to Flenix's topic in Modder Support
Perfect; been given the day off work today anyway so now I have something to do Cheers -
[Question] Is it possible to use blocks from other mods?
Flenix replied to ColdFox's topic in Modder Support
Apparently this is debatable. I've moved my stuff between preinit and init 3 or 4 times in the early days because people kept telling me one or the other was the "right" way to do it. A standardized option would be nice, but I think lex & the team themselves would have to say which is truly better. (It's worth noting though I do agree with you; I find having blocks in PreInit and recipes in Init just avoids messy little errors from having things in the wrong order. Just stating as I know it's debated a bit) -
Hey guys. I'm having some trouble with an idea. I've tried asking on IRC, but I figure it's something quite easy once you know it- so if anyone can just link a tutorial that'd be enough. Basically, what I need is the ability for a player to enter a value into the GUI of their TE, and this value is then displayed on the GUI. How would I go about doing something like that? I assume the value is saved in NBT, but how do I do that from the GUI? Also, will I need lots of nasty packets to move the value between server and client, or is there something clever that already does that for me?
-
Hey guys, So, I know 1.7 removes the old item ID system. I've also noticed a lot of modders recently started releasing "1.7 compatability patches" which seem to prepare their blocks and items for the transition. What I'm wondering is, what exactly are those mods doing with these patches, and what can we do to prepare? Obviously I don't want my users to lose my blocks from their worlds so I want to make sure everything ports over nicely.
-
It looks like that is used more for things like texture changes and visible differences. Right now everything I'm setting is supposed to be read server-side too, so I don't think that's going to really help at all... Anyone got any other ideas?
-
I don't think client/server sync is the issue here. The NBT is printing to console as default java values (0 ints, empty strings etc) on both the client and server. I'll research the AdditionalSpawnData thing though and see what it turns up
-
Hey guys, I figure you're all pretty knowledgable and I feel my Java skills increasing, so I want to try my hand at game development. I by no means expect to write the next Call of Duty or Battlefield, or anything complex. Nor do I expect it to be a fast and lucrative process. I do, however, want to make a simple, low-graphic FPS style thing. Something along the lines of 007 Goldeneye on N64 would be a good target. To be honest, world design is the bit I'm looking forward to the most but I'll focus on that later. The main thing I want to know right now, is where should I start? What software packages are good? I've looked briefly at Unity, but it looks like it might be restrictive further down the line as so much of the core is already written (I may be wrong there?). I'm not excessively fussed about the language I use for it to be honest, I'm doing this to learn new things so a new language would be interesting! As for platform, I'd like to run either on PC or Android. I've got myself an Ouya (well, a present for my 21st Birthday) so I'd love to be able to eventually release something on there. Anyone got anything to guide me?
-
Anyone got any ideas?
-
Hey guys, I want to render HTML code into a GUI. However, the only ways of doing this in Java that I know of require swing, and as someone on IRC pointed out that wont work in-game. I've seen other mods which have done things like this for an in-game browser but I'm doing something a bit different. Does anyone know how to do it? One of the mods wasn't ever released and the other is closed-source, so can't just check those...
-
Hey guys, I need to send and recieve data between Forge and Bukkit for an integration plugin I'm working on. From what I've heard, Plugin Channels MAY be the way to go. However, I can't find any examples of them in use. What I need to do is send a request from one side to the other to find out a double value, then send the relevant data back. For example, Forge asks Bukkit for the balance double, and Bukkit sends the balance back to Forge. From what I've read, though, these plugin channels may only be used on actual login? Is this true - if so, does anyone have any better ideas? Thanks
-
Alright, I think I'm still missing something. Right now, I'm setting the data hardcoded in my block class (where the mob spawn code is) just to try and pass it to my entity. Later, I'll be reading it from my Tile Entity but I want to get this bit working first. I've added a couple of println debug checks. The data seems to be there when it initially spawns but is instantly wiped. Any ideas? Below are my block and my entity classes: package co.uk.silvania.cities.core.npc.spawner; import co.uk.silvania.cities.core.FlenixCities_Core; import co.uk.silvania.cities.core.blocks.entity.TileEntityFloatingShelves; import co.uk.silvania.cities.core.npc.EntityBanker; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public class NPCSpawnerBlock extends BlockContainer { public NPCSpawnerBlock(int id) { super(id, Material.iron); this.setCreativeTab(FlenixCities_Core.tabCity); this.setHardness(2.0F); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); } public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } @Override public TileEntity createNewTileEntity(World world) { return new NPCSpawnerEntity(); } @Override public int getRenderType() { return -1; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float j, float k, float l) { NPCSpawnerEntity tile = (NPCSpawnerEntity) world.getBlockTileEntity(x, y, z); if (!world.isRemote) { if (tile != null) { EntityBanker banker = new EntityBanker(world); NBTTagCompound nbt = new NBTTagCompound(); banker.writeEntityToNBT(nbt); //For now, just hard-coding some test values to get the NBT block -> mob working. nbt.setBoolean("wander", false);// tile.wander); nbt.setString("playerName", "Blah" );//tile.playerName); nbt.setInteger("despawnTime", 12345);//tile.despawnTime); nbt.setInteger("heldID", 6);//tile.heldID); nbt.setInteger("helmetID", 7);//tile.helmetID); nbt.setInteger("chestID", ;//tile.chestID); nbt.setInteger("legsID", 9);//tile.legsID); nbt.setInteger("bootsID", 10);//tile.bootsID); nbt.setBoolean("entityLocked", true);//tile.entityLocked); nbt.setBoolean("entityInvincible", true);//tile.invincible); banker.readEntityFromNBT(nbt); //Ignore this bit - it doesn't need to be passed to the mob. banker.posX = x; banker.posY = y; banker.posZ = z; System.out.println("The offset values are: X:" + tile.offsetX + " Y:" + tile.offsetY + " Z:" + tile.offsetZ); banker.setLocationAndAngles((double)x + tile.offsetX, (double)y + tile.offsetY, (double)z + tile.offsetZ, 0.0F, 0.0F); banker.onSpawnWithEgg(null); world.spawnEntityInWorld(banker); } return true; } else { return false; } } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } } package co.uk.silvania.cities.core.npc; import co.uk.silvania.cities.core.CoreItems; import co.uk.silvania.cities.core.FlenixCities_Core; import co.uk.silvania.cities.core.NBTConfig; import co.uk.silvania.cities.core.npc.ai.NPCAITempt; import co.uk.silvania.cities.core.npc.spawner.NPCSpawnerEntity; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.IMerchant; import net.minecraft.entity.INpc; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIControlledByPlayer; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIFollowParent; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAIPanic; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAITempt; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import net.minecraft.world.World; public class EntityBanker extends EntityAnimal { boolean wander; public EntityBanker(World par1World) { super(par1World); this.getNavigator().setAvoidsWater(true); this.setSize(0.6F, 1.8F); this.isImmuneToFire = false; float var2 = 0.25F; this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new NPCAITempt(this, 1.1D, CoreItems.note10000.itemID, false)); this.tasks.addTask(2, new NPCAITempt(this, 1.0D, CoreItems.note5000.itemID, false)); this.tasks.addTask(3, new NPCAITempt(this, 0.9D, CoreItems.note2000.itemID, false)); this.tasks.addTask(4, new NPCAITempt(this, 0.8D, CoreItems.note1000.itemID, false)); this.tasks.addTask(5, new EntityAIPanic(this, 0.38F)); this.tasks.addTask(6, new EntityAIMate(this, var2)); this.tasks.addTask(7, new EntityAIFollowParent(this, 0.28F)); this.tasks.addTask(8, new EntityAIWander(this, var2)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(10, new EntityAILookIdle(this)); } @Override public boolean interact(EntityPlayer player) { //Right now this is just here so I can right-click the mob and printline what his NBT is as an in-game check. player.openGui(FlenixCities_Core.instance, 0, worldObj, 0, 0, 0); NBTTagCompound nbt = new NBTTagCompound(); readEntityFromNBT(nbt); return true; } @Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setBoolean("wander", true); } @Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); boolean wander = nbt.getBoolean("wander"); boolean locked = nbt.getBoolean("entityLocked"); boolean invincible = nbt.getBoolean("entityInvincible"); String playerName = nbt.getString("playerName"); int despawnTime = nbt.getInteger("despawnTime"); int heldID = nbt.getInteger("heldID"); int helmetID = nbt.getInteger("helmetID"); int chestID = nbt.getInteger("chestID"); int legsID = nbt.getInteger("legsID"); int bootsID = nbt.getInteger("bootsID"); System.out.println("NBT values are set as follows:"); System.out.println("Wander: " + wander); System.out.println("Locked: " + locked); System.out.println("Invincible: " + invincible); System.out.println("Player Name: " + playerName); System.out.println("Despawn Time: " + despawnTime); System.out.println("Held ID: " + heldID); System.out.println("Helmet ID: " + helmetID); System.out.println("Chest ID: " + chestID); System.out.println("Legs ID: " + legsID); System.out.println("Boots ID: " + bootsID); } public boolean isAIEnabled() { return true; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue(); } protected String getLivingSound() { return "mob.glog.say"; } protected String getHurtSound() { return "mob.glog.say"; } protected String getDeathSound() { return "mob.glog.death"; } protected void playStepSound(int par1, int par2, int par3, int par4) { this.worldObj.playSoundAtEntity(this, "mob.glog.step", 0.15F, 1.0F); } protected int getDropItemId() { return CoreItems.note1000.itemID; } public EntityAgeable createChild(EntityAgeable var1) { return null; } } Notice anything I've done incredibly wrong there?
-
Are there any examples of the above? That is what I'd tried first but it didn't work, and it wasn't until I looked at other entities that I thought something funny was going on. Also, diesieben - Maybe I misunderstood you, but how can I use the entityID there? It asks for the world and three ints, but I thought it would take those ints as coordinates, so if I throw an entityID there instead wont it just confuse everything...?
-
Hey guys, Does anyone know anything about opening a GUI on an entity? I want to add GUIs for my mobs. I explored the code a bit (looking at things like villagers & chest carts) - it looks like they all required something to already exist for them in the EntityPlayer class. I may be wrong about that, but that's what it looked like. Anyone know a way around this?
-
Hey guys, I'm currently working on (relatively simple) NPCs for my mod. I figured the best way for these to be really usable is to have a "spawn pad" which creates and destroys them as required. Players will have to use in-game money (items) in order to "keep" a mob spawned. What I want to know right now, is two things; 1. How can I spawn a mob with certain NBT values set? (I can do all the NBT stuff itself, just need to know how to set it on spawn from a block) 2. How would I use NBT to make a mob invincible? (I can see this being very useful on servers for NPCs at spawn who shouldn't be killed )
-
That fixed it, I just missed the !. That's the second time I've done that in two days, damnit... Thanks
-
Anyone at all? There must be someone who can spot my error? Even just redirecting me to another place I might be able to get help would be great...