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

implement watering can

This commit is contained in:
XiaoMoMi
2024-09-01 01:39:51 +08:00
parent f632b99554
commit 139cd9649d
62 changed files with 210 additions and 146 deletions

View File

@@ -213,6 +213,7 @@ public class BukkitConfigManager extends ConfigManager {
@Override
public void registerWateringCanConfig(WateringCanConfig config) {
Registries.WATERING_CAN.register(config.id(), config);
Registries.ITEM_TO_WATERING_CAN.register(config.itemID(), config);
Registries.ITEMS.register(config.itemID(), BuiltInItemMechanics.WATERING_CAN.mechanic());
}

View File

@@ -66,7 +66,7 @@ public class ConfigType {
.length(section.getInt("effective-range.length", 1))
.potWhitelist(new HashSet<>(section.getStringList("pot-whitelist")))
.sprinklerWhitelist(new HashSet<>(section.getStringList("sprinkler-whitelist")))
.dynamicLore(section.getBoolean("dynamic-lore"))
.dynamicLore(section.getBoolean("dynamic-lore.enable"))
.lore(section.getStringList("dynamic-lore.lore").stream().map(TextValue::<Player>auto).toList())
.fillMethods(manager.getFillMethods(section.getSection("fill-method")))
.requirements(BukkitCustomCropsPlugin.getInstance().getRequirementManager(Player.class).parseRequirements(section.getSection("requirements"), true))
@@ -115,6 +115,7 @@ public class ConfigType {
PotConfig config = PotConfig.builder()
.id(id)
.storage(section.getInt("storage", 5))
.isRainDropAccepted(section.getBoolean("absorb-rainwater", false))
.isNearbyWaterAccepted(section.getBoolean("absorb-nearby-water", false))
.maxFertilizers(section.getInt("max-fertilizers", 1))
@@ -187,6 +188,7 @@ public class ConfigType {
int point = Integer.parseInt(entry.getKey());
CropStageConfig.Builder builder = CropStageConfig.builder()
.point(point)
.existenceForm(inner.contains("type") ? CustomForm.valueOf(inner.getString("type").toUpperCase(Locale.ENGLISH)).existenceForm() : form)
.displayInfoOffset(inner.getDouble("hologram-offset-correction"))
.stageID(inner.getString("model"))
.breakRequirements(prm.parseRequirements(inner.getSection("requirements.break"), true))

View File

@@ -80,6 +80,11 @@ public class BukkitItemManager extends AbstractItemManager {
this.factory = BukkitItemFactory.create(plugin);
}
@Override
public void load() {
this.resetItemDetectionOrder();
}
@Override
public void setCustomEventListener(@NotNull AbstractCustomEventListener listener) {
Objects.requireNonNull(listener, "listener cannot be null");
@@ -392,7 +397,7 @@ public class BukkitItemManager extends AbstractItemManager {
CustomCropsWorld<?> world = optionalWorld.get();
WrappedInteractEvent wrapped = new WrappedInteractEvent(ExistenceForm.BLOCK, player, world, block.getLocation(), blockID, itemInHand, itemID, hand, blockFace, event);
handleInteractEvent(blockID, itemID, wrapped);
handleInteractEvent(blockID, wrapped);
}
@Override
@@ -406,11 +411,11 @@ public class BukkitItemManager extends AbstractItemManager {
CustomCropsWorld<?> world = optionalWorld.get();
WrappedInteractEvent wrapped = new WrappedInteractEvent(ExistenceForm.FURNITURE, player, world, location, furnitureID, itemInHand, itemID, hand, null, event);
handleInteractEvent(furnitureID, itemID, wrapped);
handleInteractEvent(furnitureID, wrapped);
}
private void handleInteractEvent(String blockID, String itemID, WrappedInteractEvent wrapped) {
CustomCropsItem customCropsItem = Registries.ITEMS.get(itemID);
private void handleInteractEvent(String blockID, WrappedInteractEvent wrapped) {
CustomCropsItem customCropsItem = Registries.ITEMS.get(wrapped.itemID());
if (customCropsItem != null) {
InteractionResult result = customCropsItem.interactAt(wrapped);
if (result != InteractionResult.PASS)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
* 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