Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix general issues with breaking things #281

Merged
merged 3 commits into from
Dec 4, 2021
Merged

Fix general issues with breaking things #281

merged 3 commits into from
Dec 4, 2021

Conversation

bruberu
Copy link
Member

@bruberu bruberu commented Dec 2, 2021

This PR fixes two minor issues I've found with breaking blocks. One of these is that the server does not correctly deal with a broken block when a sound is played, which has been fixed by adding parameters to onBreakingUse to allow the server to position a sound to where the tool is applied and then play it to everyone. The other is to fix an issue with null MTEs when they are broken at a low TPS, as they would cause persistent visual errors on the client side when broken, which has simply been fixed by turning them into air on the client on update cycles. It appears that they can return to normal MTEs if the server syncs its data properly. However, they seem to still potentially appear for a very short time, although for much shorter durations than previously.

Comment on lines 131 to 134
} else if (world.isRemote) { // Remove null TEs on the client
this.getWorld().setBlockToAir(this.getPos());
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is simple, but it makes a big impact. I wonder how you test it?

  • How to ensure data synch between the server and the client?
  • How you test it in low tps that you mentioned?
  • It appears that they can return to normal MTEs if the server syncs its data properly. How is this confirmed?

I think the core problem is to solve why MTE is synced to empty, but BlockMachine not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I have noticed several times that if this accidentally hits, the server seems to be able to recover it; besides, I would think that TE updates on the server go to the client, which could recover the block itself. I've also noticed an occasional flicker sometimes in low TPS while placing blocks, but it always properly recovers.
  2. I put a Thread.sleep of 1 in MetaTileEntity's update, which quite easily makes a nice configurable lag.
  3. Again, it also looks like placing is made a little weird in low TPS environments, and I can see the MTE flicker for a tick, and then return, as if the client code deleted the block, but the server returned it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you said, I simulated a low TPS environment (4). But didnt recovering, with a completely invisible block blocking me.
worse2
.
The good news is that I seem to have figured out how to reproduce invisible blocks inspired by you and have some ideas.

@Yefancy
Copy link
Contributor

Yefancy commented Dec 2, 2021

A quick look at the MetaTileEntityHolder code shows that I can't see when a null metaTileEntity is assigned.
probably a fake MTEHolder was accessed while rendering, is there any way to reproduce this issue? I think I can try to fix it in the renderer.

@Yefancy
Copy link
Contributor

Yefancy commented Dec 2, 2021

btw, the cheapest way is to have the BlockMachine return a non-full CollisionBox, which at least ensures that the surrounding blocks are rendered as normal. also do some check with the onDrawBlockHighlight event.

@bruberu
Copy link
Member Author

bruberu commented Dec 2, 2021

btw, the cheapest way is to have the BlockMachine return a non-full CollisionBox, which at least ensures that the surrounding blocks are rendered as normal. also do some check with the onDrawBlockHighlight event.

This wouldn't do much overall to solve the issue, and besides, null MTEs almost certainly cause other problems than just its rendering on the client side. It's likely better to just remove these side effects immediately.

@Yefancy Yefancy added the status: high priority Issue or PR should be prioritized for reviews label Dec 4, 2021
return new CPacketPluginSynced(null, buf);
}
));
CPacketPluginSynced.registerPacket(7);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move these packet numbers to GregtechDataCodes?

Copy link
Contributor

@Yefancy Yefancy Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blueberry said he will rework a general refactoring of NetworkHandler. another pr

@@ -177,6 +175,11 @@ public float getExplosionResistance(@Nonnull World world, @Nonnull BlockPos pos,
return collisionList;
}

@Override
public boolean doesSideBlockRendering(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing face) {
return state.isOpaqueCube() && getMetaTileEntity(world, pos) != null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have an additional check for if the face to be rendered is obscured by another block?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually a method called by another block to check side rendering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see

Copy link
Contributor

@ALongStringOfNumbers ALongStringOfNumbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since both of my concerns were addressed, I think it will be fine to merge this and see if any problems are reported, since it is hard to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: high priority Issue or PR should be prioritized for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants