Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Mar 13, 2024
1 parent 78cb70d commit 5591a7d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

import io.github.edwinmindcraft.apoli.api.configuration.NoConfiguration;
import io.github.edwinmindcraft.apoli.api.power.factory.BiEntityAction;
import io.github.edwinmindcraft.apoli.common.ApoliCommon;
import io.github.edwinmindcraft.apoli.common.network.S2CPlayerMount;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.network.PacketDistributor;

import java.util.function.BiConsumer;

public class SimpleBiEntityAction extends BiEntityAction<NoConfiguration> {

public static void mount(Entity actor, Entity target) {
actor.startRiding(target, true);
if (!actor.level.isClientSide() && target instanceof ServerPlayer player) {
// The below is unnecessary as the client will execute the above before the server.
/*
if (!actor.level().isClientSide() && target instanceof ServerPlayer player) {
ApoliCommon.CHANNEL.send(PacketDistributor.PLAYER.with(() -> player), new S2CPlayerMount(actor.getId(), target.getId()));
}
*/
}

public static void setInLove(Entity actor, Entity target) {
Expand Down
32 changes: 32 additions & 0 deletions src/test/resources/data/apoliforge/powers/dismount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"type": "apoli:active_self",
"cooldown": 1,
"key": {
"key": "key.use",
"continuous": false
},
"entity_action": {
"type": "apoli:passenger_action",
"bientity_action": {
"type": "apoli:and",
"actions": [
{
"type": "apoli:actor_action",
"action": {
"type": "apoli:dismount"
}
},
{
"type": "apoli:target_action",
"action": {
"type": "apoli:swing_hand",
"hand": "MAIN_HAND"
}
}
]
}
},
"condition": {
"type": "apoli:sneaking"
}
}
19 changes: 19 additions & 0 deletions src/test/resources/data/apoliforge/powers/pick_up.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "apoli:action_on_entity_use",
"bientity_action": {
"type": "apoli:invert",
"action": {
"type": "apoli:mount"
}
},
"item_condition": {
"type": "apoli:empty"
},
"hands": [
"main_hand"
],
"condition": {
"type": "apoli:sneaking",
"inverted": true
}
}

0 comments on commit 5591a7d

Please sign in to comment.