mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-16 18:44:45 +00:00
Drastically reduce getBlock calls in orchard mode (#19)
* Drastically reduce getBlock calls in orchard mode * improve caching
This commit is contained in:
1 parent
bfa39a7738
commit
b58e4c57c7
12 files changed
+97
-67
No files matched your search
@@ -0,0 +1,32 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2022, glee8e
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.farming;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* A basic form of {@link IFarmable}. It adds one more variant of isSapling, allowing much better runtime performance than otherwise.
|
||||
*/
|
||||
public interface IFarmableBasic extends IFarmable {
|
||||
|
||||
/**
|
||||
* @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop.
|
||||
*/
|
||||
default boolean isSaplingAt(World world, int x, int y, int z) {
|
||||
return world.blockExists(x, y, z) && isSapling(world.getBlock(x, y, z), isMetadataAware() ? world.getBlockMetadata(x, y, z) : 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if given block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop.
|
||||
*/
|
||||
boolean isSapling(Block block, int meta);
|
||||
|
||||
default boolean isMetadataAware() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user