Jump to content

Gnomorian

Members
  • Posts

    30
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://www.crookedhill.co.nz
  • Personal Text
    Neither here or there

Gnomorian's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi, this is a follow up to this thread. so the setting the setTarget(null) and setRevengeTarget(null) yielded no results, so i decided to reperpose the EntityAINearestAttackableTarget task. i essentualy changed the shouldExecute() method to check if a player is in the vicinity and is wearing a ceretain helmet. if so re-search the area for hostile mobs and players without the helmet. then set the target to the closest as per useual. now this works perfectly with creepers, skeletons. but with zombies and wither skeletons they just stand there doing nothing even if hostile mobs are around. i have a demo of what happens (the end shows the zombies) i thought it may be the way i am replacing the tasks with the zombie, as it has 2 instances of EntityAINearestAttackableTarget (one for players, one for villagers), but the same issue is happening for wither skeletons, or because they behave normaly without the helmet, so that means it replaced correctly. does anyone know what i have done wrong, or overlooked. source code is here, you can download a compiled mod to test it yourself here. Event class Modified EntityAINearestAttackableTarget class.
  2. yea, i was aware of the events, but setting the attackee to null will be happening constantly if its the only player aound, was hoping to not add to the performance issues minecraft has when many mods are doing things like this all the time. well, ill use the event then.
  3. im new to reflection, im aware you can get Objects of methods in classes, maybe you can replace them with that, but im sure i will still have to do this for each entity when it spawns, which will be fine i guess.
  4. is there a way to "inject?" my own update method into existing mobs like skeletons or creepers, while still being loaded by forge, i have a piece of armor that i want them to recognise, and not attack the person with it, and even protect them, i know i could use entityupate event to check if its currently targeting a player with the helm and cancel it, but this will happen allot, im guessing it will be more efficent to either replace all skeletons for example that spawn in with a custom skeleton that has the changed ai, or inject a custom method into the skeleton before the game starts. is there a way to do the method replacement as, or another way of doing thing, thanks for the help.
  5. i dont think making a seperate program like that would be quicker. and i got it working. it was only like 30 odd lines for code to do it, but works fune now. thanks for then help.
  6. Curiosity, aswell as there being 80+ item classes, and initializing & registering them all is a pain, be even more of a pain when the next version comes round, the idea of this is to setup the item classes so they setup themselves (this.setunlololizedname();this.setTexture();this.setCreativeTab()), put them all in one package, get all the files within that package, build a class from each of them and initialize/register them all in a loop, then add them to a hashmap, the key being the unlocolized name. this means i can also easily use it in other mods aswell.
  7. i found an event i thought i could use, FMLConstructionEvent. but when i use it, all the urls in it, get resource("") : Enumeration<URL>, geturls : URL[], findResource() : URL all return null.
  8. Hi, im playing round with a dead mod someone has asked to come back, and it has over 80 items to add, i cant be bothered defining all of them in the useual way so im writing a method that gets all the classes within a directory, the items directory and initializes them for me, GameRegistry and all. now i am new to classloader, i did it in a test project like so: so as you can see, it worked perfectly in that example. however when i applied it to the mod, it gets stuck on ClassLoader.getResource(classPath); the exception is NullPointerException, but when i run it in debug mode, it clearly does get passed the directory of the item classes: EDIT: i found that i have to use FML's class loader, didnt realise there was more than one, its called: "LaunchClassLoader" and i did this: when it passes Url url = * url is null, it didnt get anything, the class path i gave it is right, does any one know what im doing wrong, help would be apreciated.
  9. your not getting my point i think, or i'm not understanding this, the thing that is strange is the when calling the event you say the display name is the only thing being changed, thats fine, thats meant to happen, the strange thing is that is not happening at all. it is not getting changed. according to that event anyhow. cording to the player object it is changed, the event said it isnt changed, if my saying that makes sence. however running the game with 2 clients has showed me that the displayName above the heads of the player doesnt update, found an event to render a nameplate above a player, but not edit or hide an existing one. thanks for the help.
  10. i cant set the username, its final. and when i set the username, cording to that, even the display name never sets, it always returns the old display name + old username. however iv just found when i call player.getDisplayName() it has the new one, this is really odd. ill try getting the server running and add 2 players to see if there nameplates change.
  11. this is correct, if(event.entity.worldobject.isremote){} then the code above goes in it. it turns out im wrong before, the event does call, i got the chat output when pressing the keybind: as you can see because of the test to see if isremote is true the display name remains Player312, every time i press the key it says the same thing however (other than the variable number at the end) the original name is always Player312 not the one it ses i changed it to: "players new displayname = Gnomorian9", does this mean that is a copy of the name so setting it is useless?
  12. im calling it from a keybind, im aware i need a packet to get this to the server, but i dont want the server to be involved, which is where the trouble is, when i surround the pasted code above with isremote, the name no longer changes, when i look at refreshdisplay name, it calls ForgeEventFactory which calls the event i posted above, which wont run because its surrounded with isremote, what a shame.
  13. hi i found an event PlayerEvent.NameFormat which i can use to set the players display name on login and get it to call again using the function refreshDisplayName() in EntityPlayer. @SubscribeEvent public void onLoginEvent(PlayerEvent.NameFormat event) { Random rand = new Random(); System.out.println("players displayname = "+ event.displayname); System.out.println("players username = "+ event.username); if(event.displayname.startsWith("Player")) { String name = "Gnomorian"+rand.nextInt(10); System.out.println("setting the display Name to: "+ name); event.displayname = name; } System.out.println("players new displayname = "+ event.displayname); System.out.println("players new username = "+ event.username); } although this doesn't work client side, was wondering if anyone knew a way to set it clientside.
  14. Hi, essentualy making a clone of Crafting Bench 2/3 as they both seem dead. im having trouble with checking if the player has the right items in their inventory or not. i have a function that runs during postinit to get the list of reciepes from CraftingManager and sort them into 2 lists, ShapedRecipe and ShapelessRecipe i then have a block, which when you right click on it calls the method that loops through your inventory and checks if you have the items required for the stored ShapedRecipe and ShapelessReicpe stored in the lists the last method is called by the block, it then loops through the filtered out "valid" recipes and prints out what you can make. it sort of seems to work, it finds some recipes, like it knows when you have 3+ planks, you can make slabs, but it doesn't recognize you can make sticks. if anyone can make heads or tails of what im mucking up here, your help would be apreciated, thanks.
  15. it would seem i dont, ill get onto that, thanks.
×
×
  • Create New...

Important Information

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