Skip to content
Permalink
Browse files
BukkitGetCorrectBlockState optimization
Divide into a Container or not-Container check to do roughly half the checks on average.
  • Loading branch information
Pieter12345 committed Jan 30, 2020
1 parent d7a653d commit e68358bf36c359e89eceab367ad51cf5fa408620
Showing 1 changed file with 16 additions and 14 deletions.
@@ -494,6 +494,22 @@ public List<MCEntity> GetEntitiesAt(MCLocation location, double radius) {
}

public static MCBlockState BukkitGetCorrectBlockState(BlockState bs) {
if(bs instanceof Container) {
// This code block should only contain checks for blockstates that implement Container.
if(bs instanceof BrewingStand) {
return new BukkitMCBrewingStand((BrewingStand) bs);
}
if(bs instanceof Dispenser) {
return new BukkitMCDispenser((Dispenser) bs);
}
if(bs instanceof Dropper) {
return new BukkitMCDropper((Dropper) bs);
}
if(bs instanceof Furnace) {
return new BukkitMCFurnace((Furnace) bs);
}
return new BukkitMCContainer((Container) bs);
}
if(bs instanceof Banner) {
return new BukkitMCBanner((Banner) bs);
}
@@ -503,20 +519,6 @@ public static MCBlockState BukkitGetCorrectBlockState(BlockState bs) {
if(bs instanceof Beacon) {
return new BukkitMCBeacon((Beacon) bs);
}
if(bs instanceof BrewingStand) {
return new BukkitMCBrewingStand((BrewingStand) bs);
}
if(bs instanceof Dispenser) {
return new BukkitMCDispenser((Dispenser) bs);
}
if(bs instanceof Dropper) {
return new BukkitMCDropper((Dropper) bs);
}
if(bs instanceof Furnace) {
return new BukkitMCFurnace((Furnace) bs);
}
if(bs instanceof Container) { // needs to be after all specific containers
return new BukkitMCContainer((Container) bs);
}
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_14) && bs instanceof Lectern) {
return new BukkitMCLectern((Lectern) bs);

0 comments on commit e68358b

Please sign in to comment.