amadornes / MCMultiPart

A universal multipart API for Modern Minecraft
Other
67 stars 23 forks source link

TileMultipartContainer.Ticking doesn't call update() on client side. #118

Closed SonarSonic closed 6 years ago

SonarSonic commented 6 years ago

When updating my mod Practical Logistics 2 to 1.12.2 I noticed some very strange glitches, which were not present when the block was a normal TileEntity.

It would seem that update() is not called at all on client side for any multiparts.

SonarSonic commented 6 years ago

I'm still investigating this. It would appear that newly added Multiparts do call the update() method, but ones loaded from the world do not, So currently I'm assuming TileMultipartContainer is being loaded instead of a TileMultipartContainer.Ticking on the client side.

SonarSonic commented 6 years ago

image As you can see this tile entity was loaded and the client doesn't think it is ticking, despite all parts implementing ITickable. And this tileentity which includes some of the same parts does (this was just added) image

SonarSonic commented 6 years ago

Still looking into this. It would now see that this only occurs when I place one of my Data Cable's in the centre slot first and then add parts around it, doesn't happen if the cable is added second. So very likely the issue is my end, I will confirm. Sorry for hassle if this turns out to be the case!

2xsaiko commented 6 years ago

I know exactly what's causing this. Fix coming soon :D

EDIT: Actually, I was wrong. Works on my side (with my mod's blocks), but I've only tested it against the rewrite. Could you test against this version please?

SonarSonic commented 6 years ago

@therealfarfetchd So i've just installed your version, this doesn't fix the problem. Instead block's placed which would have errored are removed entirely, leaving a ghost block where no blocks can be placed, I'm guessing a TileMultipartContainer with no parts on the client side.

The problem arises in my first update(), this however only occurs when the part is placed second. Which suggests there is something wrong with the TileMultipartContainer not being initialised properly on the first update() call, for parts that were already present in the world when the TileMultipartContainer is formed. This is essentially all I do on the first call for every side of the block... as well as requesting the TileEntity. Commenting this out, or calling on a later tick avoids this issue.

   IMultipartContainer container = (IMultipartContainer) actualTile;                
if (!cableOnly) {// check side slot first if a cable isn't the only target
    Optional<IMultipartTile> part = container.getPartTile(EnumFaceSlot.fromFace(dir));
    if (part.isPresent() && part.get() instanceof INetworkConnection) {
        return (INetworkConnection) part.get();
    }
}

if (!internal) { // don't want the cable to return itself
    Optional<IMultipartTile> cable = container.getPartTile(EnumCenterSlot.CENTER);
    if (cable.isPresent() && cable.get() instanceof INetworkConnection) {
        return (INetworkConnection) cable.get();
    }
}

EDIT: Extra thing I noticed, it will only bug out when there is another TileMultipartContainer with a cable in a neighbouring block, I'm still assuming it's something wrong my side not yours. So thank you for getting back to me

2xsaiko commented 6 years ago

That is a very strange issue. Could you get me a build of your mod so I can test it? Also, any stack traces in the log when it happens?

AlexiyOrlov commented 6 years ago

I think I have a similar problem. I have some cable-like blocks which are wrapped into multiparts and I have panels which have an asscociated IMultipartTile. When I place a cover, then place a cable on it, then break the cable, there remains TileMultipartContainer instead of unwrapped tile: 2018-01-07_11 37 37 2018-01-07_11 37 50

And when I break this remaining piece, the multipart container remains, although the block is completely absent. I wonder if I did something wrong in my tile entity implementation?

2xsaiko commented 6 years ago

This is a thing I've noticed aswell, test with the latest version from this repo please, it should fix that. I hope :P

AlexiyOrlov commented 6 years ago

Just tested with the experimental build 2.4.1_60, and the issue is fixed. Well done!

2xsaiko commented 6 years ago

Great!

@SonarSonic do you still have this issue? Otherwise I'm just going to close it since it's been over a week now

SonarSonic commented 6 years ago

Sorry for not updating you, had other projects to sort out. I'm still encountering this issue with the latest version, however I believe I've found the source of the problem, and it's a fix I should have done anyway. Essentially when the getSelectionBoxes is called the client crashes as the multipart is in the process of being created. As I am checking within the multipart for blocks when it hasn't yet sent to the client, however these checks should be done on the server side anyway. I will update in the next few hours but I should be able to fix now.

2xsaiko commented 6 years ago

No problem. Let's hope your fix works :P