9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-27 19:09:09 +00:00
This commit is contained in:
XiaoMoMi
2025-01-18 22:49:20 +08:00
parent 3eb778e687
commit 93d83ac467
6 changed files with 26 additions and 4 deletions

View File

@@ -21,7 +21,6 @@ import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
import net.momirealms.customcrops.api.action.Action;
import net.momirealms.customcrops.api.context.Context;
import net.momirealms.customcrops.api.misc.value.MathValue;
import org.bukkit.entity.Player;
public abstract class AbstractBuiltInAction<T> implements Action<T> {

View File

@@ -33,6 +33,9 @@ import static java.util.Objects.requireNonNull;
public class ActionSpawnEntity<T> extends AbstractBuiltInAction<T> {
private final String id;
private MathValue<T> x;
private MathValue<T> y;
private MathValue<T> z;
private final Map<String, Object> properties;
public ActionSpawnEntity(
@@ -42,6 +45,9 @@ public class ActionSpawnEntity<T> extends AbstractBuiltInAction<T> {
) {
super(plugin, chance);
this.id = section.getString("id");
this.x = MathValue.auto(section.get("x", 0));
this.y = MathValue.auto(section.get("y", 0));
this.z = MathValue.auto(section.get("z", 0));
Section proeprtySection = section.getSection("properties");
this.properties = proeprtySection == null ? new HashMap<>() : proeprtySection.getStringRouteMappedValues(false);
}
@@ -49,6 +55,7 @@ public class ActionSpawnEntity<T> extends AbstractBuiltInAction<T> {
@Override
protected void triggerAction(Context<T> context) {
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
location = location.clone().add(this.x.evaluate(context), this.y.evaluate(context), this.z.evaluate(context));
String finalID;
EntityProvider provider;
if (id.contains(":")) {

View File

@@ -20,7 +20,6 @@ package net.momirealms.customcrops.api.core.world;
import com.flowpowered.nbt.CompoundMap;
import com.flowpowered.nbt.CompoundTag;
import com.flowpowered.nbt.Tag;
import com.flowpowered.nbt.stream.NBTInputStream;
import net.momirealms.customcrops.api.core.SynchronizedCompoundMap;
import net.momirealms.customcrops.api.core.block.CustomCropsBlock;
import net.momirealms.customcrops.api.util.TagUtils;