Jump to content

[Solved] RenderLayer not rendering on multiplayer


Oscarita25

Recommended Posts

Okay i created a RenderLayer it works 100% in SinglePlayer

but it doesn't in multiplayer for other Players 

i think its because i use capabilities .. or at least i use them wrong for this :0

so the RenderLayer is shown if (int)capability x of Player is equal to (int)

 

@SideOnly(Side.CLIENT)
public class LayerEntityOnPlayerBack implements LayerRenderer<EntityLivingBase>{

    private final RenderManager renderManager;
    protected RenderLivingBase <? extends EntityLivingBase > Renderer;
    private ModelBase Model = new ModelParrot();
    private ResourceLocation Resource = RenderParrot.PARROT_TEXTURES[2];

    public LayerEntityOnPlayerBack(RenderManager rendermanager)
    {
        this.renderManager = rendermanager;
    }

    public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
    {
    	IModelID model = entitylivingbaseIn.getCapability(ModelProvider.MODEL_CAP, null);
    	BNHA.NETWORK.sendToServer(new MessageRequestModel());
    	
    	    	
        if (model.getModelID() == Reference.tail)
        {
            GlStateManager.enableRescaleNormal();
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

            	if(Renderer == null) 
            	Renderer = new RenderParrot(this.renderManager);
            	
            	Renderer.bindTexture(Resource);
            	
            	
                GlStateManager.pushMatrix();
                float f = entitylivingbaseIn.isSneaking() ? -1.3F : -1.5F;
                GlStateManager.translate(0.0F, f, 0.0F);
                
                ageInTicks = 0.0F;

                Model.setLivingAnimations(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks);
                Model.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entitylivingbaseIn);
                Model.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
                GlStateManager.popMatrix();
            

            GlStateManager.disableRescaleNormal();
        }
  }

    public boolean shouldCombineTextures()
    {
        return false;
    }
}

 

Edited by Oscarita25
Link to comment
Share on other sites

1 hour ago, Oscarita25 said:

Okay i created a RenderLayer it works 100% in SinglePlayer

but it doesn't in multiplayer for other Players 

 i think its because i use capabilities .. or at least i use them wrong for this :0

so the RenderLayer is shown if (int)capability x of Player is equal to (int)

 

does anyone know how i would do this :P

Link to comment
Share on other sites

7 hours ago, Oscarita25 said:

BNHA.NETWORK.sendToServer(new MessageRequestModel());

Good dear lord. 

You do understand that you are sending a packet to a server EACH FRAME with this code, right?

Do not ever do that. That is probably the worst thing you could do.

In addition a request packet is an indication of a bad design. The server knows exactly who needs the data and when to send it. Don't request packets from the client.

In addition your approach wouldn't work anyway because packets are handled by a different thread, meanung your rendering code just moves onwards without receiving the data from the server.

 

7 hours ago, Oscarita25 said:

if(Renderer == null) Renderer = new RenderParrot(this.renderManager);

But why do this if you can just get the existing renderer for the parrot?

 

I don't think yu need to normalize the normal vectors here, so enable/disableRescaleNormal is not needed.

 

How are you syncing the capability to the players involved? Show that bit of your code.

Link to comment
Share on other sites

Quote

public static CommonProxy proxy;

A CommonProxy makes no sense. Proxies exist to separate sided-only code, if your code is common then it goes anywhere else but your proxy.

 

Quote

serverSide = Reference.COMMON_PROXY_CLASS

This makes even less sense. A server proxy contains either NOOP implementations for client-only things or code that would crash the client. Your common proxy can't be your server proxy.

 

Why do you have multiple methods both subscribing to the same FMLLifecycle event? Why not use just one method?

 

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/data/packets/MessageEXP.java#L36

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/data/packets/MessageLEVEL.java#L36

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/data/packets/MessageModel.java#L36

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/data/packets/MessageNEXP.java#L36

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/data/packets/MessageQuirkID.java#L36

You can't do this, your handler is common, but this is client-only code. This will crash the server. You must use a proxy.

 

Quote

public class MessageRequest...

Just no. Get rid of all of your request messages. First of all the server knows when to send the data, so send it from the server when needed, don't ask the client. Second of all the client can and WILL abuse these request messages. Finally this is just extra network IO that wastes time.

 

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/data/packets/MessageRequestActivate.java#L64

Since you have no safety checks and just blindly trust the client a malicious client can easily abuse this packet to do whatever it wants, like cover the entire world in these entities, one per block.

 

The reason for your issue is that you only ever set the capability data for the model to the main client player. If you need the model data for another player then set it in their capability instance, not in the client's player.

 

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/init/ModItems.java#L38

Don't ever use static initializers for registry entries. Registry entries MUST be instantinated in the appropriate registy event. Using static initializers can and WILL cause issues.

 

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/items/ItemBase.java

ItemBase is pointless, there is already an ItemBase, it's called Item. Don't abuse inheritance.

 

Quote

implements IHasModel

IHasModel is the worst thing to ever exist on this planet. It is ugly, doesn't make any sense since all items need models anyway, makes you write extra code and makes your code that much harder to manage. Don't use it and just register your models in the modelregistryevent directly.

 

https://github.com/Oscarita25/BNHA/blob/master/src/main/java/com/oscar/util/LoggingUtil.java

Any reason for this class to exist? Like at all?

 

 

Link to comment
Share on other sites

2 minutes ago, V0idWa1k3r said:

This makes even less sense. A server proxy contains either NOOP implementations for client-only things or code that would crash the client. Your common proxy can't be your server proxy.

 

What is NOOP? yeah i understand that and i wanted to change that for a while just forgot about it because .. if it works it works (i will change it later)

 

 

4 minutes ago, V0idWa1k3r said:

You can't do this, your handler is common, but this is client-only code. This will crash the server. You must use a proxy.

 

 

i actually i can because those packets are registered for client side and won't be actually executed on server side! (i tested it on server it won't cause issues)
https://github.com/Oscarita25/BNHA/blob/0d4dbc2c3f7e5f7bad430f8d129aea5594d83399/src/main/java/com/oscar/proxy/CommonProxy.java#L78
 


 

6 minutes ago, V0idWa1k3r said:

Just no. Get rid of all of your request messages. First of all the server knows when to send the data, so send it from the server when needed, don't ask the client. Second of all the client can and WILL abuse these request messages. Finally this is just extra network IO that wastes time.

 

okay i understand that this is bad code can you give a example code of how to do it much better and optimized?

 

7 minutes ago, V0idWa1k3r said:

Since you have no safety checks and just blindly trust the client a malicious client can easily abuse this packet to do whatever it wants, like cover the entire world in these entities, one per block.

 

how would i do the safety check for that? :0


 

8 minutes ago, V0idWa1k3r said:

Don't ever use static initializers for registry entries. Registry entries MUST be instantinated in the appropriate registy event. Using static initializers can and WILL cause issues.

 

should i just delete the static intializers or should do it entirely different (code example if possible)

 

 

9 minutes ago, V0idWa1k3r said:

ItemBase is pointless, there is already an ItemBase, it's called Item. Don't abuse inheritance.

 

yeah it is forgot to delete it if you just look in my code it doesn't even do anything... 

 

 

10 minutes ago, V0idWa1k3r said:

IHasModel is the worst thing to ever exist on this planet. It is ugly, doesn't make any sense since all items need models anyway, makes you write extra code and makes your code that much harder to manage. Don't use it and just register your models in the modelregistryevent directly.

 

okay will do

 

 

10 minutes ago, V0idWa1k3r said:

Any reason for this class to exist? Like at all?

 

i am logging some stuff with it.. but not that much

Link to comment
Share on other sites

5 minutes ago, Oscarita25 said:

What is NOOP?

No Operation, do nothing.

 

6 minutes ago, Oscarita25 said:

because .. if it works it works

It works for now, but it may and likely will cause issues later. Do you want to do a quick reactoring now or restructure half of your mod later?

 

7 minutes ago, Oscarita25 said:

actually i can because those packets are registered for client side and won't be actually executed on server side! (i tested it on server it won't cause issues)

This doesn't matter. It's client-only code in a common environment. Yes, vanilla JVM won't load classes before it gets to their execution without any special flags I believe. Vanilla JVM isn't the only one though, and other implementations may do different things.

Besides there are still ways to load that code on a server and cause a crash.

So no, you really can't and it will cause issues.

 

9 minutes ago, Oscarita25 said:

okay i understand that this is bad code can you give a example code of how to do it much better and optimized?

 

Just send the data from the server when the client needs it. The actual implementation would differ but as an example of your model capability you would send it to the player when they log in or when the data changes.

 

10 minutes ago, Oscarita25 said:

how would i do the safety check for that? :0

 

That would depend on your implementation. There should be a limit to these interactions anyway, like a cooldown or something. But that's up to you.

 

10 minutes ago, Oscarita25 said:

should i just delete the static intializers or should do it entirely different (code example if possible)

Delete the static initializers and just instantinate your things in the registry event. That's it. There is no example needed - do you need an example of writing new Item...() ?

 

 

Link to comment
Share on other sites

Just send them whenever the client needs them. You know when they need it.

If you have a capability you want to sync then send the packet every time the player logs in or the data changes.

In case of the model capability data you would want to send it every time a player started to track another player - grab the other player and send it to the tracking player.

Link to comment
Share on other sites

also just asking bc i did this like really fast:

 

public class ModItems {
	
	

	//Materials
	public static final ItemArmor.ArmorMaterial UA_SPORTS_MAT = 
			EnumHelper.addArmorMaterial
         (Reference.MOD_ID +":ua_sports",Reference.MOD_ID +":ua_sports",15,
		 new int[]{1, 4, 5, 2},12,SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,(float) 0);	
	
	public static  final ItemArmor.ArmorMaterial BAKUGO_ARMOR_MAT =
			EnumHelper.addArmorMaterial
		 (Reference.MOD_ID +":bakugo_armor",Reference.MOD_ID +":bakugo_armor",15,
		 new int[]{1, 4, 5, 2},12,SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,(float) 0);
	
	public static final ItemArmor.ArmorMaterial DEKU_ARMOR_MAT =
			EnumHelper.addArmorMaterial
		 (Reference.MOD_ID +":deku_armor",Reference.MOD_ID +":deku_armor",15,
		 new int[]{1, 4, 5, 2},12,SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,(float) 0);
	

	public static final Item[] ITEMS = {
			new ClothArmor("ua_sports_chestplate",UA_SPORTS_MAT,1,EntityEquipmentSlot.CHEST),
			new ClothArmor("ua_sports_leggings",UA_SPORTS_MAT,2,EntityEquipmentSlot.LEGS),
			new ClothArmor("deku_armor_chestplate",DEKU_ARMOR_MAT,1,EntityEquipmentSlot.CHEST),
			new ClothArmor("deku_armor_leggings",DEKU_ARMOR_MAT,2,EntityEquipmentSlot.LEGS),
			new ClothArmor("deku_armor_feet",DEKU_ARMOR_MAT,1,EntityEquipmentSlot.FEET),
			new ClothArmor("bakugo_armor_head",BAKUGO_ARMOR_MAT,1,EntityEquipmentSlot.HEAD),
			new ClothArmor("bakugo_armor_chestplate",BAKUGO_ARMOR_MAT,1,EntityEquipmentSlot.CHEST),
			new ClothArmor("bakugo_armor_leggings",BAKUGO_ARMOR_MAT,2,EntityEquipmentSlot.LEGS),
			new ClothArmor("bakugo_armor_feet",BAKUGO_ARMOR_MAT,1,EntityEquipmentSlot.FEET)
	};

}

 

@Mod.EventBusSubscriber(modid = Reference.MOD_ID)
public class RegistryHandler {
	
	
	@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll(ModItems.ITEMS);
		
		LoggingUtil.BNHALogger.info("Registered Items");
	}

	@SubscribeEvent
	public static void registerModels(ModelRegistryEvent event)
	{
		
		for (Item item: ModItems.ITEMS)
		{
			ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
		}
		
		LoggingUtil.BNHALogger.info("Registered models");
	}


}

is this the right way to register it? - just asking because i am not sure :P

(just saying i am on basic level of item registering because i pretty much avoid making items at all)

Edited by Oscarita25
Link to comment
Share on other sites

11 minutes ago, V0idWa1k3r said:

Just send them whenever the client needs them. You know when they need it.

If you have a capability you want to sync then send the packet every time the player logs in or the data changes.

In case of the model capability data you would want to send it every time a player started to track another player - grab the other player and send it to the tracking player.

 

if i got it right ...
 

			new ClothArmor("ua_sports_chestplate",UA_SPORTS_MAT,1,EntityEquipmentSlot.CHEST),
			new ClothArmor("ua_sports_leggings",UA_SPORTS_MAT,2,EntityEquipmentSlot.LEGS),
			new ClothArmor("deku_armor_chestplate",DEKU_ARMOR_MAT,1,EntityEquipmentSlot.CHEST),
			new ClothArmor("deku_armor_leggings",DEKU_ARMOR_MAT,2,EntityEquipmentSlot.LEGS),
			new ClothArmor("deku_armor_feet",DEKU_ARMOR_MAT,1,EntityEquipmentSlot.FEET),
			new ClothArmor("bakugo_armor_head",BAKUGO_ARMOR_MAT,1,EntityEquipmentSlot.HEAD),
			new ClothArmor("bakugo_armor_chestplate",BAKUGO_ARMOR_MAT,1,EntityEquipmentSlot.CHEST),
			new ClothArmor("bakugo_armor_leggings",BAKUGO_ARMOR_MAT,2,EntityEquipmentSlot.LEGS),
			new ClothArmor("bakugo_armor_feet",BAKUGO_ARMOR_MAT,1,EntityEquipmentSlot.FEET)

this right into the registry?

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm working in the forge mdk for 1.20.2 and using Terrablender (version 3.2.0.11) to create a custom biome. The biome itself works and generates just fine, but I need to create a custom tag for it in order to have a very specific structures generate in that biome and ONLY that biome. That's when the problem comes in: I've created a ModBiomeTagGenerator class that extends BiomeTagGenerator from the vanilla code, and the same way the vanilla BiomeTagGenerator assigns tags to biomes, I'm trying to assign my custom tag to my custom biome so I can use it in a has_structure json. However, when I do this and try to runData, an error pops up: "Couldn't define tag decayingplanetmod:is_abandoned_city as it is missing following references: decayingplanetmod:abandoned_city." After experimenting, I found that I can add my tag "is_abandoned_city" to other vanilla biomes, but I can't add vanilla tags or ANY tags to my custom biome, abandoned_city, so it's definitely a problem with the custom biome itself, despite the fact that the biome generates in-game just fine. I've included the code that defines my biome, my biome tags, and assigns my tag to my biome. I've scoured online for similar problems and found very few-- the ones I did find had no concrete solutions, just "it suddenly started working" or "I updated to another version and it works now," which is very vague, as they don't specify what they're updating or how. Nothing seems to work so far. Faulty code: https://paste.ee/p/79my3 Any input is appreciated.
    • ASIABET adalah pilihan terbaik bagi Anda yang mencari slot gacor hari ini dengan server Rusia dan jackpot menggiurkan. Berikut adalah beberapa alasan mengapa Anda harus memilih ASIABET: Slot Gacor Hari Ini Kami menyajikan koleksi slot gacor terbaik yang diperbarui setiap hari. Dengan fitur-fitur unggulan dan peluang kemenangan yang tinggi, Anda akan merasakan pengalaman bermain yang tak terlupakan setiap kali Anda memutar gulungan. Server Rusia yang Handal Kami menggunakan server Rusia yang handal dan stabil untuk memastikan kelancaran dan keadilan dalam setiap putaran permainan. Anda dapat bermain dengan nyaman tanpa khawatir tentang gangguan atau lag. Jackpot Menggiurkan Nikmati kesempatan untuk memenangkan jackpot menggiurkan yang dapat mengubah hidup Anda secara instan. Dengan hadiah-hadiah besar yang ditawarkan, setiap putaran permainan bisa menjadi peluang untuk meraih keberuntungan besar.
    • Sonic77 adalah pilihan tepat bagi Anda yang menginginkan pengalaman bermain slot yang unggul dengan akun pro Swiss terbaik. Berikut adalah beberapa alasan mengapa Anda harus memilih Sonic77: Slot Gacor Terbaik Kami menyajikan koleksi slot gacor terbaik dari provider terkemuka. Dengan fitur-fitur unggulan dan peluang kemenangan yang tinggi, Anda akan merasakan pengalaman bermain yang tak terlupakan. Akun Pro Swiss Berkualitas Kami menawarkan akun pro Swiss yang berkualitas dan terpercaya. Dengan akun ini, Anda dapat menikmati berbagai keuntungan eksklusif dan fasilitas premium yang tidak tersedia untuk akun reguler.
    • SV388 SITUS RESMI SABUNG AYAM 2024   Temukan situs resmi untuk sabung ayam terpercaya di tahun 2024 dengan SV388! Dengan layanan terbaik dan pengalaman bertaruh yang tak tertandingi, SV388 adalah tempat terbaik untuk pecinta sabung ayam. Daftar sekarang untuk mengakses arena sabung ayam yang menarik dan nikmati kesempatan besar untuk meraih kemenangan. Jelajahi sensasi taruhan yang tak terlupakan di tahun ini dengan SV388! [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]   JURAGANSLOT88 SITUS JUDI SLOT ONLINE TERPERCAYA 2024 Jelajahi pengalaman judi slot online terpercaya di tahun 2024 dengan JuraganSlot88! Sebagai salah satu situs terkemuka, JuraganSlot88 menawarkan berbagai pilihan permainan slot yang menarik dengan layanan terbaik dan keamanan yang terjamin. Daftar sekarang untuk mengakses sensasi taruhan yang tak terlupakan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan JuraganSlot88 [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
  • Topics

×
×
  • Create New...

Important Information

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