mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
1.5.10
new particle and sound
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '1.5.9'
|
||||
version = '1.5.10'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -71,6 +71,7 @@ public class ConfigReader {
|
||||
public static String referenceWorld;
|
||||
public static boolean asyncCheck;
|
||||
public static boolean enableLimit;
|
||||
public static boolean hasParticle;
|
||||
public static int cropLimit;
|
||||
public static int sprinklerLimit;
|
||||
public static int yMin;
|
||||
@@ -109,6 +110,7 @@ public class ConfigReader {
|
||||
logTime = config.getBoolean("config.log-time-consume",false);
|
||||
onlyLoadedGrow = !config.getBoolean("config.only-grow-in-loaded-chunks",true);
|
||||
allWorld = config.getBoolean("config.all-world-grow",false);
|
||||
hasParticle = config.getBoolean("config.water-particles", true);
|
||||
|
||||
//数量与高度限制
|
||||
enableLimit = config.getBoolean("config.limit.enable",true);
|
||||
@@ -523,26 +525,32 @@ public class ConfigReader {
|
||||
public static Key useFertilizerKey;
|
||||
public static net.kyori.adventure.sound.Sound.Source useFertilizerSource;
|
||||
|
||||
public static Key harvestKey;
|
||||
public static net.kyori.adventure.sound.Sound.Source harvestSource;
|
||||
|
||||
public static void loadSound(){
|
||||
YamlConfiguration config = getConfig("sounds.yml");
|
||||
|
||||
waterPotKey = Key.key(config.getString("water-pot.sound"));
|
||||
waterPotSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("water-pot.type").toUpperCase());
|
||||
waterPotKey = Key.key(config.getString("water-pot.sound", "minecraft:block.water.ambient"));
|
||||
waterPotSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("water-pot.type","player").toUpperCase());
|
||||
|
||||
addWaterToCanKey = Key.key(config.getString("add-water-to-can.sound"));
|
||||
addWaterToCanSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-can.type").toUpperCase());
|
||||
addWaterToCanKey = Key.key(config.getString("add-water-to-can.sound", "minecraft:item.bucket.fill"));
|
||||
addWaterToCanSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-can.type","player").toUpperCase());
|
||||
|
||||
addWaterToSprinklerKey = Key.key(config.getString("add-water-to-sprinkler.sound"));
|
||||
addWaterToSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-sprinkler.type").toUpperCase());
|
||||
addWaterToSprinklerKey = Key.key(config.getString("add-water-to-sprinkler.sound", "minecraft:item.bucket.fill"));
|
||||
addWaterToSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("add-water-to-sprinkler.type","player").toUpperCase());
|
||||
|
||||
placeSprinklerKey = Key.key(config.getString("place-sprinkler.sound"));
|
||||
placeSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("place-sprinkler.type").toUpperCase());
|
||||
placeSprinklerKey = Key.key(config.getString("place-sprinkler.sound", "minecraft:block.bone_block.place"));
|
||||
placeSprinklerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("place-sprinkler.type","player").toUpperCase());
|
||||
|
||||
plantSeedKey = Key.key(config.getString("plant-seed.sound"));
|
||||
plantSeedSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("plant-seed.type").toUpperCase());
|
||||
plantSeedKey = Key.key(config.getString("plant-seed.sound", "minecraft:item.hoe.till"));
|
||||
plantSeedSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("plant-seed.type","player").toUpperCase());
|
||||
|
||||
useFertilizerKey = Key.key(config.getString("use-fertilizer.sound"));
|
||||
useFertilizerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("use-fertilizer.type").toUpperCase());
|
||||
useFertilizerKey = Key.key(config.getString("use-fertilizer.sound", "minecraft:item.hoe.till"));
|
||||
useFertilizerSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("use-fertilizer.type","player").toUpperCase());
|
||||
|
||||
harvestKey = Key.key(config.getString("harvest.sound", "minecraft:block.crop.break"));
|
||||
harvestSource = net.kyori.adventure.sound.Sound.Source.valueOf(config.getString("harvest.type", "player").toUpperCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.momirealms.customcrops.utils.Sprinkler;
|
||||
import net.momirealms.customcrops.utils.WateringCan;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -77,7 +78,6 @@ public class InteractEntity implements Listener {
|
||||
Sprinkler sprinkler = SprinklerManager.Cache.get(loc);
|
||||
if (itemStack.getType() == Material.WATER_BUCKET){
|
||||
itemStack.setType(Material.BUCKET);
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey);
|
||||
if (sprinkler != null){
|
||||
currentWater = sprinkler.getWater();
|
||||
currentWater += ConfigReader.Config.sprinklerRefill;
|
||||
@@ -94,6 +94,7 @@ public class InteractEntity implements Listener {
|
||||
}
|
||||
plugin.getSprinklerManager().data.set(path, currentWater);
|
||||
}
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey);
|
||||
}
|
||||
else {
|
||||
if (ConfigReader.Config.canAddWater && itemStack.getType() != Material.AIR){
|
||||
|
||||
@@ -39,10 +39,7 @@ import net.momirealms.customcrops.requirements.PlantingCondition;
|
||||
import net.momirealms.customcrops.requirements.Requirement;
|
||||
import net.momirealms.customcrops.utils.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -159,6 +156,7 @@ public class RightClick implements Listener {
|
||||
}
|
||||
nbtItem.setInteger("WaterAmount", water);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.ITEM_BUCKET_FILL,1,1);
|
||||
|
||||
if (ConfigReader.Message.hasWaterInfo){
|
||||
String string = ConfigReader.Message.waterLeft + ConfigReader.Message.waterFull.repeat(water) +
|
||||
ConfigReader.Message.waterEmpty.repeat(wateringCan.getMax() - water) + ConfigReader.Message.waterRight;
|
||||
@@ -171,6 +169,9 @@ public class RightClick implements Listener {
|
||||
lores.clear();
|
||||
ConfigReader.Basic.waterLore.forEach(lore -> lores.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(lore.replace("{water_info}", string)))));
|
||||
}
|
||||
if (ConfigReader.Config.hasParticle){
|
||||
player.getWorld().spawnParticle(Particle.WATER_SPLASH, block.getLocation().add(0.5,1, 0.5),15,0.1,0.1,0.1);
|
||||
}
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
}
|
||||
return;
|
||||
@@ -363,6 +364,7 @@ public class RightClick implements Listener {
|
||||
}
|
||||
CustomBlock.remove(location);
|
||||
CropInstance crop = ConfigReader.CROPS.get(cropNameList[0]);
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.harvestSource, ConfigReader.Sounds.harvestKey);
|
||||
if(crop.getReturnStage() != null){
|
||||
CustomBlock.place(crop.getReturnStage(), location);
|
||||
}
|
||||
@@ -390,7 +392,10 @@ public class RightClick implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void waterPot(int width, int length, Location clickedLocation, float yaw){
|
||||
private void waterPot(int width, int length, Location location, float yaw){
|
||||
if (ConfigReader.Config.hasParticle){
|
||||
location.getWorld().spawnParticle(Particle.WATER_SPLASH, location.clone().add(0.5,1.2,0.5),15,0.1,0.1, 0.1);
|
||||
}
|
||||
int extend = width / 2;
|
||||
// -90~90 z+
|
||||
// -180~-90 & 90-180 z-
|
||||
@@ -400,7 +405,7 @@ public class RightClick implements Listener {
|
||||
// -45 ~ 45
|
||||
if (yaw > -45) {
|
||||
for (int i = -extend; i <= extend; i++) {
|
||||
Location tempLoc = clickedLocation.clone().add(i, 0, -1);
|
||||
Location tempLoc = location.clone().add(i, 0, -1);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.add(0,0,1);
|
||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
|
||||
@@ -416,7 +421,7 @@ public class RightClick implements Listener {
|
||||
// -135 ~ -45
|
||||
else {
|
||||
for (int i = -extend; i <= extend; i++) {
|
||||
Location tempLoc = clickedLocation.clone().add(-1, 0, i);
|
||||
Location tempLoc = location.clone().add(-1, 0, i);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.add(1,0,0);
|
||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
|
||||
@@ -434,7 +439,7 @@ public class RightClick implements Listener {
|
||||
// 45 ~ 135
|
||||
if (yaw > 45 && yaw < 135) {
|
||||
for (int i = -extend; i <= extend; i++) {
|
||||
Location tempLoc = clickedLocation.clone().add(1, 0, i);
|
||||
Location tempLoc = location.clone().add(1, 0, i);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.subtract(1,0,0);
|
||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
|
||||
@@ -450,7 +455,7 @@ public class RightClick implements Listener {
|
||||
// -180 ~ -135 135~180
|
||||
else {
|
||||
for (int i = -extend; i <= extend; i++) {
|
||||
Location tempLoc = clickedLocation.clone().add(i, 0, 1);
|
||||
Location tempLoc = location.clone().add(i, 0, 1);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.subtract(0,0,1);
|
||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(tempLoc.getBlock());
|
||||
|
||||
@@ -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.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -43,6 +43,8 @@ config:
|
||||
water-can-refill: 1
|
||||
#是否可以用水壶为洒水器加水
|
||||
water-can-add-water-to-sprinkler: true
|
||||
#使用水的时候是否产生粒子效果
|
||||
water-particles: true
|
||||
|
||||
#生长生效的世界
|
||||
whitelist-worlds:
|
||||
|
||||
@@ -22,3 +22,7 @@ plant-seed:
|
||||
use-fertilizer:
|
||||
sound: minecraft:item.hoe.till
|
||||
type: player
|
||||
#空手收获的音效
|
||||
harvest:
|
||||
sound: minecraft:block.crop.break
|
||||
type: player
|
||||
Reference in New Issue
Block a user