OpenBlocks

OpenBlocks

56M Downloads

Vacuum hoppers cause entity overflow

LarsonMichael opened this issue ยท 0 comments

commented

Vacuum hoppers can cause major performance issues when connected inventories are full.
In packs with automation(farms) continuing to produce entities, the vacuum hopper pulls the entities towards it even though it cannot pick them up. The entities count as having been interacted with and therefore will not despawn.
A vacuum hopper running over a field with an automatic harvester will eventually cause thousands of entities to be stuck beneath the hopper.

The vacuum hopper should suspend interactions with entities if its inventory could not possibly pick them up.

Placing a "hopper full" check around this block of code from https://github.com/OpenMods/OpenBlocks/blob/master/src/main/java/openblocks/common/tileentity/TileEntityVacuumHopper.java should allow the entities to despawn naturally on overflowing farms.

List<Entity> interestingItems = world.getEntitiesWithinAABB(Entity.class, getBB().grow(3), entitySelector);

		boolean needsSync = false;

		for (Entity entity : interestingItems) {
			double dx = (pos.getX() + 0.5D - entity.posX);
			double dy = (pos.getY() + 0.5D - entity.posY);
			double dz = (pos.getZ() + 0.5D - entity.posZ);

			double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
			if (distance < 1.1) {
				needsSync |= onEntityCollidedWithBlock(entity);
			} else {
				double var11 = 1.0 - distance / 15.0;

				if (var11 > 0.0D) {
					var11 *= var11;
					entity.motionX += dx / distance * var11 * 0.05;
					entity.motionY += dy / distance * var11 * 0.2;
					entity.motionZ += dz / distance * var11 * 0.05;
				}
			}

		}