Jump to content

[Solved] RenderLayer not rendering on multiplayer


Oscarita25

Recommended Posts

2 hours ago, V0idWa1k3r said:

It would be easiest to do with a one-line stream

Pseudo-code:

ForgeRegistries.ITEMS.valueCollection().stream().filter(i -> i.getRegistryName().getDomain().equals(MYMODID)).foreach(i -> ModelRegistry.setCustomModelResourceLocation(...))

https://gist.github.com/Cadiboo/3f5cdb785affc069af2fa5fdf2d70358

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

i did overhaul my capabilities and stuff and made the packets update the capabilities when their values changed but the problem of the problem of other players not seeing the model still persists .. am i sending the packet wrong again? xD

 

the parrot (placeholder model) should be displaying for the other player too

538368785_Anmerkung2019-05-30163256-min.thumb.png.474382f84f285895999d4f4478108cd0.png

 

 

here the repo again https://github.com/Oscarita25/BNHA
 

this is in my capability

 

	@Override
	public void synchronize() {
		if(this.player instanceof EntityPlayerMP){
			BNHA.NETWORK.sendTo(new MessageModel(this.model), (EntityPlayerMP) this.player);
			BNHA.NETWORK.sendToAllTracking(new MessageModel(this.model), (EntityPlayerMP) this.player);
		}				
	}

 

it is being called always when the value updates in the ModelID class ... 

 

Link to comment
Share on other sites

On 5/30/2019 at 6:52 PM, diesieben07 said:

It is doubtful you own this domain.

fair point
 

 

On 5/30/2019 at 6:52 PM, diesieben07 said:

get it deleted 

¯\_(ツ)_/¯

 

On 5/30/2019 at 6:52 PM, diesieben07 said:

Do not use registerModEntity. Especially not in init. Entities should be registered using RegistryEvent.Register<EntityEntry>. Use EntityEntryBuilder to create your EntityEntry.

like this?

 

On 5/30/2019 at 6:52 PM, diesieben07 said:

You don't need all those factory classes. Use constructor references.

yeah fixed that

 

On 5/30/2019 at 6:52 PM, diesieben07 said:

You don't need an interface and an implementing class for all of your capabilities. You can just use a plain class. You only need an interface and a class if you plan to expose this capability via an API for other mods to use. In that case the interface would go into your API, while the implementation would remain private in your mod implementation.

i wont actually change that

On 5/30/2019 at 6:52 PM, diesieben07 said:

As for your actual issue: Have you actually tried debugging this? Is your layer rendering being called and just fails? Is it not being called at all? What are the values of the capability on the client where it's not rendered?

trial and error 2 clients 1 server started ... the model is only being rendered on the client player that has the model as for "real" debugging with breakpoints and stuff i didn't

 

Edited by Oscarita25
published to early (accidently hit enter)
Link to comment
Share on other sites

Just now, diesieben07 said:

It's not about code being executed, it is about classes being loaded. And your message handler classes will be loaded on the server, too.

... right ... i will change that but why does this not crash the server at all then?

should i get the model id cap different in the layer class? 
i mean >here<

Link to comment
Share on other sites

  • 2 weeks later...
On 6/1/2019 at 6:16 PM, diesieben07 said:

It's not about code being executed, it is about classes being loaded. And your message handler classes will be loaded on the server, too.

i just noticed why it does work the way i do it because the class EntityPlayerSP is never loaded and the class Minecraft should be on the server too right?

Because i only reference the EntityPlayerSP with Minecraft.getMinecraft().player;

Edited by Oscarita25
Link to comment
Share on other sites

58 minutes ago, diesieben07 said:

Both EntityPlayerSP and Minecraft are client-only classes.

ok odd enough that this works xD


so i have to use ctx.getServerHandler.player even for client?

 

(sorry i am very slow at learning "complicated" stuff)
and itself getting it work somehow isn't the issue but getting it send to players tracking the client .-.

Edited by Oscarita25
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

What?

i dont know if that is a bug or so but itself the packets work only on the client side for me if i do not do something like

Minecraft mc = Minecraft.getMinecraft();

if i use Minecraft.getMinecraft(); directly for it will not crash on the server just found that out by trying and i think thats not what it is supposed to do ?

this works even if i do not use the SidedProxy:

 

	    @Override
	    public IMessage onMessage(MM message, MessageContext ctx) {	
	    		Minecraft.getMinecraft().addScheduledTask(() -> {
	    			
	    			Minecraft.getMinecraft().player.getCapability(Capabilities.modelid, null).setModelID(message.model);
	        
	        	});
	    	
	            
	        return null;
	    }


and this is quite wierd

however this will crash the server:
 

	    @Override
	    public IMessage onMessage(MM message, MessageContext ctx) {
	    	Minecraft mc = Minecraft.getMinecraft();
	    		mc.addScheduledTask(() -> {
	    			
	    			Minecraft.getMinecraft().player.getCapability(Capabilities.modelid, null).setModelID(message.model);
	        
	        	});
	    	
	            
	        return null;
	    }

 

 

37 minutes ago, Oscarita25 said:

but getting it send to players tracking the client .-.

just meant that the other clients won't get the modelID from the client that has the modelID
(do i have to send 2 packets for that? something like this: client with model id -> packet -> Server -> returning packet -> other client)?

Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

Sometimes you get lucky at it works out. But do not rely on it. Access to client-only classes must be encapsulated.

 

seems like it

 

 

11 minutes ago, diesieben07 said:

The server has control over the data. It sends it to all necessary clients. In this case the following applies:

  1.  In PlayerLoggedInEvent, PlayerRespawnEvent and PlayerChangedDimensionEvent send the data of the player in the event to that player only.
  2. In PlayerEvent.StartTracking check if PlayerEvent.StartTracking#getTarget is a player and if so send the data of PlayerEvent.StartTracking#target to PlayerEvent.StartTracking#getEntityPlayer.
  3.  Whenever the data changes, sent it to all players tracking the player who's data changed (SimpleNetworkWrapper#sendToAllTracking(IMessage, Entity)) and also the player themselves.

okay will do that now

Link to comment
Share on other sites

okay but that didn't work (don't know why i am doing really everything correct..) 

but i did found a way around i looked at how The Parrot renderer does this its just storing most of the information in the DataManager of the player
so i tried that and it worked perfectly 


i registered it in the capability and set it when i syncronize my capability

(just so you get the idea of what i did:)

    private static final DataParameter<Integer> MODEL_ID = EntityDataManager.<Integer>createKey(EntityPlayer.class, DataSerializers.VARINT);

// when i register my Capability
		player.getDataManager().register(MODEL_ID, Integer.valueOf(0));


//when i sync my Capability
		player.getDataManager().set(MODEL_ID, Integer.valueOf(this.model));


//getter method for this
	@Override
	public int getModelDATA() {
		return ((Integer)player.getDataManager().get(MODEL_ID)).intValue();

	}


is this a vaild way to do this or can this cause bugs etc.?

Link to comment
Share on other sites

Don't use the (un)boxing stuff. Your IDE should be telling you not to do this. Other than that its fine. The DataManager is how vanilla syncs data, it works pretty well for basic data.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

Do not duplicate data! Either have a field storing your model or the data parameter. Not both.

 

ok will do that :)
 

12 minutes ago, diesieben07 said:

thanks did fix that :P


till now this works like a charm i pretty happy with the result

Link to comment
Share on other sites

  • Oscarita25 changed the title to [Solved] RenderLayer not rendering on multiplayer

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

    • When I launch the Forge installation (1.20.1-47.2.0) everything works fine until Forge tries to launch Minecraft. Usually the launcher crashes while "launching minecraft" or "loading bootstrap resources". I don't know why this happens as I only have two other mods in my mods folder, Create (1.20.1-0.5.1.f) and Rubidium (mc1.20.1-0.7.1) and it works fine with out them. 
    • Your mod is probably lagging during world generation due to how it replaces blocks around your custom ore. Right now, it randomly picks spots around the ore and changes blocks there. This process can be slow, especially if it's dealing with lots of blocks or a big area. To fix it, try replacing fewer blocks, picking spots more efficiently, and changing blocks in a smarter way. This should help your mod run smoother when generating worlds. Here is an example of how you can do this // Inside the if (placed) block if (placed) { BlockState surroundingBlockState = BlockInit.ABERRANT_MINERALOID.get().defaultBlockState(); int veinSize = ctx.config().size; int maxBlocksToReplace = (int) Math.ceil(veinSize * 0.1); // Replace 10% of vein size int numBlocksToCorrupt = Math.min(maxBlocksToReplace, 1000); // Limit to 1000 blocks List<BlockPos> positionsToReplace = new ArrayList<>(); // Loop until reaching the limit of blocks to replace while (positionsToReplace.size() < numBlocksToCorrupt) { BlockPos randomPos = offsetOrigin.offset( ctx.random().nextInt(2 * areaSizeX + 1) - areaSizeX, ctx.random().nextInt(2 * areaSizeY + 1) - areaSizeY, ctx.random().nextInt(2 * areaSizeZ + 1) - areaSizeZ ); if (world.getBlockState(randomPos).is(ModBlockTags.STONE_ABERRANTABLE)) { positionsToReplace.add(randomPos); } } // Replace blocks in bulk for (BlockPos pos : positionsToReplace) { world.setBlock(pos, surroundingBlockState, 2); } } If you've tried more effective ways to generate your blocks around your ores, it may also be because of issues on your side, not the mod. Adjust the parameters as needed based on your performance testing and requirements.
    • So i have a custom ore and, arround the ore, a bunch of randomly placed custom stone blocks should be placed. After applying it, i've found that it causes moderate to extreme world generation lag (new chunks refusing to load after moving for a while, height slices of the same chunk appearing and disappearing as I get into them instead of the usual long continous chunk, new chunks generating extremely close to me instead of to the set render distance...) I've been debugging for a while and I know for a fact this is causing the lag (and sometimes freeze of the world loading screen on a new world and/or the saving world screen when quitting), since comenting it just makes the worldgen work as usual and I want to see if its really that computationally expensive, if there are other ways of doing it or if the process can be simplfied or optimized. I've tried a lot of combinations for the same code but I am just stuck. Is it some kind of generation cascading im missing?   Here is the code for the class. The code inside the if (placed) is the one causing this mess. I can see that the code might not be the most optimized thing, but it does what's supposed to... but at the cost of causing all this. Any tips? package es.nullbyte.relativedimensions.worldgen.oregen.oreplacements; import es.nullbyte.relativedimensions.blocks.BlockInit; import es.nullbyte.relativedimensions.blocks.ModBlockTags; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.OreFeature; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; import java.util.Optional; public class AberrantOreFeature extends OreFeature { public AberrantOreFeature() { super(OreConfiguration.CODEC); } @Override public boolean place(FeaturePlaceContext<OreConfiguration> ctx) { // Get the world and the position from the context WorldGenLevel world = ctx.level(); BlockPos origin = ctx.origin(); // Offset the origin by 8 in the x and z directions to avoid cascading chunk generation BlockPos offsetOrigin = origin.offset(8, 0, 8); // Create a new context with the offset origin FeaturePlaceContext<OreConfiguration> offsetCtx = new FeaturePlaceContext<>( Optional.empty(), world, ctx.chunkGenerator(), ctx.random(), offsetOrigin, ctx.config() ); // Generate the entire vein of ore at the offset origin boolean placed = super.place(offsetCtx); // If the vein was generated successfully if (placed) { // Define the block to replace surrounding blocks with BlockState surroundingBlockState = BlockInit.ABERRANT_MINERALOID.get().defaultBlockState(); // Generate a random size for the area of corruption int areaSizeX = ctx.random().nextInt(3) + 1; // between 1 and 4 int areaSizeY = ctx.random().nextInt(3) + 1; // between 1 and 4 int areaSizeZ = ctx.random().nextInt(3) + 1; // between 1 and 4 // Calculate the number of blocks to be corrupted based on the area size double numBlocksToCorrupt = (areaSizeX + areaSizeY + areaSizeZ / 2.0) ; // Counter for the number of blocks corrupted int numBlocksCorrupted = 0; // Loop for each block to be corrupted while (numBlocksCorrupted < numBlocksToCorrupt) { // Generate a random position within the area, using the offset origin BlockPos randomPos = offsetOrigin.offset( ctx.random().nextInt(2 * areaSizeX + 1) - areaSizeX, // between -areaSize and areaSize ctx.random().nextInt(2 * areaSizeY + 1) - areaSizeY, ctx.random().nextInt(2 * areaSizeZ + 1) - areaSizeZ ); // If the block at the random position is in the IS_ORE_ABERRANTABLE tag, replace it if (world.getBlockState(randomPos).is(ModBlockTags.STONE_ABERRANTABLE)) { world.setBlock(randomPos, surroundingBlockState, 2); numBlocksCorrupted++; } } } return placed; } }  
  • Topics

×
×
  • Create New...

Important Information

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