- public interface PhantasDartle {
- /**
- * [url=home.php?mod=space&uid=109629]@See[/url] #usePhantasBow()
- */
- int MAX = 100;
- /**
- * @see #usePhantasBow()
- */
- int USE = 15;
- int getPhantasTicks();
- void setPhantasTicks(int ticks);
- default void syncPhantasTicks(int ticks) {
- setPhantasTicks(ticks);
- if (this instanceof ServerPlayerEntity serverPlayerEntity) {
- PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
- buf.writeInt(ticks);
- ServerPlayNetworking.send(serverPlayerEntity, CHANNEL, buf);
- }
- }
- /**
- * @see ph.mcmod.bows.mixin.MixinLivingEntity#writePhantasTicks(NbtCompound, CallbackInfo)
- */
- default void writePhantasTicks(NbtCompound root) {
- root.putInt("phantasTicks", getPhantasTicks());
- }
- /**
- * @see ph.mcmod.bows.mixin.MixinLivingEntity#readPhantasTicks(NbtCompound, CallbackInfo)
- */
- default void readPhantasTicks(NbtCompound root) {
- if (this instanceof ServerPlayerEntity)
- syncPhantasTicks(root.getInt("phantasTicks"));
- }
- /**
- * @see ph.mcmod.bows.mixin.MixinLivingEntity#tickPhantasTicks(CallbackInfo)
- */
- default void tickPhantasTicks() {
- if (getPhantasTicks() > 0)
- setPhantasTicks(getPhantasTicks() - 1);
- }
- /**
- * 射出时增加计时
- *
- * @see #getCallback(ItemStack, ItemStack, World, LivingEntity, double, PersistentProjectileEntity)
- */
- default void usePhantasBow() {
- syncPhantasTicks(Math.min(getPhantasTicks() + USE, MAX));
- MinecraftUtil.print(getPhantasTicks());
- }
- }
复制代码 |