Jump to content

Recommended Posts

Posted

Heyho Guys!

 

I created two new types of fire, namely flash fire and hell fire. I wanted to create them via potion effects.

Everything works fine, except the rendering:

I have created an EventHandler for the Event

RenderLivingEvent.Post

. There, I test if the Potions are active and if so, I render the entity on fire. But unfortunately, this only works for the active player. Neither mobs nor other players with the effect applied are rendered on fire.

I think this is because the potions are controlled from the server, so the client doesn't need the active effects... But anyway, how can I solve this?

 

Code:

@SubscribeEvent
public void onRenderLiving(RenderLivingEvent.Post e) {
	if (e.entity == Minecraft.getMinecraft().thePlayer)
		GL11.glTranslatef(0.0F, 1.2F, 0.0F);

	if (e.entity.isPotionActive(ModPotions.flash_fire.id))
		this.renderEntityOnFire(e.entity, e.x, e.y, e.z, true);
	if (e.entity.isPotionActive(ModPotions.hell_fire.id))
		this.renderEntityOnFire(e.entity, e.x, e.y, e.z, false);
}

If I leave out the if statements, It works fine.

Posted

I think your title is misleading.

 

Minecraft.getMinecraft().thePlayer is a client-side method, which gets the player on the client side (this means for YOU only!)

When you call renderEntityOnFire, you are calling it on the "client side" once again.

 

You won't see it for other players (because it's client side) and you won't see it for mobs (because you never set it to render for mobs!)

Posted

I think, you understood me wrong. Well, it might be my fault because I didn't say this clearly:

 

The first if-statement is to remove a small bug where the fire is rendered below the player.

 

The last two if-statements control the actual fire rendering and they are called for EVERY entity.

As I said, the problem is the if statement which checks for the active effect, because if I leave it out everything is exactly as I want it to be.

Posted

OK, I now created some data storgae and packets and everything works except one thing:

 

If I register the EventHandler for the packet's sending method in my ServerProxy and start a Dedicated Server, everything works fine. But if I start my Combined Client and try a Singleplayer world, the event Handlers are not registered.

If I place them in the commonProxy (called on client & server) everything is fine, they are registered on BOTH sides. But I only want them to be registered on SERVER side.

 

Why does this not work???

Server Proxy:

public class ServerProxy extends CommonProxy {

@Override
public void preInit(FMLPreInitializationEvent e) {
	super.preInit(e);
}

@Override
public void init(FMLInitializationEvent e) {
	super.init(e);

	MinecraftForge.EVENT_BUS.register(new EventHandlerPotionUpdater());
	FMLCommonHandler.instance().bus().register(new EventHandlerPotionUpdater());
}

@Override
public void postInit(FMLPostInitializationEvent e) {
	super.postInit(e);
}
}

CommonProxy: (I removed unimportant stuff)

public class CommonProxy {

public void preInit(FMLPreInitializationEvent e) {
}

public void init(FMLInitializationEvent e) {
	//MinecraftForge.EVENT_BUS.register(new EventHandlerPotionUpdater());
	//FMLCommonHandler.instance().bus().register(new EventHandlerPotionUpdater());
}

public void postInit(FMLPostInitializationEvent e) {
}
}

Client Proxy:

public class ClientProxy extends CommonProxy {

@Override
public void preInit(FMLPreInitializationEvent e) {
	super.preInit(e);
}

@Override
public void init(FMLInitializationEvent e) {
	super.init(e);
	MinecraftForge.EVENT_BUS.register(new EventHandlerPotionRenderer());
}

@Override
public void postInit(FMLPostInitializationEvent e) {
	super.postInit(e);
}
}

 

Registration:

@SidedProxy(clientSide="com.bedrockminer.magicum.ClientProxy", serverSide="com.bedrockminer.magicum.ServerProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent e) {
	proxy.preInit(e);
}

@EventHandler
public void init(FMLInitializationEvent e) {
	proxy.init(e);
}

@EventHandler
public void postInit(FMLPostInitializationEvent e) {
	proxy.postInit(e);
}

Posted

You use the client proxy things only needed on the client, like rendering and textures etc, and the server proxy for things that should be registered both sides, like TileEntitys etc.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.