9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-21 07:59:16 +00:00
This commit is contained in:
XiaoMoMi
2024-09-30 21:06:28 +08:00
parent 23fec3458c
commit cfcf716e9d
10 changed files with 110 additions and 6 deletions

View File

@@ -74,7 +74,7 @@ public class PotBlock extends AbstractCustomCropsBlock {
// ignore random tick
if (world.setting().tickPotMode() == 1) return;
if (canTick(state, world.setting().tickPotInterval())) {
tickPot(state, world, location, offlineTick);
tickPot(state, world, location, offlineTick, false);
}
}
@@ -83,7 +83,7 @@ public class PotBlock extends AbstractCustomCropsBlock {
// ignore scheduled tick
if (world.setting().tickPotMode() == 2) return;
if (canTick(state, world.setting().tickPotInterval())) {
tickPot(state, world, location, offlineTick);
tickPot(state, world, location, offlineTick, true);
}
}
@@ -356,7 +356,7 @@ public class PotBlock extends AbstractCustomCropsBlock {
return state;
}
private void tickPot(CustomCropsBlockState state, CustomCropsWorld<?> world, Pos3 location, boolean offline) {
private void tickPot(CustomCropsBlockState state, CustomCropsWorld<?> world, Pos3 location, boolean offline, boolean tickMode) {
PotConfig config = config(state);
BukkitCustomCropsPlugin plugin = BukkitCustomCropsPlugin.getInstance();
if (config == null) {
@@ -365,8 +365,10 @@ public class PotBlock extends AbstractCustomCropsBlock {
return;
}
if (tickMode && config.ignoreRandomTick()) return;
if (!tickMode && config.ignoreScheduledTick()) return;
World bukkitWorld = world.bukkitWorld();
CompletableFuture<Boolean> future = new CompletableFuture<>();
if (ConfigManager.doubleCheck()) {
String blockID = plugin.getItemManager().blockID(location.toLocation(bukkitWorld));
if (!config.blocks().contains(blockID)) {

View File

@@ -70,6 +70,20 @@ public interface PotConfig {
*/
boolean disablePluginMechanism();
/**
* Should the pot ignore scheduled tick?
*
* @return ignore or not
*/
boolean ignoreScheduledTick();
/**
* Should the pot ignore random tick?
*
* @return ignore or not
*/
boolean ignoreRandomTick();
/**
* Gets the methods available for watering the pot.
*
@@ -261,6 +275,10 @@ public interface PotConfig {
*/
Builder isNearbyWaterAccepted(boolean isNearbyWaterAccepted);
Builder ignoreRandomTick(boolean ignoreRandomTick);
Builder ignoreScheduledTick(boolean ignoreScheduledTick);
/**
* Sets the methods available for watering the pot.
*

View File

@@ -42,6 +42,8 @@ public class PotConfigImpl implements PotConfig {
private final int storage;
private final boolean isRainDropAccepted;
private final boolean isNearbyWaterAccepted;
private final boolean ignoreRandomTick;
private final boolean ignoreScheduledTick;
private final WateringMethod[] wateringMethods;
private final WaterBar waterBar;
private final int maxFertilizers;
@@ -65,6 +67,8 @@ public class PotConfigImpl implements PotConfig {
int storage,
boolean isRainDropAccepted,
boolean isNearbyWaterAccepted,
boolean ignoreRandomTick,
boolean ignoreScheduledTick,
WateringMethod[] wateringMethods,
WaterBar waterBar,
int maxFertilizers,
@@ -102,6 +106,8 @@ public class PotConfigImpl implements PotConfig {
this.addWaterActions = addWaterActions;
this.fullWaterActions = fullWaterActions;
this.maxFertilizerActions = maxFertilizerActions;
this.ignoreRandomTick = ignoreRandomTick;
this.ignoreScheduledTick = ignoreScheduledTick;
this.blocks.add(basicAppearance.left());
this.blocks.add(basicAppearance.right());
this.wetBlocks.add(basicAppearance.right());
@@ -153,6 +159,16 @@ public class PotConfigImpl implements PotConfig {
return disablePluginSystem;
}
@Override
public boolean ignoreScheduledTick() {
return ignoreScheduledTick;
}
@Override
public boolean ignoreRandomTick() {
return ignoreRandomTick;
}
@Override
public WateringMethod[] wateringMethods() {
if (disablePluginMechanism()) return new WateringMethod[0];
@@ -257,6 +273,8 @@ public class PotConfigImpl implements PotConfig {
private int storage;
private boolean isRainDropAccepted;
private boolean isNearbyWaterAccepted;
private boolean ignoreRandomTick;
private boolean ignoreScheduledTick;
private WateringMethod[] wateringMethods;
private WaterBar waterBar;
private int maxFertilizers;
@@ -275,7 +293,7 @@ public class PotConfigImpl implements PotConfig {
@Override
public PotConfig build() {
return new PotConfigImpl(id, vanillaFarmland, basicAppearance, potAppearanceMap, storage, isRainDropAccepted, isNearbyWaterAccepted, wateringMethods, waterBar, maxFertilizers, placeRequirements, breakRequirements, useRequirements, tickActions, reachLimitActions, interactActions, placeActions, breakActions, addWaterActions, fullWaterActions, maxFertilizerActions, vanillaPots);
return new PotConfigImpl(id, vanillaFarmland, basicAppearance, potAppearanceMap, storage, isRainDropAccepted, isNearbyWaterAccepted, ignoreRandomTick, ignoreScheduledTick, wateringMethods, waterBar, maxFertilizers, placeRequirements, breakRequirements, useRequirements, tickActions, reachLimitActions, interactActions, placeActions, breakActions, addWaterActions, fullWaterActions, maxFertilizerActions, vanillaPots);
}
@Override
@@ -314,6 +332,18 @@ public class PotConfigImpl implements PotConfig {
return this;
}
@Override
public Builder ignoreRandomTick(boolean ignoreRandomTick) {
this.ignoreRandomTick = ignoreRandomTick;
return this;
}
@Override
public Builder ignoreScheduledTick(boolean ignoreScheduledTick) {
this.ignoreScheduledTick = ignoreScheduledTick;
return this;
}
@Override
public Builder wateringMethods(WateringMethod[] wateringMethods) {
this.wateringMethods = wateringMethods;