mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
Merge remote-tracking branch 'upstream/dev' into dev
# Conflicts: # common-files/src/main/resources/translations/en.yml # common-files/src/main/resources/translations/zh_cn.yml
This commit is contained in:
@@ -130,7 +130,7 @@ public abstract class Furniture implements Cullable {
|
||||
if (aabb == null) {
|
||||
List<AABB> aabbs = new ArrayList<>();
|
||||
for (FurnitureHitBoxConfig<?> hitBoxConfig : this.currentVariant.hitBoxConfigs()) {
|
||||
hitBoxConfig.prepareForPlacement(position, aabbs::add);
|
||||
hitBoxConfig.prepareBoundingBox(position, aabbs::add, true);
|
||||
}
|
||||
return new CullingData(getMaxAABB(aabbs), parent.maxDistance, parent.aabbExpansion, parent.rayTracing);
|
||||
} else {
|
||||
|
||||
@@ -22,6 +22,6 @@ public interface FurnitureHitBoxConfig<H extends FurnitureHitBox> {
|
||||
|
||||
boolean canUseItemOn();
|
||||
|
||||
void prepareForPlacement(WorldPosition targetPos, Consumer<AABB> aabbConsumer);
|
||||
void prepareBoundingBox(WorldPosition targetPos, Consumer<AABB> aabbConsumer, boolean ignoreBlocksBuilding);
|
||||
|
||||
}
|
||||
|
||||
@@ -226,6 +226,8 @@ public abstract class Player extends AbstractEntity implements NetWorkUser {
|
||||
|
||||
public abstract void clearTrackedBlockEntities();
|
||||
|
||||
public abstract int clearOrCountMatchingInventoryItems(Key itemId, int count);
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
}
|
||||
|
||||
@@ -31,4 +31,5 @@ public final class CommonConditions {
|
||||
public static final Key IS_NULL = Key.from("craftengine:is_null");
|
||||
public static final Key HAND = Key.from("craftengine:hand");
|
||||
public static final Key HAS_PLAYER = Key.from("craftengine:has_player");
|
||||
public static final Key INVENTORY_HAS_ITEM = Key.from("craftengine:inventory_has_item");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.condition;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.context.number.NumberProvider;
|
||||
import net.momirealms.craftengine.core.plugin.context.number.NumberProviders;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
import net.momirealms.craftengine.core.util.ItemUtils;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class InventoryHasItemCondition<CTX extends Context> implements Condition<CTX> {
|
||||
private final Key itemId;
|
||||
private final NumberProvider count;
|
||||
|
||||
public InventoryHasItemCondition(Key itemId, NumberProvider count) {
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return CommonConditions.INVENTORY_HAS_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(CTX ctx) {
|
||||
Optional<Player> optionalPlayer = ctx.getOptionalParameter(DirectContextParameters.PLAYER);
|
||||
if (optionalPlayer.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Player player = optionalPlayer.get();
|
||||
return player.clearOrCountMatchingInventoryItems(this.itemId, 0) >= this.count.getInt(ctx);
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> implements ConditionFactory<CTX> {
|
||||
|
||||
@Override
|
||||
public Condition<CTX> create(Map<String, Object> arguments) {
|
||||
Key itemId = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(ResourceConfigUtils.get(arguments, "id", "item"), "warning.config.condition.inventory_has_item.missing_id"));
|
||||
NumberProvider count = NumberProviders.fromObject(arguments.getOrDefault("count", 1));
|
||||
return new InventoryHasItemCondition<>(itemId, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class EventConditions {
|
||||
register(CommonConditions.IS_NULL, new IsNullCondition.FactoryImpl<>());
|
||||
register(CommonConditions.HAND, new HandCondition.FactoryImpl<>());
|
||||
register(CommonConditions.ON_COOLDOWN, new OnCooldownCondition.FactoryImpl<>());
|
||||
register(CommonConditions.INVENTORY_HAS_ITEM, new InventoryHasItemCondition.FactoryImpl<>());
|
||||
}
|
||||
|
||||
public static void register(Key key, ConditionFactory<Context> factory) {
|
||||
|
||||
@@ -43,6 +43,7 @@ public class EventFunctions {
|
||||
register(CommonFunctions.SPAWN_FURNITURE, new SpawnFurnitureFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.REMOVE_FURNITURE, new RemoveFurnitureFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.REPLACE_FURNITURE, new ReplaceFurnitureFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.ROTATE_FURNITURE, new RotateFurnitureFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.MYTHIC_MOBS_SKILL, new MythicMobsSkillFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.TELEPORT, new TeleportFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.SET_VARIABLE, new SetVariableFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
@@ -58,6 +59,8 @@ public class EventFunctions {
|
||||
register(CommonFunctions.SET_EXP, new SetExpFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.SET_LEVEL, new SetLevelFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.PLAY_TOTEM_ANIMATION, new PlayTotemAnimationFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.CLOSE_INVENTORY, new CloseInventoryFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
register(CommonFunctions.CLEAR_ITEM, new ClearItemFunction.FactoryImpl<>(EventConditions::fromMap));
|
||||
}
|
||||
|
||||
public static void register(Key key, FunctionFactory<Context> factory) {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BreakBlockFunction<CTX extends Context> extends AbstractConditional
|
||||
private final NumberProvider y;
|
||||
private final NumberProvider z;
|
||||
|
||||
public BreakBlockFunction(NumberProvider x, NumberProvider y, NumberProvider z, List<Condition<CTX>> predicates) {
|
||||
public BreakBlockFunction(List<Condition<CTX>> predicates, NumberProvider y, NumberProvider z, NumberProvider x) {
|
||||
super(predicates);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -47,7 +47,7 @@ public class BreakBlockFunction<CTX extends Context> extends AbstractConditional
|
||||
NumberProvider x = NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>"));
|
||||
NumberProvider y = NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>"));
|
||||
NumberProvider z = NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>"));
|
||||
return new BreakBlockFunction<>(x, y, z, getPredicates(arguments));
|
||||
return new BreakBlockFunction<>(getPredicates(arguments), y, z, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.function;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.context.number.NumberProvider;
|
||||
import net.momirealms.craftengine.core.plugin.context.number.NumberProviders;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ClearItemFunction<CTX extends Context> extends AbstractConditionalFunction<CTX> {
|
||||
private final Key itemId;
|
||||
private final NumberProvider count;
|
||||
|
||||
public ClearItemFunction(List<Condition<CTX>> predicates, Key itemId, NumberProvider count) {
|
||||
super(predicates);
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runInternal(CTX ctx) {
|
||||
Optional<Player> optionalPlayer = ctx.getOptionalParameter(DirectContextParameters.PLAYER);
|
||||
if (optionalPlayer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Player player = optionalPlayer.get();
|
||||
player.clearOrCountMatchingInventoryItems(itemId, count.getInt(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return CommonFunctions.CLEAR_ITEM;
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> extends AbstractFactory<CTX> {
|
||||
|
||||
public FactoryImpl(java.util.function.Function<Map<String, Object>, Condition<CTX>> factory) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
Key itemId = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(ResourceConfigUtils.get(arguments, "id", "item"), "warning.config.function.clear_item.missing_id"));
|
||||
NumberProvider count = NumberProviders.fromObject(arguments.getOrDefault("count", 1));
|
||||
return new ClearItemFunction<>(getPredicates(arguments), itemId, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.function;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
import net.momirealms.craftengine.core.plugin.context.selector.PlayerSelector;
|
||||
import net.momirealms.craftengine.core.plugin.context.selector.PlayerSelectors;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CloseInventoryFunction<CTX extends Context> extends AbstractConditionalFunction<CTX> {
|
||||
private final PlayerSelector<CTX> selector;
|
||||
|
||||
public CloseInventoryFunction(List<Condition<CTX>> predicates, @Nullable PlayerSelector<CTX> selector) {
|
||||
super(predicates);
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runInternal(CTX ctx) {
|
||||
if (this.selector == null) {
|
||||
ctx.getOptionalParameter(DirectContextParameters.PLAYER).ifPresent(Player::closeInventory);
|
||||
} else {
|
||||
for (Player viewer : this.selector.get(ctx)) {
|
||||
viewer.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return CommonFunctions.CLOSE_INVENTORY;
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> extends AbstractFactory<CTX> {
|
||||
|
||||
public FactoryImpl(java.util.function.Function<Map<String, Object>, Condition<CTX>> factory) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
return new CloseInventoryFunction<>(getPredicates(arguments), PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public final class CommonFunctions {
|
||||
public static final Key SPAWN_FURNITURE = Key.of("craftengine:spawn_furniture");
|
||||
public static final Key REMOVE_FURNITURE = Key.of("craftengine:remove_furniture");
|
||||
public static final Key REPLACE_FURNITURE = Key.of("craftengine:replace_furniture");
|
||||
public static final Key ROTATE_FURNITURE = Key.of("craftengine:rotate_furniture");
|
||||
public static final Key MYTHIC_MOBS_SKILL = Key.of("craftengine:mythic_mobs_skill");
|
||||
public static final Key TELEPORT = Key.of("craftengine:teleport");
|
||||
public static final Key TOAST = Key.of("craftengine:toast");
|
||||
@@ -49,4 +50,6 @@ public final class CommonFunctions {
|
||||
public static final Key SET_EXP = Key.of("craftengine:set_exp");
|
||||
public static final Key SET_LEVEL = Key.of("craftengine:set_level");
|
||||
public static final Key PLAY_TOTEM_ANIMATION = Key.of("craftengine:play_totem_animation");
|
||||
public static final Key CLOSE_INVENTORY = Key.of("craftengine:close_inventory");
|
||||
public static final Key CLEAR_ITEM = Key.of("craftengine:clear_item");
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DamageFunction<CTX extends Context> extends AbstractConditionalFunc
|
||||
private final Key damageType;
|
||||
private final NumberProvider amount;
|
||||
|
||||
public DamageFunction(PlayerSelector<CTX> selector, Key damageType, NumberProvider amount, List<Condition<CTX>> predicates) {
|
||||
public DamageFunction(List<Condition<CTX>> predicates, Key damageType, NumberProvider amount, PlayerSelector<CTX> selector) {
|
||||
super(predicates);
|
||||
this.selector = selector;
|
||||
this.damageType = damageType;
|
||||
@@ -45,7 +45,7 @@ public class DamageFunction<CTX extends Context> extends AbstractConditionalFunc
|
||||
PlayerSelector<CTX> selector = PlayerSelectors.fromObject(arguments.getOrDefault("target", "self"), conditionFactory());
|
||||
Key damageType = Key.of(ResourceConfigUtils.getAsStringOrNull(arguments.getOrDefault("damage-type", "generic")));
|
||||
NumberProvider amount = NumberProviders.fromObject(arguments.getOrDefault("amount", 1f));
|
||||
return new DamageFunction<>(selector, damageType, amount, getPredicates(arguments));
|
||||
return new DamageFunction<>(getPredicates(arguments), damageType, amount, selector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Map;
|
||||
public class DamageItemFunction<CTX extends Context> extends AbstractConditionalFunction<CTX> {
|
||||
private final NumberProvider amount;
|
||||
|
||||
public DamageItemFunction(NumberProvider amount, List<Condition<CTX>> predicates) {
|
||||
public DamageItemFunction(List<Condition<CTX>> predicates, NumberProvider amount) {
|
||||
super(predicates);
|
||||
this.amount = amount;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class DamageItemFunction<CTX extends Context> extends AbstractConditional
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
NumberProvider amount = NumberProviders.fromObject(arguments.getOrDefault("amount", 1));
|
||||
return new DamageItemFunction<>(amount, getPredicates(arguments));
|
||||
return new DamageItemFunction<>(getPredicates(arguments), amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class LevelerExpFunction<CTX extends Context> extends AbstractConditional
|
||||
private final String leveler;
|
||||
private final String plugin;
|
||||
|
||||
public LevelerExpFunction(NumberProvider count, String leveler, String plugin, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public LevelerExpFunction(List<Condition<CTX>> predicates, String leveler, String plugin, PlayerSelector<CTX> selector, NumberProvider count) {
|
||||
super(predicates);
|
||||
this.count = count;
|
||||
this.leveler = leveler;
|
||||
@@ -58,7 +58,7 @@ public class LevelerExpFunction<CTX extends Context> extends AbstractConditional
|
||||
Object count = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("count"), "warning.config.function.leveler_exp.missing_count");
|
||||
String leveler = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("leveler"), "warning.config.function.leveler_exp.missing_leveler");
|
||||
String plugin = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("plugin"), "warning.config.function.leveler_exp.missing_plugin");
|
||||
return new LevelerExpFunction<>(NumberProviders.fromObject(count), leveler, plugin, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new LevelerExpFunction<>(getPredicates(arguments), leveler, plugin, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), NumberProviders.fromObject(count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class MythicMobsSkillFunction<CTX extends Context> extends AbstractCondit
|
||||
private final String skill;
|
||||
private final float power;
|
||||
|
||||
public MythicMobsSkillFunction(String skill, float power, List<Condition<CTX>> predicates) {
|
||||
public MythicMobsSkillFunction(List<Condition<CTX>> predicates, float power, String skill) {
|
||||
super(predicates);
|
||||
this.skill = skill;
|
||||
this.power = power;
|
||||
@@ -42,7 +42,7 @@ public class MythicMobsSkillFunction<CTX extends Context> extends AbstractCondit
|
||||
public Function<CTX> create(Map<String, Object> args) {
|
||||
String skill = ResourceConfigUtils.requireNonEmptyStringOrThrow(args.get("skill"), "warning.config.function.mythic_mobs_skill.missing_skill");
|
||||
float power = ResourceConfigUtils.getAsFloat(args.getOrDefault("power", 1.0), "power");
|
||||
return new MythicMobsSkillFunction<>(skill, power, getPredicates(args));
|
||||
return new MythicMobsSkillFunction<>(getPredicates(args), power, skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Optional;
|
||||
public class ParticleFunction<CTX extends Context> extends AbstractConditionalFunction<CTX> {
|
||||
private final ParticleConfig config;
|
||||
|
||||
public ParticleFunction(ParticleConfig config, List<Condition<CTX>> predicates) {
|
||||
public ParticleFunction(List<Condition<CTX>> predicates, ParticleConfig config) {
|
||||
super(predicates);
|
||||
this.config = config;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class ParticleFunction<CTX extends Context> extends AbstractConditionalFu
|
||||
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
return new ParticleFunction<>(ParticleConfig.fromMap$function(arguments), getPredicates(arguments));
|
||||
return new ParticleFunction<>(getPredicates(arguments), ParticleConfig.fromMap$function(arguments));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class PlaceBlockFunction<CTX extends Context> extends AbstractConditional
|
||||
private final NumberProvider z;
|
||||
private final NumberProvider updateFlags;
|
||||
|
||||
public PlaceBlockFunction(LazyReference<BlockStateWrapper> lazyBlockState, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider updateFlags, List<Condition<CTX>> predicates) {
|
||||
public PlaceBlockFunction(List<Condition<CTX>> predicates, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider updateFlags, LazyReference<BlockStateWrapper> lazyBlockState) {
|
||||
super(predicates);
|
||||
this.lazyBlockState = lazyBlockState;
|
||||
this.x = x;
|
||||
@@ -58,12 +58,7 @@ public class PlaceBlockFunction<CTX extends Context> extends AbstractConditional
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
String state = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("block-state"), "warning.config.function.place_block.missing_block_state");
|
||||
return new PlaceBlockFunction<>(LazyReference.lazyReference(() -> CraftEngine.instance().blockManager().createBlockState(state)),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>")),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>")),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>")),
|
||||
Optional.ofNullable(arguments.get("update-flags")).map(NumberProviders::fromObject).orElse(NumberProviders.direct(UpdateOption.UPDATE_ALL.flags())),
|
||||
getPredicates(arguments));
|
||||
return new PlaceBlockFunction<>(getPredicates(arguments), NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>")), NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>")), NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>")), Optional.ofNullable(arguments.get("update-flags")).map(NumberProviders::fromObject).orElse(NumberProviders.direct(UpdateOption.UPDATE_ALL.flags())), LazyReference.lazyReference(() -> CraftEngine.instance().blockManager().createBlockState(state)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,15 +31,7 @@ public class PlaySoundFunction<CTX extends Context> extends AbstractConditionalF
|
||||
private final PlayerSelector<CTX> selector;
|
||||
|
||||
public PlaySoundFunction(
|
||||
Key soundEvent,
|
||||
NumberProvider x,
|
||||
NumberProvider y,
|
||||
NumberProvider z,
|
||||
NumberProvider volume,
|
||||
NumberProvider pitch,
|
||||
SoundSource source,
|
||||
PlayerSelector<CTX> selector,
|
||||
List<Condition<CTX>> predicates
|
||||
List<Condition<CTX>> predicates, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider volume, NumberProvider pitch, SoundSource source, PlayerSelector<CTX> selector, Key soundEvent
|
||||
) {
|
||||
super(predicates);
|
||||
this.soundEvent = soundEvent;
|
||||
@@ -89,7 +81,7 @@ public class PlaySoundFunction<CTX extends Context> extends AbstractConditionalF
|
||||
NumberProvider pitch = NumberProviders.fromObject(arguments.getOrDefault("pitch", 1));
|
||||
SoundSource source = Optional.ofNullable(arguments.get("source")).map(String::valueOf).map(it -> SoundSource.valueOf(it.toUpperCase(Locale.ENGLISH))).orElse(SoundSource.MASTER);
|
||||
PlayerSelector<CTX> selector = PlayerSelectors.fromObject(arguments.get("target"), conditionFactory());
|
||||
return new PlaySoundFunction<>(soundEvent, x, y, z, volume, pitch, source, selector, getPredicates(arguments));
|
||||
return new PlaySoundFunction<>(getPredicates(arguments), x, y, z, volume, pitch, source, selector, soundEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PotionEffectFunction<CTX extends Context> extends AbstractCondition
|
||||
private final boolean ambient;
|
||||
private final boolean particles;
|
||||
|
||||
public PotionEffectFunction(Key potionEffectType, NumberProvider duration, NumberProvider amplifier, boolean ambient, boolean particles, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public PotionEffectFunction(List<Condition<CTX>> predicates, NumberProvider duration, NumberProvider amplifier, boolean ambient, boolean particles, PlayerSelector<CTX> selector, Key potionEffectType) {
|
||||
super(predicates);
|
||||
this.potionEffectType = potionEffectType;
|
||||
this.duration = duration;
|
||||
@@ -63,7 +63,7 @@ public class PotionEffectFunction<CTX extends Context> extends AbstractCondition
|
||||
NumberProvider amplifier = NumberProviders.fromObject(arguments.getOrDefault("amplifier", 0));
|
||||
boolean ambient = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("ambient", false), "ambient");
|
||||
boolean particles = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("particles", true), "particles");
|
||||
return new PotionEffectFunction<>(effectType, duration, amplifier, ambient, particles, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new PotionEffectFunction<>(getPredicates(arguments), duration, amplifier, ambient, particles, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), effectType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RemoveCooldownFunction<CTX extends Context> extends AbstractConditi
|
||||
private final String id;
|
||||
private final boolean all;
|
||||
|
||||
public RemoveCooldownFunction(String id, boolean all, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public RemoveCooldownFunction(List<Condition<CTX>> predicates, boolean all, PlayerSelector<CTX> selector, String id) {
|
||||
super(predicates);
|
||||
this.selector = selector;
|
||||
this.id = id;
|
||||
@@ -59,10 +59,10 @@ public class RemoveCooldownFunction<CTX extends Context> extends AbstractConditi
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
boolean all = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("all", false), "all");
|
||||
if (all) {
|
||||
return new RemoveCooldownFunction<>(null, true, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new RemoveCooldownFunction<>(getPredicates(arguments), true, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), null);
|
||||
} else {
|
||||
String id = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("id"), "warning.config.function.remove_cooldown.missing_id");
|
||||
return new RemoveCooldownFunction<>(id, false, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new RemoveCooldownFunction<>(getPredicates(arguments), false, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class RemoveFurnitureFunction<CTX extends Context> extends AbstractCondit
|
||||
private final boolean dropLoot;
|
||||
private final boolean playSound;
|
||||
|
||||
public RemoveFurnitureFunction(boolean dropLoot, boolean playSound, List<Condition<CTX>> predicates) {
|
||||
public RemoveFurnitureFunction(List<Condition<CTX>> predicates, boolean playSound, boolean dropLoot) {
|
||||
super(predicates);
|
||||
this.dropLoot = dropLoot;
|
||||
this.playSound = playSound;
|
||||
@@ -80,7 +80,7 @@ public class RemoveFurnitureFunction<CTX extends Context> extends AbstractCondit
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
boolean dropLoot = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("drop-loot", true), "drop-loot");
|
||||
boolean playSound = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("play-sound", true), "play-sound");
|
||||
return new RemoveFurnitureFunction<>(dropLoot, playSound, getPredicates(arguments));
|
||||
return new RemoveFurnitureFunction<>(getPredicates(arguments), playSound, dropLoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class RemovePotionEffectFunction<CTX extends Context> extends AbstractCon
|
||||
private final Key potionEffectType;
|
||||
private final boolean all;
|
||||
|
||||
public RemovePotionEffectFunction(Key potionEffectType, boolean all, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public RemovePotionEffectFunction(List<Condition<CTX>> predicates, boolean all, PlayerSelector<CTX> selector, Key potionEffectType) {
|
||||
super(predicates);
|
||||
this.potionEffectType = potionEffectType;
|
||||
this.selector = selector;
|
||||
@@ -54,10 +54,10 @@ public class RemovePotionEffectFunction<CTX extends Context> extends AbstractCon
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
boolean all = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("all", false), "all");
|
||||
if (all) {
|
||||
return new RemovePotionEffectFunction<>(null, true, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new RemovePotionEffectFunction<>(getPredicates(arguments), true, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), null);
|
||||
} else {
|
||||
Key effectType = Key.of(ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("potion-effect"), "warning.config.function.remove_potion_effect.missing_potion_effect"));
|
||||
return new RemovePotionEffectFunction<>(effectType, false, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new RemovePotionEffectFunction<>(getPredicates(arguments), false, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), effectType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,16 +26,7 @@ public class ReplaceFurnitureFunction<CTX extends Context> extends AbstractCondi
|
||||
private final boolean playSound;
|
||||
|
||||
public ReplaceFurnitureFunction(
|
||||
Key newFurnitureId,
|
||||
NumberProvider x,
|
||||
NumberProvider y,
|
||||
NumberProvider z,
|
||||
NumberProvider pitch,
|
||||
NumberProvider yaw,
|
||||
String variant,
|
||||
boolean dropLoot,
|
||||
boolean playSound,
|
||||
List<Condition<CTX>> predicates
|
||||
List<Condition<CTX>> predicates, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider pitch, NumberProvider yaw, String variant, boolean dropLoot, boolean playSound, Key newFurnitureId
|
||||
) {
|
||||
super(predicates);
|
||||
this.newFurnitureId = newFurnitureId;
|
||||
@@ -96,7 +87,7 @@ public class ReplaceFurnitureFunction<CTX extends Context> extends AbstractCondi
|
||||
String variant = ResourceConfigUtils.getAsStringOrNull(ResourceConfigUtils.get(arguments, "variant", "anchor-type"));
|
||||
boolean dropLoot = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("drop-loot", true), "drop-loot");
|
||||
boolean playSound = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("play-sound", true), "play-sound");
|
||||
return new ReplaceFurnitureFunction<>(furnitureId, x, y, z, pitch, yaw, variant, dropLoot, playSound, getPredicates(arguments));
|
||||
return new ReplaceFurnitureFunction<>(getPredicates(arguments), x, y, z, pitch, yaw, variant, dropLoot, playSound, furnitureId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.function;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||
import net.momirealms.craftengine.core.entity.player.InteractionHand;
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.loot.LootTable;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.context.ContextHolder;
|
||||
import net.momirealms.craftengine.core.plugin.context.event.EventFunctions;
|
||||
import net.momirealms.craftengine.core.plugin.context.number.NumberProvider;
|
||||
import net.momirealms.craftengine.core.plugin.context.number.NumberProviders;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
import net.momirealms.craftengine.core.sound.SoundData;
|
||||
import net.momirealms.craftengine.core.sound.SoundSource;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class RotateFurnitureFunction<CTX extends Context> extends AbstractConditionalFunction<CTX> {
|
||||
private final NumberProvider degree;
|
||||
private final List<Function<Context>> successFunctions;
|
||||
private final List<Function<Context>> failureFunctions;
|
||||
|
||||
public RotateFurnitureFunction(List<Condition<CTX>> predicates, NumberProvider degree, List<Function<Context>> successFunctions, List<Function<Context>> failureFunctions) {
|
||||
super(predicates);
|
||||
this.degree = degree;
|
||||
this.successFunctions = successFunctions;
|
||||
this.failureFunctions = failureFunctions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runInternal(CTX ctx) {
|
||||
ctx.getOptionalParameter(DirectContextParameters.FURNITURE).ifPresent(furniture -> rotateFurniture(ctx, furniture));
|
||||
}
|
||||
|
||||
public void rotateFurniture(CTX ctx, Furniture furniture) {
|
||||
if (!furniture.isValid()) return;
|
||||
WorldPosition position = furniture.position();
|
||||
WorldPosition newPos = new WorldPosition(position.world, position.x, position.y, position.z, position.xRot, position.yRot + this.degree.getFloat(ctx));
|
||||
furniture.moveTo(newPos).thenAccept(success -> {
|
||||
if (success) {
|
||||
for (Function<Context> successFunction : this.successFunctions) {
|
||||
successFunction.run(ctx);
|
||||
}
|
||||
} else {
|
||||
for (Function<Context> failureFunction : this.failureFunctions) {
|
||||
failureFunction.run(ctx);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key type() {
|
||||
return CommonFunctions.ROTATE_FURNITURE;
|
||||
}
|
||||
|
||||
public NumberProvider degree() {
|
||||
return degree;
|
||||
}
|
||||
|
||||
public static class FactoryImpl<CTX extends Context> extends AbstractFactory<CTX> {
|
||||
|
||||
public FactoryImpl(java.util.function.Function<Map<String, Object>, Condition<CTX>> factory) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
NumberProvider degree = NumberProviders.fromObject(arguments.getOrDefault("degree", 90));
|
||||
List<Function<Context>> onSuccess = ResourceConfigUtils.parseConfigAsList(arguments.get("on-success"), EventFunctions::fromMap);
|
||||
List<Function<Context>> onFailure = ResourceConfigUtils.parseConfigAsList(arguments.get("on-failure"), EventFunctions::fromMap);
|
||||
return new RotateFurnitureFunction<>(getPredicates(arguments), degree, onSuccess, onFailure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class RunFunction<CTX extends Context> extends AbstractConditionalFunctio
|
||||
private final List<Function<CTX>> functions;
|
||||
private final NumberProvider delay;
|
||||
|
||||
public RunFunction(List<Function<CTX>> functions, NumberProvider delay, List<Condition<CTX>> predicates) {
|
||||
public RunFunction(List<Condition<CTX>> predicates, NumberProvider delay, List<Function<CTX>> functions) {
|
||||
super(predicates);
|
||||
this.functions = functions;
|
||||
this.delay = delay;
|
||||
@@ -75,7 +75,7 @@ public class RunFunction<CTX extends Context> extends AbstractConditionalFunctio
|
||||
for (Map<String, Object> function : functions) {
|
||||
fun.add(this.functionFactory.apply(function));
|
||||
}
|
||||
return new RunFunction<>(fun, delay, getPredicates(arguments));
|
||||
return new RunFunction<>(getPredicates(arguments), delay, fun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SetCooldownFunction<CTX extends Context> extends AbstractConditiona
|
||||
private final String id;
|
||||
private final boolean add;
|
||||
|
||||
public SetCooldownFunction(TextProvider time, String id, boolean add, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public SetCooldownFunction(List<Condition<CTX>> predicates, String id, boolean add, PlayerSelector<CTX> selector, TextProvider time) {
|
||||
super(predicates);
|
||||
this.time = time;
|
||||
this.add = add;
|
||||
@@ -66,7 +66,7 @@ public class SetCooldownFunction<CTX extends Context> extends AbstractConditiona
|
||||
String id = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("id"), "warning.config.function.set_cooldown.missing_id");
|
||||
String time = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("time"), "warning.config.function.set_cooldown.missing_time");
|
||||
boolean add = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("add", false), "add");
|
||||
return new SetCooldownFunction<>(TextProviders.fromString(time), id, add, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new SetCooldownFunction<>(getPredicates(arguments), id, add, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), TextProviders.fromString(time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SetCountFunction<CTX extends Context> extends AbstractConditionalFu
|
||||
private final NumberProvider count;
|
||||
private final boolean add;
|
||||
|
||||
public SetCountFunction(NumberProvider count, boolean add, List<Condition<CTX>> predicates) {
|
||||
public SetCountFunction(List<Condition<CTX>> predicates, boolean add, NumberProvider count) {
|
||||
super(predicates);
|
||||
this.count = count;
|
||||
this.add = add;
|
||||
@@ -51,7 +51,7 @@ public class SetCountFunction<CTX extends Context> extends AbstractConditionalFu
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
Object value = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("count"), "warning.config.function.set_count.missing_count");
|
||||
boolean add = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("add", false), "add");
|
||||
return new SetCountFunction<>(NumberProviders.fromObject(value), add, getPredicates(arguments));
|
||||
return new SetCountFunction<>(getPredicates(arguments), add, NumberProviders.fromObject(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SetFoodFunction<CTX extends Context> extends AbstractConditionalFun
|
||||
private final NumberProvider count;
|
||||
private final boolean add;
|
||||
|
||||
public SetFoodFunction(NumberProvider count, boolean add, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public SetFoodFunction(List<Condition<CTX>> predicates, boolean add, PlayerSelector<CTX> selector, NumberProvider count) {
|
||||
super(predicates);
|
||||
this.count = count;
|
||||
this.add = add;
|
||||
@@ -54,7 +54,7 @@ public class SetFoodFunction<CTX extends Context> extends AbstractConditionalFun
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
Object value = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("food"), "warning.config.function.set_food.missing_food");
|
||||
boolean add = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("add", false), "add");
|
||||
return new SetFoodFunction<>(NumberProviders.fromObject(value), add, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new SetFoodFunction<>(getPredicates(arguments), add, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), NumberProviders.fromObject(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SetSaturationFunction<CTX extends Context> extends AbstractConditio
|
||||
private final NumberProvider count;
|
||||
private final boolean add;
|
||||
|
||||
public SetSaturationFunction(NumberProvider count, boolean add, PlayerSelector<CTX> selector, List<Condition<CTX>> predicates) {
|
||||
public SetSaturationFunction(List<Condition<CTX>> predicates, boolean add, PlayerSelector<CTX> selector, NumberProvider count) {
|
||||
super(predicates);
|
||||
this.count = count;
|
||||
this.add = add;
|
||||
@@ -54,7 +54,7 @@ public class SetSaturationFunction<CTX extends Context> extends AbstractConditio
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
Object value = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("saturation"), "warning.config.function.set_saturation.missing_saturation");
|
||||
boolean add = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("add", false), "add");
|
||||
return new SetSaturationFunction<>(NumberProviders.fromObject(value), add, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
return new SetSaturationFunction<>(getPredicates(arguments), add, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), NumberProviders.fromObject(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,15 +26,7 @@ public class SpawnFurnitureFunction<CTX extends Context> extends AbstractConditi
|
||||
private final boolean playSound;
|
||||
|
||||
public SpawnFurnitureFunction(
|
||||
Key furnitureId,
|
||||
NumberProvider x,
|
||||
NumberProvider y,
|
||||
NumberProvider z,
|
||||
NumberProvider pitch,
|
||||
NumberProvider yaw,
|
||||
String variant,
|
||||
boolean playSound,
|
||||
List<Condition<CTX>> predicates
|
||||
List<Condition<CTX>> predicates, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider pitch, NumberProvider yaw, String variant, boolean playSound, Key furnitureId
|
||||
) {
|
||||
super(predicates);
|
||||
this.furnitureId = furnitureId;
|
||||
@@ -86,7 +78,7 @@ public class SpawnFurnitureFunction<CTX extends Context> extends AbstractConditi
|
||||
NumberProvider yaw = NumberProviders.fromObject(arguments.getOrDefault("yaw", "<arg:position.yaw>"));
|
||||
String variant = ResourceConfigUtils.getAsStringOrNull(ResourceConfigUtils.get(arguments, "variant", "anchor-type"));
|
||||
boolean playSound = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("play-sound", true), "play-sound");
|
||||
return new SpawnFurnitureFunction<>(furnitureId, x, y, z, pitch, yaw, variant, playSound, getPredicates(arguments));
|
||||
return new SpawnFurnitureFunction<>(getPredicates(arguments), x, y, z, pitch, yaw, variant, playSound, furnitureId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Optional;
|
||||
public class SwingHandFunction<CTX extends Context> extends AbstractConditionalFunction<CTX> {
|
||||
private final Optional<InteractionHand> hand;
|
||||
|
||||
public SwingHandFunction(Optional<InteractionHand> hand, List<Condition<CTX>> predicates) {
|
||||
public SwingHandFunction(List<Condition<CTX>> predicates, Optional<InteractionHand> hand) {
|
||||
super(predicates);
|
||||
this.hand = hand;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class SwingHandFunction<CTX extends Context> extends AbstractConditionalF
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
Optional<InteractionHand> optionalHand = Optional.ofNullable(arguments.get("hand")).map(it -> InteractionHand.valueOf(it.toString().toUpperCase(Locale.ENGLISH)));
|
||||
return new SwingHandFunction<>(optionalHand, getPredicates(arguments));
|
||||
return new SwingHandFunction<>(getPredicates(arguments), optionalHand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TransformBlockFunction<CTX extends Context> extends AbstractConditi
|
||||
private final NumberProvider z;
|
||||
private final NumberProvider updateFlags;
|
||||
|
||||
public TransformBlockFunction(LazyReference<BlockStateWrapper> lazyBlockState, CompoundTag properties, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider updateFlags, List<Condition<CTX>> predicates) {
|
||||
public TransformBlockFunction(List<Condition<CTX>> predicates, CompoundTag properties, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider updateFlags, LazyReference<BlockStateWrapper> lazyBlockState) {
|
||||
super(predicates);
|
||||
this.properties = properties;
|
||||
this.x = x;
|
||||
@@ -84,13 +84,8 @@ public class TransformBlockFunction<CTX extends Context> extends AbstractConditi
|
||||
}
|
||||
}
|
||||
return new TransformBlockFunction<>(
|
||||
LazyReference.lazyReference(() -> CraftEngine.instance().blockManager().createBlockState(block)),
|
||||
properties,
|
||||
NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>")),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>")),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>")),
|
||||
Optional.ofNullable(arguments.get("update-flags")).map(NumberProviders::fromObject).orElse(NumberProviders.direct(UpdateOption.UPDATE_ALL.flags())),
|
||||
getPredicates(arguments));
|
||||
getPredicates(arguments), properties, NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>")), NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>")), NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>")), Optional.ofNullable(arguments.get("update-flags")).map(NumberProviders::fromObject).orElse(NumberProviders.direct(UpdateOption.UPDATE_ALL.flags())), LazyReference.lazyReference(() -> CraftEngine.instance().blockManager().createBlockState(block))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class UpdateBlockPropertyFunction<CTX extends Context> extends AbstractCo
|
||||
private final NumberProvider z;
|
||||
private final NumberProvider updateFlags;
|
||||
|
||||
public UpdateBlockPropertyFunction(CompoundTag properties, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider updateFlags, List<Condition<CTX>> predicates) {
|
||||
public UpdateBlockPropertyFunction(List<Condition<CTX>> predicates, NumberProvider x, NumberProvider y, NumberProvider z, NumberProvider updateFlags, CompoundTag properties) {
|
||||
super(predicates);
|
||||
this.properties = properties;
|
||||
this.x = x;
|
||||
@@ -67,12 +67,8 @@ public class UpdateBlockPropertyFunction<CTX extends Context> extends AbstractCo
|
||||
for (Map.Entry<String, Object> entry : state.entrySet()) {
|
||||
properties.putString(entry.getKey(), String.valueOf(entry.getValue()));
|
||||
}
|
||||
return new UpdateBlockPropertyFunction<>(properties,
|
||||
NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>")),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>")),
|
||||
NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>")),
|
||||
Optional.ofNullable(arguments.get("update-flags")).map(NumberProviders::fromObject).orElse(NumberProviders.direct(UpdateOption.UPDATE_ALL.flags())),
|
||||
getPredicates(arguments));
|
||||
return new UpdateBlockPropertyFunction<>(getPredicates(arguments), NumberProviders.fromObject(arguments.getOrDefault("x", "<arg:position.x>")), NumberProviders.fromObject(arguments.getOrDefault("y", "<arg:position.y>")), NumberProviders.fromObject(arguments.getOrDefault("z", "<arg:position.z>")), Optional.ofNullable(arguments.get("update-flags")).map(NumberProviders::fromObject).orElse(NumberProviders.direct(UpdateOption.UPDATE_ALL.flags())), properties
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.craftengine.core.plugin.entityculling;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.world.ChunkPos;
|
||||
import net.momirealms.craftengine.core.world.MutableVec3d;
|
||||
|
||||
Reference in New Issue
Block a user