调整模块结构

This commit is contained in:
tanyaofei 2023-10-17 11:42:47 +08:00
parent 4c834d5afa
commit 4bd71d67a0
83 changed files with 48 additions and 90 deletions

View File

@ -4,12 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.github.hello09x</groupId> <groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer</artifactId> <artifactId>fakeplayer-parent</artifactId>
<version>0.1.9</version> <version>0.1.9</version>
</parent> </parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-api</artifactId> <artifactId>fakeplayer-api</artifactId>
<properties> <properties>

View File

@ -24,4 +24,6 @@ public interface ActionTicker {
void init(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting); void init(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting);
boolean isDone();
} }

View File

@ -1,45 +1,54 @@
package io.github.hello09x.fakeplayer.api.action; package io.github.hello09x.fakeplayer.api.action;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
public enum ActionType { public enum ActionType {
/** /**
* 攻击实体 * 攻击实体
*/ */
ATTACK, ATTACK("攻击"),
/** /**
* 挖掘 * 挖掘
*/ */
MINE, MINE("挖掘"),
/** /**
* 右键 * 右键
*/ */
USE, USE("右键"),
/** /**
* 跳跃 * 跳跃
*/ */
JUMP, JUMP("跳跃"),
/** /**
* 看向附近实体 * 看向附近实体
*/ */
LOOK_AT_NEAREST_ENTITY, LOOK_AT_NEAREST_ENTITY("看向实体"),
/** /**
* 丢弃手上 1 个物品 * 丢弃手上 1 个物品
*/ */
DROP_ITEM, DROP_ITEM("丢弃单个物品"),
/** /**
* 丢弃手上整组物品 * 丢弃手上整组物品
*/ */
DROP_STACK, DROP_STACK("丢弃整组物品"),
/** /**
* 丢弃背包 * 丢弃背包
*/ */
DROP_INVENTORY DROP_INVENTORY("丢弃背包物品")
;
@Getter
final String displayName;
} }

View File

@ -4,12 +4,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.github.hello09x</groupId> <groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer</artifactId> <artifactId>fakeplayer-parent</artifactId>
<version>0.1.9</version> <version>0.1.9</version>
</parent> </parent>
<groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer-core</artifactId> <artifactId>fakeplayer-core</artifactId>
<properties> <properties>

View File

@ -62,7 +62,7 @@ public class ActionCommand extends AbstractCommand {
sender.sendMessage(textOfChildren( sender.sendMessage(textOfChildren(
text(target.getName()), text(target.getName()),
text(desc, GRAY), text(desc, GRAY),
text(action.name(), GRAY) text(action.getDisplayName(), GRAY)
)); ));
} }

View File

@ -56,8 +56,13 @@ public class ActionManager {
} }
// do tick // do tick
for (var ticker : entry.getValue().values()) { var tickerItr = entry.getValue().values().iterator();
while (tickerItr.hasNext()) {
var ticker = tickerItr.next();
ticker.tick(); ticker.tick();
if (ticker.isDone()) {
tickerItr.remove();
}
} }
} }
} }

View File

@ -4,13 +4,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>io.github.hello09x</groupId> <groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer</artifactId> <artifactId>fakeplayer-parent</artifactId>
<version>0.1.9</version> <version>0.1.9</version>
</parent> </parent>
<groupId>io.github.hello09x.fakeplayer</groupId> <artifactId>fakeplayer-v1_20_R1</artifactId>
<artifactId>v1_20_R1</artifactId>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
@ -55,6 +54,7 @@
</dependencies> </dependencies>
<build> <build>
<directory>../target</directory>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -33,8 +33,8 @@ public class ActionTicker implements io.github.hello09x.fakeplayer.api.action.Ac
return; return;
} }
var done = action.tick(); var valid = action.tick();
if (done) { if (valid) {
if (setting.times > 0) { if (setting.times > 0) {
setting.times--; setting.times--;
} }
@ -42,6 +42,10 @@ public class ActionTicker implements io.github.hello09x.fakeplayer.api.action.Ac
} }
} }
public boolean isDone() {
return setting.times <= 0;
}
@Override @Override
public void inactiveTick() { public void inactiveTick() {
action.inactiveTick(); action.inactiveTick();

View File

@ -1,6 +1,7 @@
package io.github.hello09x.fakeplayer.x.action; package io.github.hello09x.fakeplayer.x.action;
import io.github.hello09x.fakeplayer.api.action.Action; import io.github.hello09x.fakeplayer.api.action.Action;
import io.github.hello09x.fakeplayer.x.action.util.Tracer;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package io.github.hello09x.fakeplayer.x.action; package io.github.hello09x.fakeplayer.x.action.util;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ClipContext;

14
pom.xml
View File

@ -4,16 +4,16 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>io.github.hello09x</groupId> <groupId>io.github.hello09x.fakeplayer</groupId>
<artifactId>fakeplayer</artifactId> <artifactId>fakeplayer-parent</artifactId>
<version>0.1.9</version> <version>0.1.9</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>fakeplayer</name> <name>fakeplayer-parent</name>
<modules> <modules>
<module>api</module> <module>fakeplayer-api</module>
<module>core</module> <module>fakeplayer-core</module>
<module>v1_20_R1</module> <module>fakeplayer-v1_20_R1</module>
</modules> </modules>
<properties> <properties>
@ -80,6 +80,4 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
</project> </project>

View File

@ -1,59 +0,0 @@
package io.github.hello09x.fakeplayer.x.action;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ActionPack {
/**
* 假人玩家
*/
@NotNull
public final ServerPlayer player;
/**
* 左键数据
*/
@NotNull
public final AttackActionPack attack = new AttackActionPack();
/**
* 右键相关数据
*/
@NotNull
public final UseActionPack use = new UseActionPack();
public ActionPack(@NotNull ServerPlayer player) {
this.player = player;
}
public final static class AttackActionPack {
/**
* 当前左键的目标位置
*/
@Nullable
public BlockPos pos;
/**
* 破坏方块的进度
*/
public float progress;
/**
* 冷却, 单位: tick
*/
public int freeze;
}
public final static class UseActionPack {
/**
* 冷却, 单位: tick
*/
public int freeze;
}
}