9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-19 15:09:25 +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;

View File

@@ -47,6 +47,8 @@ dependencies {
compileOnly("org.betonquest:betonquest:2.1.3")
// item
compileOnly(files("libs/zaphkiel-2.0.24.jar"))
compileOnly(files("libs/ExecutableItems-7.24.9.29.jar"))
compileOnly(files("libs/SCore-5.24.9.29.jar"))
compileOnly("net.Indyuce:MMOItems-API:6.10-SNAPSHOT")
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("pers.neige.neigeitems:NeigeItems:1.17.13")

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) <2024> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customcrops.bukkit.integration.item;
import com.ssomar.executableitems.executableitems.manager.ExecutableItemsManager;
import com.ssomar.score.api.executableitems.config.ExecutableItemInterface;
import net.momirealms.customcrops.api.integration.ItemProvider;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public class ExecutableItemProvider implements ItemProvider {
@Override
public @NotNull ItemStack buildItem(@NotNull Player player, @NotNull String id) {
return ExecutableItemsManager.getInstance().getExecutableItem(id).get().buildItem(1, Optional.of(player));
}
@Nullable
@Override
public String itemID(@NotNull ItemStack itemStack) {
return ExecutableItemsManager.getInstance().getExecutableItem(itemStack).map(ExecutableItemInterface::getId).orElse(null);
}
@Override
public String identifier() {
return "ExecutableItems";
}
}

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=3.6.12
project_version=3.6.13
config_version=41
project_group=net.momirealms

View File

@@ -118,6 +118,8 @@ public class ConfigType {
.id(id)
.vanillaFarmland(section.getBoolean("vanilla-farmland", false))
.vanillaPots(ListUtils.toList(section.get("vanilla-blocks")))
.ignoreRandomTick(section.getBoolean("ignore-random-tick", false))
.ignoreScheduledTick(section.getBoolean("ignore-scheduled-tick", false))
.storage(section.getInt("storage", 5))
.isRainDropAccepted(section.getBoolean("absorb-rainwater", false))
.isNearbyWaterAccepted(section.getBoolean("absorb-nearby-water", false))

View File

@@ -69,6 +69,9 @@ public class BukkitIntegrationManager implements IntegrationManager {
if (isHooked("Zaphkiel")) {
registerItemProvider(new ZaphkielItemProvider());
}
if (isHooked("ExecutableItems")) {
registerItemProvider(new ExecutableItemProvider());
}
if (isHooked("NeigeItems")) {
registerItemProvider(new NeigeItemsItemProvider());
}