Jump to content

Recommended Posts

Posted

For some odd reason, the entity I created is spawning on the server, but not on the client. I have verified this with breakpoints (The loadedEntityList in the server world has the entity, the one on the client does not have the entity)

 

Code of relevant classes:

 

  Reveal hidden contents

 

The rest of the code is here: https://www.dropbox.com/s/3rth16yn14qzlk0/SimpleFrames.zip

Posted
  On 7/25/2014 at 12:12 PM, diesieben07 said:

@LaugingJackal: No! Do not use @SideOnly. Never ever.

 

ok, why should I never use @SideOnly? I know not for mobs I just checked my code, do you mean never for the entire mod or just the mob stuff?

Posted
  On 7/25/2014 at 3:28 PM, LaughingJackalMC said:

  Quote

@LaugingJackal: No! Do not use @SideOnly. Never ever.

 

ok, why should I never use @SideOnly? I know not for mobs I just checked my code, do you mean never for the entire mod or just the mob stuff?

 

He means (I think) that you should only use it when absolutely necessary, which should be infrequent.  Technically Minecraft and Forge could have let all classes be loaded on both sides (and just not call them when not needed) but as an optimization decided that server doesn't need to load classes related to GUI and user input stuff so used the SideOnly.  Therefore any code of ours that depends on classes with SideOnly technically also need to be SideOnly too, so it is sometimes needed.  It is common modding practice to move as much of that as you can into your sided proxy -- like registering renderers -- since this is major reason that we do the proxy stuff in the first place.  In other words you can put the functionality into the proxy and don't need SideOnly annotation because the proxy is already sided.

 

Otherwise you shouldn't create new hierarchies that are sided, since there really isn't that much use in the optimization of hiding a few classes.  Certainly you may still need to run code on only one side, but can just check for the side using world.isRemote instead.

 

Basically the SideOnly creates "weird" sets of classes that you have to manage and it is normally unnecessary.  It is not outright wrong, just troublesome.

 

At least I think that is part of diesieben07's aversion to it.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
  On 7/25/2014 at 12:12 PM, diesieben07 said:

@LaugingJackal: No! Do not use @SideOnly. Never ever.

 

@Shalashalska: Don't use registerGlobalEntityId. Use registerModEntity, then you don't need findGlobalUniqueEntityId either, you can choose any number between 0 and 255, because they are reserved for only your mod.

I can't seem to figure out what to put in for the mod object.

 

 

Posted

I made it use the registerModEntity method, but it still doesn't render.

 

New EntityManager.java

package com.simpleframes.entity;

import com.simpleframes.lib.Reference;

import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.Item;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;

public class EntityManager
{
    public static void preInit()
    {
        registerEntities();
    }

    private static void registerEntities()
    {
        createEntity(EntityMovingBlock.class, "MovingBlock", 0, 100, 1, true);
    }

    public static void createEntity(Class entityClass, String entityName, int entityID, int trackingRange, int updateFrequency, boolean sendVelocityUpdates)
    {
        EntityRegistry.registerModEntity(entityClass, entityName, entityID, Reference.MOD_ID, trackingRange, updateFrequency, sendVelocityUpdates);
    }
}

 

Edit: However, it now does exist in the client world.

 

 

Posted

The renderer is registered in clientProxy. Also, I have done some work with break points, and found out that the doRender method is being called, however, the clientside entity's block is null, therefore it can't get a texture and can't render.

Posted
  On 7/25/2014 at 4:59 PM, diesieben07 said:

  Quote
He means (I think) that you should only use it when absolutely necessary, which should be infrequent.  Technically Minecraft and Forge could have let all classes be loaded on both sides (and just not call them when not needed) but as an optimization decided that server doesn't need to load classes related to GUI and user input stuff so used the SideOnly.
No, I mean you literally should not use it, ever. It's a marker interface by forge that results in the merging process of Client & Server. We get 2 jar files from Mojang, the client & the server. Both contain roughly the same things, but the client has a whole lot more things and the server has some things too that the client have.

The decompilation process merges these two jars into one universal codebase, so that you can make only one mod jar that works on client & server. @SideOnly is a marker for you that tells you "oh, this class / method / field only exists in the Server / Client jar file". That means you can only use such a class / method / field only with care, because it doesn't always exist.

 

I understand that, but don't see how you can say "never".  If I extend a class and override a method that is already SideOnly, don't I have to also be SideOnly in my overriding method?

 

Yes you shouldn't create your own sided stuff, but if you're calling, extending, or copying stuff that is already sided don't you have to follow that?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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