mirror of
https://github.com/songoda/EpicFarming.git
synced 2025-02-21 15:01:25 +01:00
Merge branch 'development'
This commit is contained in:
commit
823f5c7a0b
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicFarming</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>3.0.14</version>
|
||||
<version>3.0.15</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicFarming-${project.version}</finalName>
|
||||
|
@ -85,7 +85,8 @@ public class ModuleAutoCollect extends Module {
|
||||
entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 2);
|
||||
if (!isEnabled(farm)) {
|
||||
ticksLived.remove(entity);
|
||||
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), new ItemStack(Material.EGG));
|
||||
Bukkit.getScheduler().runTask(plugin, () ->
|
||||
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), new ItemStack(Material.EGG)));
|
||||
} else {
|
||||
doLivestockDrop(farm, new ItemStack(Material.EGG, 1));
|
||||
}
|
||||
@ -98,7 +99,8 @@ public class ModuleAutoCollect extends Module {
|
||||
Wool woolColor = new Wool(((Sheep) entity).getColor());
|
||||
ItemStack wool = woolColor.toItemStack((int) Math.round(1 + (Math.random() * 3)));
|
||||
if (!isEnabled(farm)) {
|
||||
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), wool);
|
||||
Bukkit.getScheduler().runTask(plugin, () ->
|
||||
entity.getLocation().getWorld().dropItemNaturally(entity.getLocation(), wool));
|
||||
} else {
|
||||
doLivestockDrop(farm, wool);
|
||||
}
|
||||
|
@ -37,31 +37,33 @@ public class FarmTask extends BukkitRunnable {
|
||||
|
||||
public static List<Block> getCrops(Farm farm, boolean add) {
|
||||
if (((System.currentTimeMillis() - farm.getLastCached()) > (30 * 1000)) || !add) {
|
||||
farm.setLastCached(System.currentTimeMillis());
|
||||
if (add) farm.clearCache();
|
||||
Block block = farm.getLocation().getBlock();
|
||||
int radius = farm.getLevel().getRadius();
|
||||
int bx = block.getX();
|
||||
int by = block.getY();
|
||||
int bz = block.getZ();
|
||||
for (int fx = -radius; fx <= radius; fx++) {
|
||||
for (int fy = -2; fy <= 1; fy++) {
|
||||
for (int fz = -radius; fz <= radius; fz++) {
|
||||
Block b2 = block.getWorld().getBlockAt(bx + fx, by + fy, bz + fz);
|
||||
CompatibleMaterial mat = CompatibleMaterial.getMaterial(b2);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
farm.setLastCached(System.currentTimeMillis());
|
||||
if (add) farm.clearCache();
|
||||
Block block = farm.getLocation().getBlock();
|
||||
int radius = farm.getLevel().getRadius();
|
||||
int bx = block.getX();
|
||||
int by = block.getY();
|
||||
int bz = block.getZ();
|
||||
for (int fx = -radius; fx <= radius; fx++) {
|
||||
for (int fy = -2; fy <= 1; fy++) {
|
||||
for (int fz = -radius; fz <= radius; fz++) {
|
||||
Block b2 = block.getWorld().getBlockAt(bx + fx, by + fy, bz + fz);
|
||||
CompatibleMaterial mat = CompatibleMaterial.getMaterial(b2);
|
||||
|
||||
if (mat == null || !mat.isCrop() || !CropType.isGrowableCrop(mat.getBlockMaterial()))
|
||||
continue;
|
||||
if (mat == null || !mat.isCrop() || !CropType.isGrowableCrop(mat.getBlockMaterial()))
|
||||
continue;
|
||||
|
||||
if (add) {
|
||||
farm.addCachedCrop(b2);
|
||||
continue;
|
||||
if (add) {
|
||||
farm.addCachedCrop(b2);
|
||||
continue;
|
||||
}
|
||||
farm.removeCachedCrop(b2);
|
||||
plugin.getGrowthTask().removeCropByLocation(b2.getLocation());
|
||||
}
|
||||
farm.removeCachedCrop(b2);
|
||||
plugin.getGrowthTask().removeCropByLocation(b2.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return farm.getCachedCrops();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user