RFTools

RFTools

74M Downloads

RFTools shield generator causing significant FPS drops

douglasg14b opened this issue ยท 8 comments

commented

Issue description:

When using the RFTools Shield Generator for large areas, there is significant FPS drops (20-30FPS decreases).

Even relatively small shields (few thousand blocks or less) caused a 5+FPS drop in the area when active.

Steps to reproduce:

Create a hollow cube shield of 161*161*161 in some manner. Transparent, Solid, shield...etc types cause the same effect.

Versions:

  • Minecraft: 1.12.2
  • Forge: 14.23.4.2715
  • McJtyLib: 1.12-3.0.2
  • RFTools: 1.12-7.54

Does the shield perform regular updates for every block it's comprised of? If so, that would explain the FPS drops. If that's the case, what's the purpose of the updates (Just curious from a dev perspective), and can it be configured to slow down or stop under some condition?

commented

at all i wonder why shield blocks/tiles have to tick at all, energy consumption could be handled by the controller, and damage could be handled by removedByPlayer() in the block/nonticking tile.

im just curious as i want to implement a shield in another mod :>

commented

What has removedByPlayer to do with damage handling? Damage is also done to mobs

commented

damage to the shield, missed the part with damage done to mobs, so nvm me. sorry

commented

after dealing with my own shield system for the last days... you can indeed deal damage without a ticking tile entity, for damage from solid blocks return a bounding box which is slightly smaller than the block/cube
new AxisAlignedBB(0.01, 0.01, 0.01, 0.99, 0.99, 0.99)

do something like this in your block class

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
	if(entity == null)
		return;

	TileEntityNanoFog te = getTE(world, pos);
	if(te == null)
		return;

	if(te.getDamage() > 0 && te.filterDamage.contains(entity.getClass(), entity.getName())) {
		entity.attackEntityFrom(new DamageSource("NanoFog"), te.getDamage());
	}

	if(te.getKnockback() > 0 && !canEntityPass(world, pos, entity)){
		Vec3i kbVec = BlockUtils.getFacingFromEntity(pos, entity);
		entity.addVelocity(kbVec.getX() * te.getKnockback(), kbVec.getY() * te.getKnockback(), kbVec.getZ() * te.getKnockback());
	}
}
commented

As of the next release, shields will no longer have to tick. Thanks @ben-mkiv

commented

A 161161161 hollow cube is still more then 150000 blocks. That's a lot. Also Minecraft generally performs bad if you have blocks very high (this is why extreme hills is laggy and why the nether is restricted to height 128). In addition what settings did you use for the shield? In some settings it actually has to create a tile entity for every block

commented

Thanks for replying!

Isn't the number of blocks in the context of minecraft a mostly non-relavant metric? I can make a 256x256x256 cube of most things and have no ill effects. I don't see FPS drops in extreme hills, or MUCH larger Alps (lvl 200+) biomes, though I limit my framerate to 60, so I might not notice.

The settings I've tried are Solid, Transparent, Shield, and Invisible. They all have almost the same effect on FPS (~30 FPS drop after testing again for myself and a buddy in the region).

I'm curious what the shield does that makes it differ from blocks, where a 161x161x161 hollow cube of stone is a non-issue. Not accusing you, or calling you our or anything, just curious.

commented

What about damage settings? That's what matters for making it a tile entity or not. Can I see a screenshot of the UI of the shield?