mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 09:59:20 +00:00
3.5.2
This commit is contained in:
@@ -2656,8 +2656,13 @@ public class ItemManagerImpl implements ItemManager {
|
||||
|
||||
@Override
|
||||
public void updatePotState(Location location, Pot pot, boolean hasWater, Fertilizer fertilizer) {
|
||||
Block block = location.getBlock();
|
||||
Pot currentPot = getPotByBlock(block);
|
||||
if (currentPot != pot) {
|
||||
plugin.getWorldManager().removePotAt(SimpleLocation.of(location));
|
||||
return;
|
||||
}
|
||||
if (pot.isVanillaBlock()) {
|
||||
Block block = location.getBlock();
|
||||
if (block.getBlockData() instanceof Farmland farmland) {
|
||||
farmland.setMoisture(hasWater ? 7 : 0);
|
||||
block.setBlockData(farmland);
|
||||
|
||||
@@ -217,23 +217,55 @@ public class MemoryPot extends AbstractCustomCropsBlock implements WorldPot {
|
||||
}
|
||||
|
||||
int water = getWater();
|
||||
if (water > 0) {
|
||||
if (--water <= 0) {
|
||||
loseWater = true;
|
||||
|
||||
SimpleLocation location = getLocation();
|
||||
Location bukkitLocation = location.getBukkitLocation();
|
||||
if (bukkitLocation == null) return;
|
||||
World world = bukkitLocation.getWorld();
|
||||
|
||||
outer: {
|
||||
if (water > 0) {
|
||||
if (pot.isRainDropAccepted()) {
|
||||
if (world.hasStorm() || (!world.isClearWeather() && !world.isThundering())) {
|
||||
double temperature = world.getTemperature(location.getX(), location.getY(), location.getZ());
|
||||
if (temperature > 0.15 && temperature < 0.85) {
|
||||
Block highest = world.getHighestBlockAt(location.getX(), location.getZ());
|
||||
if (highest.getLocation().getY() == location.getY()) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pot.isNearbyWaterAccepted()) {
|
||||
for (int i = -4; i <= 4; i++) {
|
||||
for (int j = -4; j <= 4; j++) {
|
||||
for (int k : new int[]{0, 1}) {
|
||||
Block block = bukkitLocation.clone().add(i,k,j).getBlock();
|
||||
if (block.getType() == Material.WATER || (block.getBlockData() instanceof Waterlogged waterlogged && waterlogged.isWaterlogged())) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (--water <= 0) {
|
||||
loseWater = true;
|
||||
}
|
||||
setWater(water);
|
||||
}
|
||||
setWater(water);
|
||||
}
|
||||
|
||||
if (loseFertilizer || loseWater) {
|
||||
Location location = getLocation().getBukkitLocation();
|
||||
CustomCropsPlugin.get().getScheduler().runTaskSync(() ->
|
||||
CustomCropsPlugin.get().getItemManager()
|
||||
.updatePotState(
|
||||
location,
|
||||
bukkitLocation,
|
||||
pot,
|
||||
getWater() > 0,
|
||||
getFertilizer()
|
||||
), location
|
||||
), bukkitLocation
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user