add a few more player events, update dependencies, bump version
All checks were successful
Publish to snapshot maven / build (push) Successful in 1m9s
All checks were successful
Publish to snapshot maven / build (push) Successful in 1m9s
This commit is contained in:
parent
a1801635b3
commit
dea3b79fc9
|
@ -6,7 +6,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-SNAPSHOT"
|
||||
version = "0.0.1-alpha.1"
|
||||
|
||||
subprojects {
|
||||
if (!project.projectDir.resolve("src/main/resources/frog.mod.toml").exists()) {
|
||||
|
@ -62,6 +62,10 @@ allprojects {
|
|||
classpath(sourceSets.test.get().runtimeClasspath)
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[versions]
|
||||
|
||||
minecraft = "1.21"
|
||||
frogloader = "0.0.1-SNAPSHOT"
|
||||
phytotelma = "0.0.1-alpha.9"
|
||||
frogloader = "0.0.1-alpha.5"
|
||||
phytotelma = "0.0.1-alpha.10"
|
||||
lombok = "8.6"
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package dev.frogmc.froglib.player.api;
|
|||
import java.util.function.BiConsumer;
|
||||
|
||||
import dev.frogmc.froglib.events.api.Event;
|
||||
import dev.frogmc.froglib.player.api.types.EatingEvent;
|
||||
import dev.frogmc.froglib.player.api.types.InteractionEvent;
|
||||
import dev.frogmc.froglib.player.api.types.StopSleepEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
|
@ -14,4 +16,6 @@ public final class PlayerEvents {
|
|||
public static final Event<BiConsumer<Player, Entity>> ATTACK = Event.biConsumer();
|
||||
public static final Event<BiConsumer<Player, BlockPos>> START_SLEEP = Event.biConsumer();
|
||||
public static final Event<StopSleepEvent> STOP_SLEEP = Event.of(StopSleepEvent.class);
|
||||
public static final Event<InteractionEvent> INTERACTION = Event.of(InteractionEvent.class);
|
||||
public static final Event<EatingEvent> EAT = Event.of(EatingEvent.class);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package dev.frogmc.froglib.player.api.types;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public interface EatingEvent {
|
||||
void onEat(Player player, Level level, ItemStack itemStack, FoodProperties foodProperties);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package dev.frogmc.froglib.player.api.types;
|
||||
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public interface InteractionEvent {
|
||||
void onInteract(Player player, Entity entityToInteractOn, InteractionHand hand);
|
||||
}
|
|
@ -4,9 +4,14 @@ import com.mojang.datafixers.util.Either;
|
|||
import dev.frogmc.froglib.player.api.PlayerEvents;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -35,4 +40,14 @@ public class PlayerMixin {
|
|||
private void onStopSleep(boolean wakeImmediately, boolean updateLevelForSleepingPlayers, CallbackInfo ci) {
|
||||
PlayerEvents.STOP_SLEEP.invoker().onSleepStop((Player) (Object) this, wakeImmediately, updateLevelForSleepingPlayers);
|
||||
}
|
||||
|
||||
@Inject(method = "interactOn", at = @At("HEAD"))
|
||||
private void onInteract(Entity entityToInteractOn, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
PlayerEvents.INTERACTION.invoker().onInteract((Player) (Object) this, entityToInteractOn, hand);
|
||||
}
|
||||
|
||||
@Inject(method = "eat", at = @At("HEAD"))
|
||||
private void onEat(Level level, ItemStack itemStack, FoodProperties foodProperties, CallbackInfoReturnable<ItemStack> cir) {
|
||||
PlayerEvents.EAT.invoker().onEat((Player) (Object) this, level, itemStack, foodProperties);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue