Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. What is your MItem? If it extends Item and your item is actually initialized using ItemX, then the problem is elsewhere. Could you please share whole code including item initialization, registry?
  2. He gave you (almost) working code. addRecipe(MyItems.someItem, "ABC", "DEF", "GHI", 'A', MyItems.someOtherItem, 'B', MyBlocks.someBlock, 'C', new ItemStack(MyItems.item3, 1, 3)); If you don't understand it, you need to learn Java. "x" - string 'x' - char In your recipy, you define pattern using 3-letter strings like "XYZ" or " X" or "X X" or whatever. Then you associate a char 'X' 'Y' and 'Z' (or ANY other) with some item or itemstack (if you want to utilize itemstack's meta as ingredient). It won't get simplier than that and you won't get working code here - forum is for Java coders and forge modders in need of help, not java kindergarten. Again: addRecipe(OUTPUT ITEMSTACK, 1PATTERN, 2PATTERN, 3PATTERN, CHAR, ASSOCIATED ITEM, CHAR, ASSOCIATED ITEM) This will create 3x3 pattern in your crafting grid, and use CHAR and ASSOCIATED ITEM (always one after another) as key. or addRecipe(OUTPUT ITEMSTACK, PATTERN, CHAR, ASSOCIATED ITEM) Will make 1x3 pattern with one definition. Can i be more clear? Btw. write in google something like: "GitHub <SomeModName>", you will probably find likt to src code and you can lookup all stuff you want. https://github.com/Glitchfiend/BiomesOPlenty/blob/3cdb526f0defbcfe6f49153d01d9d601c5b31b20/src/main/java/biomesoplenty/common/core/BOPCrafting.java
  3. Yeah, exacly - "TOTALLY Client". Guis (classes) are not present on Dedicated server. If you want to use this method you will need to call it via proxy. Common = return, Client = mc.displayGuiScreen(...) As to "right way" - it's comatybile with anything else, it's just a normal call for gui that is not including forge in process. If you want you can still use player.openGui and put some irrelevant stuff in arguments (like 0 0 0) and ofc. inside your GuiHandler for server side elemnt you will return null. Yet I don't know if this won't make your mod require server side (it probably will).
  4. Wasn't EnumHelper moved to: net.minecraftforge.common.util; - Idk, I am on 1.8, it was moved on 1.8 or earlier.
  5. If you want to open it TOTALLY client side, then: mc.displayGuiScreen(new MyGui());
  6. GUI != Container. To just open gui you don't need to pass any special coords, you can even pass something else - you literally have 3 integers that you may wanna use to send some ID for example. If you want to open Gui that is connected with block's container (TileEntity) you need to pass proper coords of given block. If you want to open some other inventory that the one held by player (horse for example, just note that horses are NOT using forge system, I am just giving example of inventory), you will probably need to send that entity's coords to know where the container is opened (not necessarily).
  7. To note few facts: 1. You send packet from client to server, you don't have to use any kind of checks, proxies, if statements, because you KNOW that receiver IS server. 2. After receiving msg on server you can pull player instance from msg context to know who send message. 3. What you are after can be executed directly in handler (in 1.7.10) - I don't think making !isRemote is even necessary (maybe). In 1.8 it will look differently (you will need Runnable, but that is note for future updating). As to proxies - yes, they are totally useless here. P.S i might be missing the point of problem in question.
  8. Some code maybe? Crash? http://4.bp.blogspot.com/_D_Z-D2tzi14/S8TRIo4br3I/AAAAAAAACv4/Zh7_GcMlRKo/s400/ALOT.png[/img] http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html
  9. private static int maxItemAmount = 10; @SubscribeEvent public void PlayerTickEvent(TickEvent.PlayerTickEvent event) { if (event.phase == Phase.START) { if (!event.player.worldObj.isRemote) { int count = 0; for (int i = 0; i < event.player.inventory.mainInventory.length; ++i) { ItemStack stack = event.player.inventory.mainInventory[i]; if (stack != null) { if (stack.getItem() == Items.stick) { count += stack.stackSize; } } } while (count > maxItemAmount) { event.player.inventory.consumeInventoryItem(Items.stick); --count; } } } } Example of working code. Now the flaw is - server may be consuming items but will not send packet to client. I've tried using event.player.inventory.markDirty(); but this got me nowhere. You have to either send inventory packet on your own if any item was changed, or do this event on both sides. (without !isRemote). Seems like doing it on both sides will give you predicted effects P.S - oh and OBVIOUSLY, this code is SHIT (very-not optimal). Look at method i used and make some smart looping.
  10. Pretty much yeah, I remember having fun with editing it without events pre-1.6 (I actually overriden whole GuiIngame that time) and rendering was a loop of drawTexturedModalRect methods that were set by player's health and food etc.
  11. I didn't look much but: propsChannel.registerMessage(propsPacketHandler.class, propsPacket.class, 1, SIDE THAT HANDLES PACKET); Should client be handler here? If not, lemme look deeper (your IMessage and Handler are cool, only flaw is your coding style - Class names should start Capital) Other: 1. Where are you calling registration? 2. How are your sendind packet, from where? (side) 3. Put prints in each method - at which one it stops (not called)? 4. Are your loops working? You are using size(). ^^ This might get you somewhere. I've never had this error, so might be missing something.
  12. Flaws of your code: public static CreativeTabs tabWeAreTheWarriorsMod = new CreativeTabs("tabWeAreTheWarriorsMod"){ @Override public Item getTabIconItem(){ return new ItemStack(itemcorruptedsoulgem).getItem(); } }; THIS IS BAD. getTabIconItem() should return Item, you don't need to make new ItemStack and then pull Item out of it. return itemcorruptedsoulgem; As to main problem - do you even recipe, bro? GameRegistry.addRecipe(new ItemStack(someItem, meta, quantity), new Object[] {"XXX", 'X', ITEMX}); "XXX" pattern 'X' - symbol definition start ITEMX - actual definition of X GO LEARN JAVA This is not modding if you can't solve simple stuff.
  13. Have you even looked at NBT methods? You actually don't need some of what you did at all. Things like rotation are saved inside NBT (print it out and see, or just look at code). Also it's "Health" not "health". There are also FEW health fields (HealF for example). You'd be better off reading callback hierarchy EDIT: Few things: 1. Not every entity has NBT, NBT is only created for "special" ones. That will be tamed, named with label or mobs with amour (and animals). Rest of them are spawned randomly via world spawner, not saved on disk and loaded later, so 1st check for NBT. 2. Tho I have no idea why it doesn't work - your entity IS being SPAWNED. It's location is 0,0,0 (auto-death) and I honestly have no idea why. Things like setLocationAndAngles seem to not be working. I only managed to make them work when i put them after spawn-code: worldIn.spawnEntityInWorld(entity); entity.setLocationAndAngles(event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, MathHelper.wrapAngleTo180_float(worldIn.rand.nextFloat() * 360.0F), 0.0F); entity.rotationYawHead = entity.rotationYaw; entity.renderYawOffset = entity.rotationYaw; The entity is being spawned at 0,0,0 and moved to x,y,z desired - that is NOT best way, but still - all happens in one chunk of code so it's literally like you would spawn it in x,y,z.
  14. You could try using GuiOpenEvent InitGuiEvent.Post to add new button to list, you could also probably access alredy created buttons and find the one you want to move and re-add it. Note: Your mod shouldn't edit whole GUI, rather make button-link to new window. EDIT: use GuiScreenEvent, it has access to initGui() (InitGuiEvent.Post), while open event is totally pre-init.
  15. Items as objects in any inventory won't get any updates. For that you'd need custom tileEntity container (which chest is not) that will scan and update items for you. The only inventory that updates items per-tick is player's Item#onUpdate() is called always when item is inside player's inventory. Item#onCreated is called when you create item in crafting process (and only), so pulling it out of e.g creative inventory won't call it. To execute some code on block break you can use: HarvestDropsEvent Share what you want to do, and we will help in better manner.
  16. Post your code?
  17. You are probably missing the idea. This event is called everytime for each overlay phase (HEALTH, CHAT, FOOD, etc.) on every tick frame. You just need to put your code in one of phases. The armour for your player can be pulled from mc.thePlayer.inventory.(...) (something with main and armour inventory and [.0],[1],[2],[3]) i belive your armour weight is saved inside NBT? You simply access it and draw.
  18. src/main/resources/assets/'modid'/lang/en_US.lang and inside: tile.<unloc name>.name=<ingame name> tile.ore_copper.name=Copper Ore
  19. One class: EntityLookHelper. Example of code (vanilla): this.theGolem.getLookHelper().setLookPositionWithEntity(this.theVillager, 30.0F, 30.0F); EDIT: Check out what happens there (self explainatory), it will take some time, but you should get it. Then you will need to use same mechanics to make your EntityFX have motion set in given direction. For that you might wanna look at EntityThrowable (arrows).
  20. You know, simple physics - there is speed, acceleration, time. If you would set motion x/y/z to exacly value "to ge from A to B" the particle would travel there in time=1[j] wheras [j] in MC is one tick. So computing this way is simply retarded, hence my question and statement "before I write something dumb". You either want a: - formula for speed of particle in time with acceleration. - forumla for speed of particle in time, without acceleration - formula for starting force that should be used on particle for it to travel from A to B (which in the end is actually 1st formula mentioned).
  21. This is 100% math, but before I write something dumb - what is "motion" is this case? You want to compute starting (in A) speed to make entity get from A to B wheras in B the speed will get to 0?
  22. Ernio

    Guns

    Then you (also in rightClick) will want to spawn particle - CLIENT side, in x/y/z of world where gun was shot (probably very near player). Particles are also pretty easy to spawn - most of the stuff you want to write is alredy in vanilla (for me, best teacher that ever existed). Example from TNT code: this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]); have look at TNT obviously and EnumParticleTypes. Rest is self-explainatory. For custom particles I don't have right to say anything (never used them yet), but stuff will be probably the same - extend EntityFX and do your stuff, then spawn in on lcient side. EDIT: Oh and sounds. It's literally same, you just do what vanilla does: world.playSound((double)x, (double)y, (double)z, "name", 100F, 1F, true); // look at the method itself. As for this, I am not sure (I am outdated here), but there might be methods to play sounds on client and on server, wheras playing them on server will cause all players in range hear them. There must be something on google for this.
  23. Ernio

    Guns

    Uhm, you will need to know stuff about: - Item - onRightClick method (in item) - server/client thread - understand that bullet is an entity, which is spawned into world on shoot (server side) - know how to operate on NBTTags to save ammo, reaload time, recoil and special attributes - RenderGameOverlayEvent will be useful to dosplay ammo / gui stuff onto screen - learn how velocity works (some math sometimes) and how stuff "goes" in world (bullets) Everything can be found: - Basic setup, using NBT (examples) http://www.minecraftforge.net/forum/index.php/topic,26267.0.html - Help understanding NBT (maybe) http://www.minecraftforge.net/wiki/Creating_NBT_for_items - Making game overlay http://www.minecraftforge.net/wiki/Gui_Overlay - Spawning entity (bulllet) into world: * You will need to look how fireball/snowballs are spawned in MC, quite easy (just look at vanilla) * Extend EntityThrowable and make bullets This all should give you everything you need to know. Also additional: If you'd like to save per-entity (per player for e.g) data like reloading or some timers - use IEEP (IExtendedEntityProperties) - 2nd post in link http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and EDIT: MOST of ALL - you will need to know JAVA and have patience to make this properly.
  24. "Dont use Id, so how can I set my items/blocks in a correct queue in a own tab?" Have look at displayAllReleventItems(List list) in CreativeTabs.class It allows you to make an ordered list for display (you need to use your own tabs ofc.) To make it "neat", you could do: (example on Block calss since I had one in IDE): public MyBlock(Material material) { super(material); MyTab.tabOrder.add(this); } And in your MyTab.class you would have: public static ArrayList<Object> tabOrder = new ArrayList<Object>(); Now one thing left is to use displayAllReleventItems(List list) to display stuff (have look at what vanilla does there). Obviously the order will be same as your initialization order and will work for both Block and Items (ofc you will need to do it well).
  25. OR use ItemSword. Anyone? No? Okay... ;_; p.s: lel.
×
×
  • Create New...

Important Information

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