Jump to content

coolboy4531

Members
  • Posts

    584
  • Joined

  • Last visited

Posts posted by coolboy4531

  1. Thank you, I actually learned a lot with reflection.

     

    Now, here's the problem, I don't know how to implement it to the events.

    Too much .... Exceptions (NoSuchFieldException, IllegalArgumentException, etc.) idk.

     

    I feel so retarded.

  2. Okay, hold it.

     

    I need you to restate that, because my brain - just too much work and stress happenin' right now xD.

     

    So you are trying to tell me that the "instance" is the SRG name ("field_****")?

    If so, would Forge automatically change that when the srg name is changed - to the actual value instead of field_**** to (e.g. getBlockName() )?

     

    Also, how would I use it with the event?

     

    @SubscribeEvent
    public void onEntityJoinedWorld(EntityJoinWorldEvent event) {
    if (event.entity instanceof EntitySkeleton) {
    //what do I do here? 
    //do I do --  Field.set(instance, value) -- ?
    }
    }
    

  3. Yep, made perfect sense :)

     

    Although you can replace that field via reflection every time a skeleton is spawned (EntityJoinWorldEvent)

     

    Yeah, I was leaning towards that, I learned a few things about Java reflection but not so deep into that.

    If you can teach me a thing or two about how to replace that field, that would be greatful.

    (You don't have to show me like noob codes, just need to get some advice xD)

     

    If you would like to know how little I know about reflection I'll be happy to show what I know.

    I know how to use "Field" to get the private value.

     

    public class RandomClass {
    private String s = "hi";
    }
    

    public class RandomClazz {
    
      public static void main(String[] args) throws Exception {
        RandomClass randClass = new RandomClass ();
        Field f = randClass.getClass().getDeclaredField("s");
        f.setAccessible(true);
        System.out.println(f.get(randClass));
      }
    }
    

    In my opinion, I don't even THINK this would work, because it was a long time ago that I learned this :P

  4. Learnt how to change methods in ASM, was worth it. lol

     

    Now, I'm trying to learn how to change fields.

    They're probably extremely similar, and probably easy to grab on to but I don't know where to learn :P

     

    What I'm trying to do is lower the skeleton attack speed (I probably don't need to make a coremod, imo I don't know any alternatives)

     

    Converting:

    private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F);
    

    to

    private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 60, 60, 15.0F);
    

     

    Any suggestions?

  5. Break points are to separate things (its kinda complex don't want to explain now)

     

    Switches are used to do different things if the value of what is inside the switch corresponds to your case.

     

    For example, you should make your code like this:

     

             switch(ID){
             case mainRegistry.guiIDSaltFurnace:
                if(entity instanceof TileEntitySaltFurnace){
                   return new ContainerSaltFurnace(player.inventory, (TileEntitySaltFurnace) entity);   
                }
             break;
                   
                case mainRegistry.guiIDgrinder:
                   if(entity instanceof TileEntityGrinder){
                      return new ContainerGrinder(player.inventory, (TileEntityGrinder) entity);
                }
                break;
    

     

    In my opinion, I think you 'ought to know more Java before jumping into complex things.

     

     

  6. You don't get your item object from Items, because you never put it in there (its for vanilla items). You have to get the item object, from your OWN main class.

     

    Give us code, please. It was hard to understand what you were talking about, without code of course.

  7. Then why do it?

     

    mainRegistry:guiIDgrinder

     

    What is this suppose to be? The ID of the block/item?

    Come on dude, you should know that IDs were removed in 1.7 and uses the Block/Item object itself.

    Also, never use @SupressWarnings("unused") or other things that you have NO IDEA does.

     

    Another thing is to use context clues ("unused") = not being used.

    So why do you think it says "Connection lost?"

     

    If you give me more information of what you are trying to do with your switches, then I'll gladly help you out :D

×
×
  • Create New...

Important Information

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