Jump to content

Efficient cable network


MrRiegel

Recommended Posts

Hey guys,

 

I created a network with cables and one cable controller (similiar to AE).

The list of blockPos of the cables is a field in the cable controller.

Every time a cable is placed or removed I need to refresh the entire list (recursive).

Problem: If the network has many cables (>500), a refresh decreases the fps.

How can I prevent this?

AE doesn't have this problem.

 

Can I increases the fps by refreshing the list in another thread?

Link to comment
Share on other sites

@Choonster

I did, but I don't get it. The AE code is pretty complicated.

 

@7

Thanks for your hints.

A cable should not have a network by itself. A controller is necessary.

And of course there's only one controller per network. If I connect 2 networks, one of the controllers drops.

 

current method to fill the list

private void addCables(final BlockPos pos) {
	for (BlockPos bl : getNeighbors(pos)) {
		if (worldObj.getTileEntity(bl) instanceof TileMaster && !bl.equals(this.pos) && worldObj.getChunkFromBlockCoords(bl) != null && worldObj.getChunkFromBlockCoords(bl).isLoaded()) {
			worldObj.getBlockState(bl).getBlock().dropBlockAsItem(worldObj, bl, worldObj.getBlockState(bl), 0);
			worldObj.setBlockToAir(bl);
			worldObj.removeTileEntity(bl);
			continue;
		}
		if (worldObj.getTileEntity(bl) instanceof IConnectable && !connectables.contains(bl) && worldObj.getChunkFromBlockCoords(bl).isLoaded()) {
			connectables.add(bl);
			((IConnectable) worldObj.getTileEntity(bl)).setMaster(this.pos);
			addCables(bl);
		}
	}

}

 

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



×
×
  • Create New...

Important Information

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