mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-21 16:09:21 +00:00
[Feature] Variation keeps the data
This commit is contained in:
@@ -151,6 +151,13 @@ public interface Crop extends KeyItem {
|
||||
|
||||
interface Stage {
|
||||
|
||||
/**
|
||||
* Get the crop config
|
||||
*
|
||||
* @return crop config
|
||||
*/
|
||||
Crop getCrop();
|
||||
|
||||
/**
|
||||
* Get the offset of the hologram
|
||||
*
|
||||
|
||||
@@ -494,9 +494,12 @@ public class ActionManagerImpl implements ActionManager {
|
||||
}
|
||||
for (VariationCrop variationCrop : variations) {
|
||||
if (Math.random() < variationCrop.getChance() + bonus) {
|
||||
SimpleLocation location = SimpleLocation.of(state.getLocation());
|
||||
plugin.getItemManager().removeAnythingAt(state.getLocation());
|
||||
plugin.getWorldManager().removeAnythingAt(SimpleLocation.of(state.getLocation()));
|
||||
plugin.getWorldManager().removeAnythingAt(location);
|
||||
plugin.getItemManager().placeItem(state.getLocation(), variationCrop.getItemCarrier(), variationCrop.getItemID());
|
||||
Optional.ofNullable(plugin.getItemManager().getCropStageByStageID(variationCrop.getItemID()))
|
||||
.ifPresent(stage -> plugin.getWorldManager().addCropAt(new MemoryCrop(location, stage.getCrop().getKey(), stage.getPoint()), location));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.mechanic.item.impl;
|
||||
|
||||
import net.momirealms.customcrops.api.CustomCropsPlugin;
|
||||
import net.momirealms.customcrops.api.mechanic.action.Action;
|
||||
import net.momirealms.customcrops.api.mechanic.action.ActionTrigger;
|
||||
import net.momirealms.customcrops.api.mechanic.condition.Conditions;
|
||||
@@ -206,6 +207,11 @@ public class CropConfig extends AbstractEventItem implements Crop {
|
||||
this.breakRequirements = breakRequirements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Crop getCrop() {
|
||||
return CustomCropsPlugin.get().getItemManager().getCropByStageID(stageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHologramOffset() {
|
||||
return hologramOffset;
|
||||
|
||||
Reference in New Issue
Block a user