mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 08:29:35 +00:00
1.5.21
This commit is contained in:
@@ -146,10 +146,13 @@ public class CropManager {
|
||||
}
|
||||
Location potLocation = seedLocation.clone().subtract(0,1,0);
|
||||
CustomBlock pot = CustomBlock.byAlreadyPlaced(potLocation.getBlock());
|
||||
if (pot == null) return;
|
||||
String potNamespacedID = pot.getNamespacedID();
|
||||
String[] cropNameList = StringUtils.split(id,"_");
|
||||
CropInstance cropInstance = ConfigReader.CROPS.get(cropNameList[0]);
|
||||
if (pot == null || cropInstance == null){
|
||||
data.set(stringBuilder.toString(), null);
|
||||
return;
|
||||
}
|
||||
int random = new Random().nextInt(ConfigReader.Config.timeToGrow);
|
||||
if (potNamespacedID.equals(ConfigReader.Basic.watered_pot)){
|
||||
//如果启用季节限制且农作物有季节需求
|
||||
@@ -207,7 +210,7 @@ public class CropManager {
|
||||
}
|
||||
}, random);
|
||||
}else {
|
||||
if (cropInstance.getReturnStage() == null && !ConfigReader.Season.enable) data.set(stringBuilder.toString(), null);
|
||||
if (!ConfigReader.Season.enable) data.set(stringBuilder.toString(), null);
|
||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () -> {
|
||||
CustomBlock.remove(potLocation);
|
||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||
@@ -222,6 +225,8 @@ public class CropManager {
|
||||
CustomBlock.place(ConfigReader.Basic.dead, seedLocation);
|
||||
}, random);
|
||||
}
|
||||
}else {
|
||||
data.set(stringBuilder.toString(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -277,10 +282,13 @@ public class CropManager {
|
||||
}
|
||||
Location potLocation = seedLocation.clone().subtract(0,1,0);
|
||||
CustomBlock pot = CustomBlock.byAlreadyPlaced(potLocation.getBlock());
|
||||
if (pot == null) return;
|
||||
String potNamespacedID = pot.getNamespacedID();
|
||||
String[] cropNameList = StringUtils.split(id,"_");
|
||||
CropInstance cropInstance = ConfigReader.CROPS.get(cropNameList[0]);
|
||||
if (pot == null || cropInstance == null){
|
||||
data.set(stringBuilder.toString(), null);
|
||||
return;
|
||||
}
|
||||
int random = new Random().nextInt(ConfigReader.Config.timeToGrow);
|
||||
if (potNamespacedID.equals(ConfigReader.Basic.watered_pot)){
|
||||
if (ConfigReader.Season.enable && cropInstance.getSeasons() != null){
|
||||
@@ -337,7 +345,7 @@ public class CropManager {
|
||||
}
|
||||
}, random);
|
||||
}else {
|
||||
if (cropInstance.getReturnStage() == null && !ConfigReader.Season.enable) data.set(stringBuilder.toString(), null);
|
||||
if (!ConfigReader.Season.enable) data.set(stringBuilder.toString(), null);
|
||||
bukkitScheduler.runTaskLater(CustomCrops.instance, () -> {
|
||||
CustomBlock.remove(potLocation);
|
||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||
@@ -352,6 +360,8 @@ public class CropManager {
|
||||
CustomBlock.place(ConfigReader.Basic.dead, seedLocation);
|
||||
}, random);
|
||||
}
|
||||
}else {
|
||||
data.set(stringBuilder.toString(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -369,8 +369,8 @@ public class RightClick implements Listener {
|
||||
String[] cropNameList = StringUtils.split(customBlock.getId(), "_");
|
||||
int nextStage = Integer.parseInt(cropNameList[2]) + 1;
|
||||
if (CustomBlock.getInstance(StringUtils.chop(namespacedID) + nextStage) == null) {
|
||||
if (ConfigReader.Config.quality){
|
||||
CropInstance cropInstance = ConfigReader.CROPS.get(cropNameList[0]);
|
||||
if (ConfigReader.Config.quality){
|
||||
ThreadLocalRandom current = ThreadLocalRandom.current();
|
||||
int random = current.nextInt(cropInstance.getMin(), cropInstance.getMax() + 1);
|
||||
World world = location.getWorld();
|
||||
@@ -417,10 +417,10 @@ public class RightClick implements Listener {
|
||||
customBlock.getLoot().forEach(loot-> location.getWorld().dropItem(location.clone().add(0.5,0.2,0.5), loot));
|
||||
}
|
||||
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);
|
||||
if(cropInstance.getReturnStage() != null){
|
||||
CustomBlock.place(cropInstance.getReturnStage(), location);
|
||||
CropManager.Cache.put(location, cropNameList[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,9 @@ crops:
|
||||
1: customcrops:cabbage
|
||||
2: customcrops:cabbage_silver_star
|
||||
3: customcrops:cabbage_golden_star
|
||||
gigantic: customcrops:gigantic_cabbage
|
||||
gigantic-chance: 0.01
|
||||
gigantic:
|
||||
block: customcrops:gigantic_cabbage
|
||||
chance: 0.01
|
||||
season:
|
||||
- spring
|
||||
|
||||
|
||||
Reference in New Issue
Block a user