Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

Hopper optimisations #387

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public void onPlace(World world, BlockPosition blockposition, IBlockData iblockd
while (iterator.hasNext()) {
EnumDirection enumdirection = (EnumDirection) iterator.next();
BlockPosition blockposition1 = blockposition.shift(enumdirection);
IBlockData iblockdata1 = world.getType(blockposition1);
// FlamePaper start - Dont load chunks for chests
final IBlockData iblockdata1 = world.isLoaded(blockposition1) ? world.getType(blockposition1) : null;
if (iblockdata1 == null) {
continue;
}
// FlamePaper end

if (iblockdata1.getBlock() == this) {
this.e(world, blockposition1, iblockdata1);
Expand Down
12 changes: 12 additions & 0 deletions NachoSpigot-Server/src/main/java/net/minecraft/server/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -1630,4 +1630,16 @@ public static enum EnumTileEntityState {

private EnumTileEntityState() {}
}

// FlamePaper start - Hopper item lookup optimization
public int getItemCount(BlockPosition blockPosition) {
int k = MathHelper.floor(blockPosition.getY() / 16.0D);

k = Math.max(0, k);
k = Math.min(this.entitySlices.length - 1, k);

return itemCounts[k];
}
// FlamePaper end - Hopper item lookup optimization

}
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ public static IInventory getInventory(World world, double d0, double d1, double
}
}

if (object == null && searchForEntities) {
net.minecraft.server.Chunk chunk = world.getChunkAtWorldCoords(blockposition);

if (object == null && searchForEntities && !org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(block).isOccluding() && chunk.getItemCount(blockposition) > 0) {
List list = world.a((Entity) null, new AxisAlignedBB(d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, d0 + 0.5D, d1 + 0.5D, d2 + 0.5D), IEntitySelector.c);

if (list.size() > 0) {
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ See: [Contributors Page](https://github.com/CobbleSword/NachoSpigot/graphs/contr
[KigPaper-0191] Don't calculate initial light if not requested
[KigPaper-0220] Entity: Use EnumMap in CraftPlayer#playEffect()

[FlamePaper-0032] Dont load chunks for chests
[FlamePaper-0033] Dont check occluding hoppers
[FlamePaper-0034] Hopper item lookup optimization
[FlamePaper-0102] Fixed chunk memory leak
[FlamePaper-0103] Limit CraftChatMessage iterations
[FlamePaper-0104] Return last slot by default
Expand Down