9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-29 03:49:08 +00:00

add languages and farmland support

This commit is contained in:
XiaoMoMi
2024-03-09 08:23:54 +08:00
parent 8d37290cff
commit 19a0080aae
12 changed files with 93 additions and 4 deletions

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <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.manager;
import net.momirealms.customcrops.api.CustomCropsPlugin;

View File

@@ -59,7 +59,9 @@ import net.momirealms.customcrops.utils.ItemUtils;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Farmland;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
@@ -2268,6 +2270,14 @@ public class ItemManagerImpl implements ItemManager {
@Override
public void updatePotState(Location location, Pot pot, boolean hasWater, Fertilizer fertilizer) {
if (pot.isVanillaBlock()) {
Block block = location.getBlock();
if (block.getBlockData() instanceof Farmland farmland) {
farmland.setMoisture(hasWater ? 7 : 0);
block.setBlockData(farmland);
return;
}
}
this.customProvider.placeBlock(
location,
pot.getBlockState(

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) <2022> <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.mechanic.item.function;
public enum FunctionTrigger {

View File

@@ -26,6 +26,7 @@ import net.momirealms.customcrops.api.mechanic.item.water.PassiveFillMethod;
import net.momirealms.customcrops.api.mechanic.misc.image.WaterBar;
import net.momirealms.customcrops.api.mechanic.requirement.Requirement;
import net.momirealms.customcrops.mechanic.item.AbstractEventItem;
import net.momirealms.customcrops.utils.ConfigUtils;
import java.util.HashMap;
import java.util.HashSet;
@@ -45,6 +46,7 @@ public class PotConfig extends AbstractEventItem implements Pot {
private final Requirement[] useRequirements;
private final boolean acceptRainDrop;
private final boolean acceptNearbyWater;
private boolean isVanillaBlock;
public PotConfig(
String key,
@@ -76,6 +78,7 @@ public class PotConfig extends AbstractEventItem implements Pot {
this.placeRequirements = placeRequirements;
this.breakRequirements = breakRequirements;
this.useRequirements = useRequirements;
this.isVanillaBlock = ConfigUtils.isVanillaItem(dryModel) && ConfigUtils.isVanillaItem(wetModel);
}
@Override
@@ -153,4 +156,9 @@ public class PotConfig extends AbstractEventItem implements Pot {
return water ? wetModel : dryModel;
}
}
@Override
public boolean isVanillaBlock() {
return isVanillaBlock;
}
}

View File

@@ -39,11 +39,14 @@ public class SlimeWorldAdaptor extends AbstractWorldAdaptor {
@EventHandler (ignoreCancelled = true)
public void onSlimeWorldLoad(LoadSlimeWorldEvent event) {
}
@EventHandler(ignoreCancelled = true)
public void onWorldLoad(WorldLoadEvent event) {
if (worldManager.isMechanicEnabled(event.getWorld())) {
worldManager.loadWorld(event.getWorld());
}
}
@EventHandler (ignoreCancelled = true)