Jump to content

Jade_Knightblazer

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by Jade_Knightblazer

  1. Looking for a method that will allow me to tell if a player has certain armor equipped or not. I use the public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){} Method to perform a special ability. Which works while in the players inventory, however not when its equipped. So I am wondering if there is another way I can keep performing updates while the armor is equipped.
  2. Got it, found http://www.minecraftforge.net/wiki/Tutorials/Packet_Handling. I am sure most of my stuff is chopped up but.... lol it works
  3. Ok, ran into a problem with my Time clock thingy.... This code works 100% when running the client, however has a Null Pointer error if you try to connect to a server. public void onTickInGame() { //System.out.println("onTickInGame"); //TODO: Your Code Here Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.thePlayer == null || mc.theWorld == null) return; { EntityPlayer p = mc.thePlayer; //PhantomClock time. mod_AsgardShield.playerGPS = p.dimension; mod_AsgardShield.phantomClock = MinecraftServer.getServer().theWorldServer[0].isDaytime(); So I placed a Null catcher If statement to make sure the error doesn't crash the game. And then waits for the serverTickHander to do its job. if (MinecraftServer.getServer() != null) { mod_AsgardShield.phantomClock = MinecraftServer.getServer().theWorldServer[0].isDaytime(); } if (MinecraftServer.getServer() == null) { //System.out.println("Server do your Job"); } Now I created this for the my ServerTickHander. Which btw I hope I sliced it up correctly, since there is no template anywhere . This part here is my server tick which tells my clock if its day or night. public void onTickInGame() { //System.out.println("onTickInGame"); //TODO: Your Code Here MinecraftServer mcs = FMLServerHandler.instance().getServer(); if (mcs == null) return; { //PhantomClock time. //mod_AsgardShield.playerGPS = p.dimension; //if (MinecraftServer.getServer() != null) //{ //mod_AsgardShield.phantomClock = MinecraftServer.getServer().theWorldServer[0].isDaytime(); //} //if (MinecraftServer.getServer() == null) //{ //System.out.println("need server info"); //} mod_AsgardShield.phantomClock = mcs.theWorldServer[0].isDaytime(); } System.out.println(mod_AsgardShield.phantomClock); } Now this works for the server (By the readings isDaytime() returns correct true and false in the cmd prompt), however my mod_AsgardShield.phantomClock never gets updated by the Server, and sticks with clients preInt vaule. SO... Server tells one thing, and the Client only knows the other. I never messed with Server packets, what code would I use here?
  4. The dial was a bad idea sadly, however I figured it out. Time is not handled well on the client. Not sure why, but that is a no no. Instead it must be aquired from the server so... I made a static boolean in my mod_class. public static boolean phantomClock; Then in my clientTickHandler, under my tickInGame. mod_AsgardShield.phantomClock = MinecraftServer.getServer().theWorldServer[0].isDaytime(); Finally under my Custom Common Item.class public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { if ("phantom".equals(asgardShieldType)) { if (mod_AsgardShield.phantomClock == true) { setIconIndex(36); } if (mod_AsgardShield.phantomClock == false) { setIconIndex(35); } } } This work the way I need it Now important question tho. I had to import net.minecraft.server.MinecraftServer; to my clientTickHander. Should I keep it that way? or create a serverTickHander and place my: mod_AsgardShield.phantomClock = MinecraftServer.getServer().theWorldServer[0].isDaytime(); in there instead. Nevermind, seems the client must have the server info to work correctly.
  5. Seems what ever I do, I can't get time of day to work correctly. Under my ClientTickHandler. System.out.println(mc.theWorld.isDayLight()); is always true. EntityPlayer.worldObj.isDayLight(); is always true. Under my Custom Common Item.class: onUpdate() Method: System.out.println(world.isDayLight()); flips back and forth randomly true and false... My goal is to have my iconIndex to switch to a different icon during the day, and change at night. However seems I can't get time to work I have tried using Entity.worldObj, EntityPlayer.worldObj, World, mc.theWorld., mc.thPlayer.worldObj, ect.... still not correct time.
  6. Full SmartMoving Interface Code. That was said to place anywhere long as it ran every tick. I have no more errors, however no response with SmartMoving either =/.
  7. Tried: With no red unline errors, however fails to hook into SmartMoving ;( net.minecraft.src.BaseMod mod = (net.minecraft.src.BaseMod)iterator.next();
  8. Honestly this is the only way I learnt how to figure out which mods are loaded, by Divisor. Also that code -snip- is placed in my OnTickInGame Method, in my ClientTickHandler of course.
  9. Hi, working on a compatibliy method to interface with SmartMoving Mod. Normally I use this line of code when using Modloader. Works like a charm and allow my mod to hook in. "Btw when I program with Modloader I use only .txt not eclipse" net.minecraft.src.BaseMod mod = (BaseMod)iterator.next(); However, while using eclipse and Forge. That line of code is red D: net.minecraft.src.BaseMod mod = (BaseMod)iterator.next(); Which states: BaseMod cannot be resolved to a type. Any solutions? Just for added help, here is the rest of the code... for this method.
  10. Figured it all out now. Thank you very much ShetiPhian. That Code -snip- works like a charm And Atomic helped set up the EventHookContainerClass. Your name has been added to the Special thanks Section on my mod's OP thread
  11. I'll try it Thanks. As for "my event handler", would I use my ClientTickHandlerAsgardShield. Or is the event handler a Common class I need to create? Or able to place in my Proxy.common I'll search around as well Reading: Atomic's http://www.minecraftforum.net/topic/1419836-131-forge-4x-events-howto/
  12. Hi, I am nearly finished with my mod. One last piece of coding is what I need for my whole mod to function. //Mod_shield par2 = mod_AsgardShield.calcDamage(par1DamageSource, par2, this); //end This little piece of code allows me to Lower the value of par2 (which is damage dealt by entity), before it effects armor, pot and player health calculations. My code is placed in the EntityPlayer.class (had to change the baseclass when using modloader , and hoping to avoid any class edits with Forge) protected void damageEntity(DamageSource par1DamageSource, int par2) { if (!par1DamageSource.isUnblockable() && this.isBlocking()) { par2 = 1 + par2 >> 1; } //Mod_shield par2 = mod_AsgardShield.calcDamage(par1DamageSource, par2, this); //end par2 = this.applyArmorCalculations(par1DamageSource, par2); par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); this.addExhaustion(par1DamageSource.getHungerDamage()); this.health -= par2; } As you can see, my calcDamage method is stored in my mod_AsgardShield.common/mod_AsgardShield.class I need help using the correct hook to achieve the same effect as I did when editing the EntityPlayer base class. Also I need help in general on how to use a hook @_@. Looking through all the different FML events, the one that seems suitable is the LivingHurtEvent. Which even then isn't achieving my goal, since I am not trying to do damage but rather reduce it. -Unless I could use a negative amount of damage to cancel out an Entities damage? Or, Maybe IsSpecialArmor the place I need to look? If there is no such event, May I Request an : Before ArmorProperties.ApplyArmor hook? Please any help will be most grateful and will allow me to release my mod.
  13. Cool thanks, with all the tutorials around (not many for forge). No one has ever pointed out there was a server debug mode in eclipse. I never used this coding program before and did all my work with .txt for modloader. Thanks for clearing that up and now hopfully I can use this tool to see whats going wrong. Still odd tho, even with Eclipse debugging, the server loads up the mod just fine. Its only after I .zip it and place in mods folder. /shrug Back to the drawing board.
  14. Be more easy to test if you could run the server on MCP with Forge installed.... Instead of skipping it. So I have to blindly hope SMP works while the Client runs smoothly. Its odd I used the same Mod.zip I have placed in my clients /mods folder. So all files are intact.
  15. Works fine on client, however Server is having its issues. ForgeModLoader-server-0 @_@, I feel like such a noob with Forge and SMP. I understand Modloader (client is this, and server is that) but for forge.... I feel like I am drowning.
  16. Thank you very much sir, just what I needed. A quick, simple, fix. Just switched my winrar to convert to .zip. Worked like a charm.
  17. While the mod completely works on eclipse, I can't load it with Forge on a normal game run. My mod_ class, hoping I have everything right in there. When I reobf, I get the following. reobf/minecraft Then two folders: AsgardShield and mod_AsgardShield. Do I need both and .zip them together or just mod_AsgardShield like I would do with Modloader. Lastly here is my ForgeModLoader-client-0. This is when I placed the two folders above in 1 .zip, and put them in the .minecraft/mods folder.
  18. Sweet Lex, please direct me . I been looking for a nice wiki or just a class file with all the hooks in it. (Only way I learn coding is to dive into it @_@ ) I really wish to take full advantage of Forge and would like to learn what it can do. You gave me a starting point, but please more info. -Thanks in advance Looking through all the events, only one seems sorta what I am looking for is: @Cancelable public class LivingHurtEvent extends LivingEvent { public final DamageSource source; public int ammount; public LivingHurtEvent(EntityLiving entity, DamageSource source, int ammount) { super(entity); this.source = source; this.ammount = ammount; } } But forgive me, how would I use it? @_@
  19. Could I use this same code for Item ID's too? and what would be the code for it
  20. Hiya, I am just about finished porting my "Asgard Shield" Mod to Forge and have ran into one last step. Are there any hooks I can use for this line of code I normally edit in the EntityPlayer.class "og.class" //Mod_shield par2 = mod_AsgardShield.calcDamage(par1DamageSource, par2, this); //end protected void damageEntity(DamageSource par1DamageSource, int par2) { if (!par1DamageSource.isUnblockable() && this.isBlocking()) { par2 = 1 + par2 >> 1; } //Mod_shield par2 = mod_AsgardShield.calcDamage(par1DamageSource, par2, this); //end par2 = this.applyArmorCalculations(par1DamageSource, par2); par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); this.addExhaustion(par1DamageSource.getHungerDamage()); this.health -= par2; } If no hooks are around, then am I still able to modify the EntityPlayer.class or have to use Player API?
  21. I still need help with this, seems the only Tutorials I am finding are for Modloader. ( I am well verse in modloader). However I want to learn FML, so taking methods one at a time. Right now I seem to fail at loading custom textures for my items. This is my code atm... package mod_AsgardShield; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.Block; @Mod(modid = "Jade_Knightblazer", name = "AsgardShield", version = "1.3.2") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class mod_AsgardShield { public static Item AsgardShieldWoodShield; @Init public void load(FMLInitializationEvent event) { AsgardShieldWoodShield = new ItemAsgardShield(400).setIconCoord(1,0).setItemName("WoodenShield"); GameRegistry.addRecipe(new ItemStack(AsgardShieldWoodShield), new Object[] { "XXX", "XXX", "XXX", 'X', Block.dirt }); LanguageRegistry.addName(AsgardShieldWoodShield, "Wooden Shield"); } } Where woudl I place the code for loading an ItemSheet.png AND will it work for thoses that use HD images later?
×
×
  • Create New...

Important Information

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