Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. Above. I STRONGLY suggest following SOME tutorial. This one ships best simple examples: http://www.minecraftforge.net/forum/index.php/topic,26267.0.html
  2. Forge adds method in Item.class: /** * ItemStack sensitive version of getItemAttributeModifiers */ public Multimap getAttributeModifiers(ItemStack stack) { return this.getItemAttributeModifiers(); } You will need to design system that will be saving your attributes to NBT and them using #getAttributeModifiers you will check that NBT and return proper attributes.
  3. http://www.minecraftforge.net/forum/index.php/topic,31515.0.html
  4. That's not how you work with events. 1. @SubscribeEvent 2. You don't CALL event. 3. Event (this one) will be called everytime living entity dies and drops item. 4. Do not drop items manually - event ships List<EntityItem> drops - add/remove items to/from it. 5. NEVER do this: Item.getItemById(272) - as of 1.7 IDs SHOULDN'T be EVER used in code. - use direct item instance (e.g MyMod.theItem)
  5. 1. Pack all .png to 256x256 sheet. 2. Put that sheet somewhere in server files. 3. Create SpecialResourcePack extends AbstractResourcePack (or FileResourcePack). 4. Use packets (send .png as stream): either SimpleNetworkWrapper or setup your own sending (open new thread) 5. On receiver (client) side you will now have some .png - use SpecialResourcePack to load image as resource (inputStream). 6. Use: mc.getTextureManager().bindTexture(textureSheet); this.drawTexturedModalRect(x, y, u, v, 16, 16); To draw image. Note: Instead of writing whole new implementation of ResourcePack you can use FileResourcePack. 1. After finishing downloading .png, place it into .zip or .jar (on client side). 2. Load .jar/.zip as FileResourcePack. 3. That way you will also inherit file structure (e.g: assets/something/lol/textureSheet.png) of that .jar. Example of loading FileResourcePack: List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); defaultResourcePacks.add(new MyFileResourcePack(new File("C:/Users/Me/Something/.minecraft/theJar.jar"))); Minecraft.getMinecraft().refreshResources();
  6. There are like 5 ways of touching this. Some of them were used in old days (pre 1.6), some are quite new. You can: (listing most "sane", others are CoreMod-ASM and reflection) 1. Set health attribute of entity to something else on EntityJoinedWorldEvent. That "something else" has to be saved separately in IEEP. 2. Add modifiers to health. 3. Operate on floating point - health is nothing but float - you can make 20.0F be whatever you want. It's just a value. Problem lies rather in vanilla - I am not sure - it might be (almost sure) that vanilla trims float to int at some point (to make full numbers). If that is the case you can't really do anything with floats. In any of those ways you will most certainly run into fact that you WILL have to alter whole damage system. EDIT Note that while modifiers are synchronized internally, no matter what you do with them - changing BASE value of attribute is NOT. BASE value is set only only during constructing, if you decide to alter it - you will need to send packet to clients (all) about it. You will (probably) also need to send packet to all others that will "soon start to track" given entity #dynamicUpdates #startTrackingEvent
  7. http://images-cdn.9gag.com/photo/azbp0MB_460sa_v1.gif[/img] Jesus christ. I totally missed that for the packet to actually be sent server->client - you need to NOT return null o server...
  8. Show us your main class - mainly - where you register recipes. You most likely are registering them wrong or you are using stuff that is not yet initialized (e.g using your mods item before you create it).
  9. So I kinda touched piece of code I wrote long ago. Anyway: player.openGui, when called on: (logical side) * Client = will ONLY call #getClientGuiElement * Server = will call #getServerGuiElement and send packet to client that will call #getClientGuiElement. Yeah, all cool, so what's the problem? Try calling player.openGui in PlayerEvent.PlayerLoggedInEvent. Logically - it SHOULD open gui on client (given client has gui assigned to proper id). It doesn't. At first i though that maybe someone forgot about thread safety, but nope (OpenGuiHandler) - it is there. So question arises: Why does this work: @SubscribeEvent public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) { Network.sendTo(new PacketSendGui((byte) 1), (EntityPlayerMP) event.player); } @Override public IMessage handleClientMessage(final EntityPlayer player, final PacketSendGui message, MessageContext ctx) { Minecraft.getMinecraft().addScheduledTask(new Runnable() { public void run() { player.openGui(RoAMain.instance, message.id, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); } }); return null; } And this doesn't: public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) { event.player.openGui(Main.instance, 1, event.player.worldObj, (int) event.player.posX, (int) event.player.posY, (int) event.player.posZ); } I mean - it's literally same routine. <Looks at Guru diesieben>
  10. This needs more explanation. GUIs are client sided displays. You don't call values FROM them. You put values INTO them (onto display). Do I understand correctly - you have server-sided plugin that holds values about players (stats), and you want to display those values in player's GUI (as Forge mod)? What API is your plugin using? Basically you will need to setup packets server->client.
  11. What about constructor? EDIT post below: Just asking, I've seen many things, including messed up constructors.
  12. Why do you even have class-per block? To have block instance you don't need whole damn class for it. Suggestion: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe03_block_variants Have one block with metadata, if not even 1 block, still - ONE class. Not milions. Better suggestion: You kinda seem like you don't know how to properly use java. I mean - class-per-instance is either bad design or lack of knowlegde. Therefore - consider reading more on it.
  13. Item is something like "what is this thing I am holding?" ItemStack is the "THING I am holding." Item only tells game that stuff you hold should be treated as something. ItemStack actually holds data - it's itemDamage and/or NBT. Google NBT and how to work with it (a lot of tuts).
  14. Or this: https://github.com/MinecraftForge/MinecraftForge/pull/1885
  15. Warning! I am sorry, I had too good day
  16. Its The range at which MC will send tracking The frequency of tracking updates (thanks cpt. obvious!) I know, I know, HOLD your applause, I am but a humble helper.
  17. You can't use removeEntity - it removes entity, not kills it, therefore server removes it from world but client doesn't know it died - that is your ghost horse probably. You could instead of passing whole oldHorse into newHorse constructor, try only coordinates. Idk really.
  18. If you want to manipulate vanilla blocks you have two ways - replace vanilla and write whatever you want, or use Events. To change hardness of block you can use PlayerEvent.BreakSpeed, but that will be only for players, not e.g explosions.
  19. I think that's not what he wanted. EDIT: OP was faster You want to do something when player spawns in world for the 1st time right? You will need IExtendedEntityProperties - assign them to EntityPlayer on EntityConstructing event and save boolean there. Then use PlayerLoggedInEvent - check if boolean is false - if it is - do stuff and change to true. Yes, this is the only way to perform one-time action (you need to save it). EDIT As you mentioned teleporting on respawn - you will need to know it: Every player has EntityPlayer. Whem player dies, his entity will be assigned to "him" until he either leaves game or server OR click respawn button - on that moment, old Entity is lost and new one is created. If you want to move player (tp) after respawn you can use EntityJoinedWorldEvent or PlayerEvent.PlayerRespawnEvent. (EDIT) Try it.
  20. There are 3 methods responsible for dropping. When Block is broken, game asks "getDrops" for dropList - List<ItemStack>. To get full control over drops you can override it and simply return List containing whatever you want. If you don't want to override it - this method (getDrops) asks "quantityDropped" and "getItemDropped" for quantity and item of dropped item. You can override any of them to get what you want. getItemDropped + quantityDropped V getDrops V <- applies forge event finalList V drops ItemStacks. You can hook yourself anywhere.
  21. EnumChatFormatting! Do not reinvent the wheel please.
  22. Player's model and any other (maybe not all, I think dragon has few) model as you know it (vanilla) takes only one texture in consideration. It will then use this particular ResourceLocation and grab u/v coordinates from it which then will be placed onto model. Changing player's skin can be done in client-sided cache map which can be accessed via AbstractClientPlayer (you will need to dig deep and long and most likely use reflection). Aside from that - it will still give you one .png file. As i understand - you want to put player's texture from parts. In that case you will need to generate dynamic image. This is purely Java stuff - go goole it. This above would work like: 1. Gather few textures based on EntityPlayer 2. Blend them together into skin.png 3. Place skin.png into player's skin location 4. Lock skin-change (vanilla will try to override it) Above is how it can be done using vanilla itself. Other way is to totally ignore vanilla - in that case - indeed - you will use RenderPlayerEvent - cancel normal rendering (event.setCanceled(true)) and then render totally different model (custom copy of ModelBiped) that will accept few textures instead of one, or like proposed previously - will take one texture that is put together from parts. Note: If you want to save textures per-player you can utilize IExtendedEntityProperties. P.S - What I know is based off mod I made in 1.6.4 that was setting players' skins from server (not mojang). I never updated (and i plan to) because in 1.7 they added skin-caching, which gave me code-headache, so I postponed update.
  23. mc.fontRendererObj.drawString(getDamageString(new ItemStack(item)), x + 12, y1 + 10, 16777215); // This renders the durability to the screen You are making new ItemStack - it will be untouched. ItemStack's itemDamage = meta. You need to either do new ItemStack(item, 1, damage) or simply use ItemStack pulled from player. Item is just an instance, it's the ItemStack that holds data, pass that instead of Item. You shouldn't even make "new ItemStack" - ever. In most cases very bad, is some - it's just pointless. To get armour worn: Minecraft.getMinecraft().thePlayer.inventory.armorInventory[index]
  24. If Cauldron was TileEntity - sure you could then, but cauldron is not TE (sadly for you). Everything cauldron block knows is its 16 states (like any other block). And it cannot hold data. Your 2 options are: * Impement new Cauldron ("BetterCauldron") that will have its own TileEntity with IInventory. In this case you can also use BlockEvent.PlaceEvent to detect if block is Cauldron - and if so - replace it with your own Pros: Easier, more compatybile, less buggy? Cons: You still have vanilla cauldron left. * "Hack" into world and whenever Cauldron is loaded/placed - place TileEntity at its BlockPos. Utilize Forge events to launch interaction (lookup PlayerEvents - there are interaction events like block-clicking). Pros: You will simulate TileEntity at Cauldron pos, that will work for all vanilla Cauldrons. Cons: Will be probably HARD to hack your way into it as vanilla takes good care of badly assigned TileEntities (they are removed). Might even have to ASM. I'd go with 1st one - much safer! EDIT As to rendering - you will probably want to use TESR (google).
  25. If by NBTList you ment NBTTagList - I just relized that NBTTagString(string) is also an NBTTag. Before: NBTTagList strings = new NBTTagList(); NBTTagCompound nbt; for (String s : stringsToAdd) { nbt = new NBTTagCompound() nbt.setString("S", s); strings.appendTag(nbt); } Now: NBTTagList strings = new NBTTagList(); NBTTagString string; for (String s : stringsToAdd) { string = new NBTTagString(s) strings.appendTag(string); } This closes thread - SOLVED. Thanks for pointing it out!
×
×
  • Create New...

Important Information

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