Jump to content

Recommended Posts

Posted

Dear folks, I have block that is a tile entity, this tile entity utilizes BuildCraft api to configure sides of the block to become compatible as a power receptor. The pipe works fine when its connected to the pipe and that side is configured "ON", and it works fine if I configure it "OFF", but the problem is the actual Pipe that connects to that side doesn't render that is is no longer connected. If I close my server and reopen it, the pipe correctly renders because it knows that side is no longer valid to be connected to.

 

While the server is running, if you want the pipe to show correctly based on the tile entity's state you must destroy the pipe and replace it. The pipe has a method to detect when neighbor blocks change and will connect/disconnect accordingly. The problem is its not the block changing, its the tile entity. Without changing the pipe which will detect the changed block, how can I force my tile entity to tell the server that the block has changed. Does this make sense? If the server knew the block changed, not the tile entity, this would work fine.

Posted

It's a world problem. Not kidding!:P

 

The method which updates the neighbours is in World, and you can call this from within your TileEntity:

worldObj.notifyBlockChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord,yCoord,zCoord);

 

What I would do (if possible) is determining whether it's on or off with the block's metadata. That way, when you change the on/off state, you can automatically notify the neighbors (by using the right flag in worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta, flag)).

 

//Edit: Forgot the word Metadata in the method name!

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Posted

MineMaarten, this worked perfect.

 

My problem now is it seems like the server is having issues or my client is having issues. I don't drop in FPS, but i get these weird "frame skips" like im lagging. I think its because my block is saying tis changed too frequently and its causing a lot of useless checks or something. How can i make it do notifyBlockChange only when the invetory is changed? onInvetoryChanged() seems to do other stuff not related to my problem.

 

Will i just have to add the notifyblock to all the methods that move an itemstack into or out of a slot or is there a simple solution I can put into updateEntity to do this with less code everywhere?

Posted

The invetory change and blockchange notify can be optimized if you help. But asking around the lag is most likely from the initlization/configuration process of getting information from the item and applying it to specific features of the tile entity.

 

I don't need it to be quick, i just dont want it to bog down for a few seconds while it configures everything whenever a item changes. I guess i need to setup a custom tick handler and do each step after so many ticks, right? That should make it smoother...i Think

Posted

it seems like the server is having issues or my client is having issues.

It's probably unrelated to the problem, but only change the block meta or notify only on the server. The server then automatically will update the client.

 

I think its because my block is saying tis changed too frequently and its causing a lot of useless checks or something. How can i make it do notifyBlockChange only when the invetory is changed? onInvetoryChanged() seems to do other stuff not related to my problem.

You might be right here. I guess (not sure!) onInventoryChanged() is being called multiple times when the inventory changed and if every time causes the neighbors to update that can cause a lag spike yes.

 

Will i just have to add the notifyblock to all the methods that move an itemstack into or out of a slot or is there a simple solution I can put into updateEntity to do this with less code everywhere?

I would go for the latter. You don't need a TickHandler first of all, you already have one in your TileEntity (updateEntity()). If speed is not really problem, you can set something up that checks if the on/off state changed every so often and if it has changed update the neighbors:

private int ticksExisted;

public void updateEntity(){
    if(!worldObj.isRemote && ticksExisted % 20 == 0){ //check every second
          if(check if changed){
                  worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 3);
          }
    }
}

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

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

    • Ah, it appears I spoke too soon, I still need a little help here. I now have the forceloading working reliably.  However, I've realized it's not always the first tick that loads the entity.  I've seen it take anywhere from 2-20ish to actually go through, in which time my debugging has revealed that the chunk is loaded, but during which time calling  serverLevelIn.getEntity(uuidIn) returns a null result.  I suspect this has to do with queuing and how entities are loaded into the game.  While not optimal, it's acceptable, and I don't think there's a whole ton I can do to avoid it. However, my concern is that occasionally teleporting an entity in this manner causes a lag spike.  It's not every time and gives the appearance of being correlated with when other chunks are loading in.  It's also not typically a long spike, but can last a second or two, which is less than ideal.  The gist of how I'm summoning is here (although I've omitted some parts that weren't relevant.  The lag occurs before the actual summon so I'm pretty confident it's the loading, and not the actual summon call). ChunkPos chunkPos = new ChunkPos(entityPosIn); if (serverLevelIn.areEntitiesLoaded(chunkPos.toLong())) { boolean isSummoned = // The method I'm using for actual summoning is called here. Apart from a few checks, the bulk of it is shown later on. if (isSummoned) { // Code that runs here just notifies the player of the summon, clears it from the queue, and removes the forceload } } else { // I continue forcing the chunk until the summon succeeds, to make sure it isn't inadvertently cleared ForgeChunkManager.forceChunk(serverLevelIn, MODID, summonPosIn, chunkPos.x, chunkPos.z, true, true); } The summon code itself uses serverLevelIn.getEntity(uuidIn) to retrieve the entity, and moves it as such.  It is then moved thusly: if (entity.isAlive()) { entity.moveTo(posIn.getX(), posIn.getY(), posIn.getZ()); serverLevelIn.playSound(null, entity, SoundEvents.ENDERMAN_TELEPORT, SoundSource.NEUTRAL, 1.0F, 1.0F); return true; } I originally was calling .getEntity() more frequently and didn't have the check for whether or not entities were loaded in place to prevent unnecessary code calls, but even with those safety measures in place, the lag still persists.  Could this just be an issue with 1.18's lack of optimization in certain areas?  Is there anything I can do to mitigate it?  Is there a performance boosting mod I could recommend alongside my own to reduce the chunk loading lag? At the end of the day, it does work, and I'm putting measures in place to prevent players from abusing the system to cause lag (i.e. each player can only have one queued summon at a time-- trying to summon another replaces the first call).  It's also not an unacceptable level of lag, IMO, given the infrequency of such calls, and the fact that I'm providing the option to toggle off the feature if server admins don't want it used.  However, no amount of lag is ideal, so if possible I'd love to find a more elegant solution-- or at least a mod recommendation to help improve it. Thanks!
    • When i start my forge server its on but when i try to join its come a error Internal Exception: java.lang.OutOfMemoryError: Requested array size exceeds VM limit Server infos: Linux Minecraft version 1.20.1 -Xmx11G -Xms8G
    • Also add the latest.log from your logs-folder
    • Add the mods in groups
  • Topics

×
×
  • Create New...

Important Information

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