-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
2,238 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...s/src/main/java/me/dueris/originspaper/factory/action/types/entity/AddVelocityAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package me.dueris.originspaper.factory.action.types.entity; | ||
|
||
import io.github.dueris.calio.SerializableDataTypes; | ||
import io.github.dueris.calio.parser.InstanceDefiner; | ||
import me.dueris.originspaper.OriginsPaper; | ||
import me.dueris.originspaper.factory.action.ActionFactory; | ||
import me.dueris.originspaper.factory.data.ApoliDataTypes; | ||
import me.dueris.originspaper.factory.data.types.Space; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.apache.logging.log4j.util.TriConsumer; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.joml.Vector3f; | ||
|
||
public class AddVelocityAction { | ||
|
||
public static @NotNull ActionFactory<Entity> getFactory() { | ||
return new ActionFactory<>(OriginsPaper.apoliIdentifier("add_velocity"), | ||
InstanceDefiner.instanceDefiner() | ||
.add("x", SerializableDataTypes.FLOAT, 0F) | ||
.add("y", SerializableDataTypes.FLOAT, 0F) | ||
.add("z", SerializableDataTypes.FLOAT, 0F) | ||
.add("space", ApoliDataTypes.SPACE, Space.WORLD) | ||
.add("client", SerializableDataTypes.BOOLEAN, true) | ||
.add("server", SerializableDataTypes.BOOLEAN, true) | ||
.add("set", SerializableDataTypes.BOOLEAN, false), | ||
(data, entity) -> { | ||
if (entity instanceof Player | ||
&& (entity.level().isClientSide ? | ||
!data.getBoolean("client") : !data.getBoolean("server"))) | ||
return; | ||
Space space = data.get("space"); | ||
Vector3f vec = new Vector3f(data.getFloat("x"), data.getFloat("y"), data.getFloat("z")); | ||
TriConsumer<Float, Float, Float> method = entity::push; | ||
if (data.getBoolean("set")) { | ||
method = entity::setDeltaMovement; | ||
} | ||
space.toGlobal(vec, entity); | ||
method.accept(vec.x, vec.y, vec.z); | ||
entity.hurtMarked = true; | ||
} | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
origins/src/main/java/me/dueris/originspaper/factory/action/types/entity/AddXpAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package me.dueris.originspaper.factory.action.types.entity; | ||
|
||
import io.github.dueris.calio.SerializableDataTypes; | ||
import io.github.dueris.calio.parser.InstanceDefiner; | ||
import me.dueris.originspaper.OriginsPaper; | ||
import me.dueris.originspaper.factory.action.ActionFactory; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AddXpAction { | ||
|
||
public static @NotNull ActionFactory<Entity> getFactory() { | ||
return new ActionFactory<>(OriginsPaper.apoliIdentifier("add_xp"), | ||
InstanceDefiner.instanceDefiner() | ||
.add("points", SerializableDataTypes.INT, 0) | ||
.add("levels", SerializableDataTypes.INT, 0), | ||
(data, entity) -> { | ||
if (entity instanceof Player) { | ||
int points = data.getInt("points"); | ||
int levels = data.getInt("levels"); | ||
if (points > 0) { | ||
((Player) entity).giveExperiencePoints(points); | ||
} | ||
((Player) entity).giveExperienceLevels(levels); | ||
} | ||
} | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...s/src/main/java/me/dueris/originspaper/factory/action/types/entity/ApplyEffectAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.dueris.originspaper.factory.action.types.entity; | ||
|
||
import io.github.dueris.calio.SerializableDataTypes; | ||
import io.github.dueris.calio.parser.InstanceDefiner; | ||
import me.dueris.originspaper.OriginsPaper; | ||
import me.dueris.originspaper.factory.action.ActionFactory; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class ApplyEffectAction { | ||
|
||
public static @NotNull ActionFactory<Entity> getFactory() { | ||
return new ActionFactory<>(OriginsPaper.apoliIdentifier("apply_effect"), | ||
InstanceDefiner.instanceDefiner() | ||
.add("effect", SerializableDataTypes.STATUS_EFFECT_INSTANCE, null) | ||
.add("effects", SerializableDataTypes.list(SerializableDataTypes.STATUS_EFFECT_INSTANCE), null), | ||
(data, entity) -> { | ||
if (entity instanceof LivingEntity le && !entity.level().isClientSide) { | ||
if (data.isPresent("effect")) { | ||
MobEffectInstance effect = data.get("effect"); | ||
le.addEffect(new MobEffectInstance(effect)); | ||
} | ||
if (data.isPresent("effects")) { | ||
((List<MobEffectInstance>) data.get("effects")).forEach(e -> le.addEffect(new MobEffectInstance(e))); | ||
} | ||
} | ||
} | ||
); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
.../src/main/java/me/dueris/originspaper/factory/action/types/entity/AreaOfEffectAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package me.dueris.originspaper.factory.action.types.entity; | ||
|
||
import io.github.dueris.calio.SerializableDataTypes; | ||
import io.github.dueris.calio.parser.InstanceDefiner; | ||
import io.github.dueris.calio.parser.reader.DeserializedFactoryJson; | ||
import me.dueris.originspaper.OriginsPaper; | ||
import me.dueris.originspaper.factory.action.ActionFactory; | ||
import me.dueris.originspaper.factory.data.ApoliDataTypes; | ||
import me.dueris.originspaper.factory.data.types.Shape; | ||
import net.minecraft.util.Tuple; | ||
import net.minecraft.world.entity.Entity; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Predicate; | ||
|
||
public class AreaOfEffectAction { | ||
|
||
public static void action(@NotNull DeserializedFactoryJson data, @NotNull Entity entity) { | ||
|
||
Consumer<Tuple<Entity, Entity>> biEntityAction = data.get("bientity_action"); | ||
Predicate<Tuple<Entity, Entity>> biEntityCondition = data.get("bientity_condition"); | ||
Shape shape = data.get("shape"); | ||
|
||
boolean includeActor = data.get("include_actor"); | ||
double radius = data.get("radius"); | ||
|
||
for (Entity target : Shape.getEntities(shape, entity.level(), entity.getPosition(1.0f), radius)) { | ||
|
||
if (target == entity && !includeActor) { | ||
continue; | ||
} | ||
|
||
Tuple<Entity, Entity> actorAndTarget = new Tuple<>(entity, target); | ||
if (biEntityCondition == null || biEntityCondition.test(actorAndTarget)) { | ||
biEntityAction.accept(actorAndTarget); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
public static @NotNull ActionFactory<Entity> getFactory() { | ||
return new ActionFactory<>( | ||
OriginsPaper.apoliIdentifier("area_of_effect"), | ||
InstanceDefiner.instanceDefiner() | ||
.add("radius", SerializableDataTypes.DOUBLE, 16D) | ||
.add("shape", SerializableDataTypes.enumValue(Shape.class), Shape.CUBE) | ||
.add("bientity_action", ApoliDataTypes.BIENTITY_ACTION) | ||
.add("bientity_condition", ApoliDataTypes.BIENTITY_CONDITION, null) | ||
.add("include_target", SerializableDataTypes.BOOLEAN, false) | ||
.add("include_actor", SerializableDataTypes.BOOLEAN, false), | ||
AreaOfEffectAction::action | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...src/main/java/me/dueris/originspaper/factory/action/types/entity/BlockActionAtAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.dueris.originspaper.factory.action.types.entity; | ||
|
||
import io.github.dueris.calio.parser.InstanceDefiner; | ||
import me.dueris.originspaper.OriginsPaper; | ||
import me.dueris.originspaper.factory.action.ActionFactory; | ||
import me.dueris.originspaper.factory.data.ApoliDataTypes; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Level; | ||
import org.apache.commons.lang3.tuple.Triple; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class BlockActionAtAction { | ||
|
||
public static @NotNull ActionFactory<Entity> getFactory() { | ||
return new ActionFactory<>(OriginsPaper.apoliIdentifier("block_action_at"), | ||
InstanceDefiner.instanceDefiner() | ||
.add("block_action", ApoliDataTypes.BLOCK_ACTION), | ||
(data, entity) -> ((ActionFactory<Triple<Level, BlockPos, Direction>>) data.get("block_action")).accept( | ||
Triple.of(entity.level(), entity.blockPosition(), Direction.UP))); | ||
} | ||
} |
Oops, something went wrong.