Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Goz3rr

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Goz3rr

  1. I had this issue with a few items in my mod.

     

    The end solution?

     

    Use a PlayerTracker, and a HashMap or similar to store the player instances and their corresponding Hook instances.  No need to edit base classes.  You would just query PlayerTracker.instance().getHookForPlayer() or similar, and set through PlayerTracker.instance().setHookForPlayer(EntityHook ent)

     

    If persistence across saves is needed, you can save all of the data out to a custom NBT file.

     

    Offtimes modding in MC is a game of compromise because of base-classes and inabilty to alter them.

     

    Very interesting, hadn't thought of that. Will look into it!

  2. So, i'm working on making a grappling hook. The actual hook itself is a EntityHook, like the fishing rod uses a EntityFishHook. The problem is, i need some way to store the EntityHook after i spawn it. Looking at the fishing rod, it uses the EntityPlayer.fishEntity field, which i can't since i'm using a EntityHook, not a EntityFishHook. Adding a field to the actual item won't work either, since that means it's shared across all instances of that item, and would probably glitch out. I looked into saving it to the player NBT thing, but i don't think you can write entities to it. Another possibility would be using ASM to add a new field to EntityPlayer, similar to fishEntity. What would be the best approach here?

  3. thanks for the answers, i actually ended up using a code similar to the one used in the furnace. i have 2 blocks and switch between them with setblockwithnotify(), and they have different textures.

    @jammas615: i found out that it was exactly the "this" that was causing problem, because it pointed at TestBlock class which is the class for every Test Block in the world, not a single instance... thanks for making me understand that :)

     

    It would probably be better to switch between metadata in this case, unless you change stuff like light level. It'll save a block id for something else

  4. I've read the sticky, but a console log doesn't really seem needed here.

     

    I'm using MC1.3.2, Forge 4.1.4.272 and FML 3.1.15.378

     

    To reproduce this:

    Make a class subscribed to LivingDropsEvent, run this code on that event:

    	ModLoader.getMinecraftInstance().thePlayer.addChatMessage(event.source.getSourceOfDamage().getClass().toString());		
    	ModLoader.getMinecraftInstance().thePlayer.addChatMessage(event.source.getEntity().getClass().toString());	
    

     

    Kill an animal, chat will show "class net.minecraft.src.EntityPlayerMP" twice, which is the player. Shouldn't getEntity() return the entity that died?

     

    The wiki says:

    Calling source.getEntity() will return an Entity if the damage source is an entity or null otherwise.

     

    And when looking at DamageSource.java:

        public Entity getSourceOfDamage()
        {
            return this.getEntity();
        }
    
        public Entity getEntity()
        {
            return null;
        }
    

     

    what.

  5. Unfortunately, the given code won't compile on the server, as there is no ModLoader.getMinecraftInstance there. It may be possible to compile it on the client and then put it into the server file, but even if that would work, it would be absolutely bad coding style.

     

    You do realize that the second if statement shouldn't even be in the server code right?

  6. Hi there!

     

    Currently i'm in the progress of porting my mods over to multiplayer, and my 'weapon' of choice was the Forge Modloader.

    While working on said task, to be precise my LambChop mod, i found out that Forge does infact change the EntitySheep class, but does nothing with dropFewItems, the function that decides what item should be dropped by the sheep. The current code that i'm adding right now isn't that huge:

     

            int var3 = this.rand.nextInt(2) + 1 + this.rand.nextInt(1 + par2);
            
            for (int i = 0; i < var3; i++)
            {
                if (this.isBurning())
                {
                    this.dropItem(mod_LambChop.LambChopCooked.shiftedIndex, 1);
                }
                else
                {
                    this.dropItem(mod_LambChop.LambChopRaw.shiftedIndex, 1);
                }
            }
    

     

    But it seems to me it would be a better option if forge added a hook for this, and i'd just use that to do my item dropping!

    Now i'm very new to Forge, and i have no idea if i'm totally missing a hook that already exists, or no one really cares about a hook like this existing, but atleast it would give me a peace of mind that pretty much any mod using forge is going to be compatible with the mods i'm making since i no longer need to fiddle around in this baseclass!

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.