初次提交,完成伐木的工作

This commit is contained in:
xypp
2025-04-25 18:21:36 +08:00
commit 7a2e7e4954
29 changed files with 1699 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package studio.fantasyit.maid_useful_task;
import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.slf4j.Logger;
import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(MaidUsefulTask.MODID)
public class MaidUsefulTask {
// Define mod id in a common place for everything to reference
public static final String MODID = "maid_useful_task";
@SuppressWarnings("removal")
public MaidUsefulTask() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
MemoryModuleRegistry.register(modEventBus);
}
}

View File

@@ -0,0 +1,34 @@
package studio.fantasyit.maid_useful_task;
import com.github.tartaricacid.touhoulittlemaid.api.ILittleMaid;
import com.github.tartaricacid.touhoulittlemaid.api.LittleMaidExtension;
import com.github.tartaricacid.touhoulittlemaid.api.entity.ai.IExtraMaidBrain;
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.ExtraMaidBrainManager;
import com.github.tartaricacid.touhoulittlemaid.entity.task.TaskManager;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
import studio.fantasyit.maid_useful_task.task.MaidTreeTask;
import java.util.List;
@LittleMaidExtension
public class UsefulTaskExtension implements ILittleMaid {
@Override
public void addMaidTask(TaskManager manager) {
ILittleMaid.super.addMaidTask(manager);
manager.add(new MaidTreeTask());
}
@Override
public void addExtraMaidBrain(ExtraMaidBrainManager manager) {
manager.addExtraMaidBrain(new IExtraMaidBrain() {
@Override
public List<MemoryModuleType<?>> getExtraMemoryTypes() {
return List.of(
MemoryModuleRegistry.DESTROY_TARGET.get(),
MemoryModuleRegistry.PLACE_TARGET.get()
);
}
});
}
}

View File

@@ -0,0 +1,118 @@
package studio.fantasyit.maid_useful_task.behavior;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.ai.behavior.Behavior;
import net.minecraft.world.entity.ai.memory.MemoryStatus;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import studio.fantasyit.maid_useful_task.memory.BlockTargetMemory;
import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
import studio.fantasyit.maid_useful_task.task.IMaidBlockDestroyTask;
import studio.fantasyit.maid_useful_task.util.Conditions;
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
import studio.fantasyit.maid_useful_task.util.WrappedMaidFakePlayer;
import java.util.List;
import java.util.Map;
public class DestoryBlockBehavior extends Behavior<EntityMaid> {
private IMaidBlockDestroyTask task;
public DestoryBlockBehavior() {
super(Map.of(
InitEntities.TARGET_POS.get(), MemoryStatus.VALUE_PRESENT,
MemoryModuleRegistry.DESTROY_TARGET.get(), MemoryStatus.VALUE_PRESENT
));
}
@Override
protected boolean checkExtraStartConditions(@NotNull ServerLevel worldIn, @NotNull EntityMaid maid) {
return Conditions.hasReachedValidTargetOrReset(maid,1);
}
List<BlockPos> blockPosSet = null;
int index = 0;
float destroyProgress = 0f;
BlockPos targetPos;
BlockState targetBlockState;
WrappedMaidFakePlayer fakePlayer;
@Override
protected void start(ServerLevel p_22540_, @NotNull EntityMaid maid, long p_22542_) {
super.start(p_22540_, maid, p_22542_);
BlockTargetMemory blockTargetMemory = MemoryUtil.getDestroyTargetMemory(maid);
if (blockTargetMemory != null) {
blockPosSet = blockTargetMemory.getBlockPosSet();
blockPosSet.sort((o1, o2) -> (int) (o1.distSqr(maid.blockPosition()) - o2.distSqr(maid.blockPosition())));
}
index = 0;
task = (IMaidBlockDestroyTask) maid.getTask();
fakePlayer = WrappedMaidFakePlayer.get(maid);
targetPos = null;
targetBlockState = null;
maid.getNavigation().stop();
}
@Override
protected boolean canStillUse(ServerLevel p_22545_, EntityMaid p_22546_, long p_22547_) {
return (blockPosSet != null && index < blockPosSet.size()) || targetPos != null;
}
@Override
protected void tick(@NotNull ServerLevel level, @NotNull EntityMaid maid, long p_22553_) {
if (!Conditions.stopAndCheckStopped(maid)) return;
if (targetPos != null) {
tickDestroyProgress(maid);
return;
}
while (index < blockPosSet.size()) {
targetPos = blockPosSet.get(index++);
targetBlockState = level.getBlockState(targetPos);
if (!targetBlockState.isAir()) {
task.tryTakeOutToolForTarget(maid, targetPos);
if (task.canDestroyBlock(maid, targetPos)) {
destroyProgress = 0f;
return;
}
}
targetPos = null;
targetBlockState = null;
}
}
private void tickDestroyProgress(EntityMaid maid) {
float speed = fakePlayer.getMainHandItem().getDestroySpeed(targetBlockState) / fakePlayer.getDigSpeed(targetBlockState, targetPos) / 30;
MemoryUtil.setLookAt(maid, targetPos);
if (task.availableToGetDrop(maid, fakePlayer, targetPos, targetBlockState)) {
maid.swing(InteractionHand.MAIN_HAND);
destroyProgress += speed;
if (destroyProgress >= 1f) {
maid.getMainHandItem().hurt(1, maid.getRandom(), fakePlayer);
task.tryDestroyBlock(maid,targetPos);
destroyProgress = 0f;
targetPos = null;
targetBlockState = null;
}
} else {
targetPos = null;
targetBlockState = null;
}
}
@Override
protected void stop(ServerLevel p_22548_, EntityMaid p_22549_, long p_22550_) {
super.stop(p_22548_, p_22549_, p_22550_);
MemoryUtil.clearDestroyTargetMemory(p_22549_);
MemoryUtil.clearTarget(p_22549_);
}
@Override
protected boolean timedOut(long p_22537_) {
return false;
}
}

View File

@@ -0,0 +1,67 @@
package studio.fantasyit.maid_useful_task.behavior;
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task.MaidMoveToBlockTask;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.MaidPathFindingBFS;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import studio.fantasyit.maid_useful_task.task.IMaidBlockDestroyTask;
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
import java.util.List;
public class DestoryBlockMoveBehavior extends MaidMoveToBlockTask {
private IMaidBlockDestroyTask task;
private MaidPathFindingBFS pathfindingBFS;
private BlockPos targetPos;
List<BlockPos> blockPosSet;
public DestoryBlockMoveBehavior() {
super(0.5f, 4);
}
@Override
protected void start(@NotNull ServerLevel p_22540_, @NotNull EntityMaid maid, long p_22542_) {
super.start(p_22540_, maid, p_22542_);
task = (IMaidBlockDestroyTask) maid.getTask();
task.tryTakeOutTool(maid);
searchForDestination(p_22540_, maid);
@Nullable BlockPos target = MemoryUtil.getTargetPos(maid);
if (target != null && blockPosSet != null) {
blockPosSet.addAll(task.getTryDestroyBlockListBesidesStart(targetPos, target, maid));
MemoryUtil.setDestroyTargetMemory(maid, blockPosSet);
}
}
@Override
protected boolean shouldMoveTo(@NotNull ServerLevel serverLevel, @NotNull EntityMaid entityMaid, @NotNull BlockPos blockPos) {
if (!task.shouldDestroyBlock(entityMaid, blockPos)) return false;
targetPos = blockPos.immutable();
if (blockPos instanceof BlockPos.MutableBlockPos mb) {
for (int dx = 0; dx < task.reachDistance(); dx = dx <= 0 ? 1 - dx : -dx) {
for (int dy = 0; dy < task.reachDistance(); dy = dy <= 0 ? 1 - dy : -dy) {
for (int dz = 0; dz < task.reachDistance(); dz = dz <= 0 ? 1 - dz : -dz) {
BlockPos pos = mb.offset(dx, dy, dz);
if (entityMaid.isWithinRestriction(pos) && pathfindingBFS.canPathReach(pos)) {
blockPosSet = task.toDestroyFromStanding(entityMaid, targetPos, pos);
if (blockPosSet != null) {
mb.set(pos);
return true;
}
}
}
}
}
}
targetPos = null;
return false;
}
@Override
protected @NotNull MaidPathFindingBFS getOrCreateArrivalMap(@NotNull ServerLevel worldIn, @NotNull EntityMaid maid) {
this.pathfindingBFS = super.getOrCreateArrivalMap(worldIn, maid);
return this.pathfindingBFS;
}
}

View File

@@ -0,0 +1,63 @@
package studio.fantasyit.maid_useful_task.behavior;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.ai.behavior.Behavior;
import net.minecraft.world.entity.ai.memory.MemoryStatus;
import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
import studio.fantasyit.maid_useful_task.task.IMaidBlockPlaceTask;
import studio.fantasyit.maid_useful_task.util.Conditions;
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
import java.util.Map;
public class PlaceBlockBehavior extends Behavior<EntityMaid> {
private BlockPos target;
public PlaceBlockBehavior() {
super(Map.of(MemoryModuleRegistry.PLACE_TARGET.get(), MemoryStatus.VALUE_PRESENT,
InitEntities.TARGET_POS.get(), MemoryStatus.VALUE_PRESENT
));
}
@Override
protected boolean checkExtraStartConditions(ServerLevel p_22538_, EntityMaid p_22539_) {
return Conditions.hasReachedValidTargetOrReset(p_22539_);
}
@Override
protected boolean canStillUse(ServerLevel p_22545_, EntityMaid p_22546_, long p_22547_) {
return target != null;
}
@Override
protected void start(ServerLevel p_22540_, EntityMaid maid, long p_22542_) {
super.start(p_22540_, maid, p_22542_);
target = MemoryUtil.getPlaceTarget(maid);
if (target == null)
return;
MemoryUtil.setLookAt(maid, target);
maid.getNavigation().stop();
}
@Override
protected void tick(ServerLevel p_22551_, EntityMaid maid, long p_22553_) {
if (!Conditions.stopAndCheckStopped(maid)) return;
IMaidBlockPlaceTask task = (IMaidBlockPlaceTask) maid.getTask();
if (task.shouldPlacePos(maid, maid.getMainHandItem(), target)) {
maid.swing(InteractionHand.MAIN_HAND);
task.tryPlaceBlock(maid, maid.getMainHandItem(), target);
}
target = null;
}
@Override
protected void stop(ServerLevel p_22548_, EntityMaid p_22549_, long p_22550_) {
super.stop(p_22548_, p_22549_, p_22550_);
MemoryUtil.clearPlaceTarget(p_22549_);
MemoryUtil.clearTarget(p_22549_);
}
}

View File

@@ -0,0 +1,80 @@
package studio.fantasyit.maid_useful_task.behavior;
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task.MaidMoveToBlockTask;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.MaidPathFindingBFS;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import studio.fantasyit.maid_useful_task.task.IMaidBlockPlaceTask;
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
import java.util.ArrayList;
import java.util.List;
public class PlaceBlockMoveBehavior extends MaidMoveToBlockTask {
private IMaidBlockPlaceTask task;
private MaidPathFindingBFS pathfindingBFS;
private BlockPos targetPos;
private ItemStack targetItem;
public PlaceBlockMoveBehavior() {
super(0.5f, 4);
}
@Override
protected void start(ServerLevel p_22540_, EntityMaid maid, long p_22542_) {
super.start(p_22540_, maid, p_22542_);
task = (IMaidBlockPlaceTask) maid.getTask();
CombinedInvWrapper inv = maid.getAvailableInv(true);
List<ItemStack> markedVis = new ArrayList<>();
for (int i = 0; i < inv.getSlots(); i++) {
if (!task.shouldPlaceItemStack(maid, inv.getStackInSlot(i))) continue;
int finalI = i;
if (markedVis.stream().anyMatch(t -> ItemStack.isSameItem(t, inv.getStackInSlot(finalI)))) continue;
targetItem = inv.getStackInSlot(i);
searchForDestination(p_22540_, maid);
@Nullable BlockPos target = MemoryUtil.getTargetPos(maid);
if (target != null) {
MemoryUtil.setPlaceTarget(maid, targetPos);
inv.setStackInSlot(finalI, maid.getMainHandItem());
maid.setItemInHand(InteractionHand.MAIN_HAND, targetItem);
return;
}
markedVis.add(targetItem);
}
}
@Override
protected boolean shouldMoveTo(ServerLevel serverLevel, EntityMaid entityMaid, BlockPos blockPos) {
if (!task.shouldPlacePos(entityMaid, targetItem, blockPos)) return false;
targetPos = blockPos.immutable();
if (blockPos instanceof BlockPos.MutableBlockPos mb) {
final int[] dv = {0, 1, -1};
for (int dx : dv) {
for (int dy : dv) {
for (int dz : dv) {
BlockPos pos = mb.offset(dx, dy, dz);
if (entityMaid.isWithinRestriction(pos) && pathfindingBFS.canPathReach(pos)) {
mb.set(pos);
return true;
}
}
}
}
}
targetPos = null;
return false;
}
@Override
protected @NotNull MaidPathFindingBFS getOrCreateArrivalMap(@NotNull ServerLevel worldIn, @NotNull EntityMaid maid) {
this.pathfindingBFS = super.getOrCreateArrivalMap(worldIn, maid);
return this.pathfindingBFS;
}
}

View File

@@ -0,0 +1,34 @@
package studio.fantasyit.maid_useful_task.memory;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import java.util.List;
import java.util.Set;
public class BlockTargetMemory {
public static final Codec<BlockTargetMemory> CODEC = RecordCodecBuilder.create(instance ->
instance.group(
BlockPos
.CODEC
.listOf()
.fieldOf("blockPosSet")
.forGetter(BlockTargetMemory::getBlockPosSet)
).apply(instance, BlockTargetMemory::new)
);
List<BlockPos> blockPosSet;
public BlockTargetMemory(List<BlockPos> blockPosSet) {
this.blockPosSet = blockPosSet;
}
public List<BlockPos> getBlockPosSet() {
return blockPosSet;
}
public void setBlockPosSet(List<BlockPos> blockPosSet) {
this.blockPosSet = blockPosSet;
}
}

View File

@@ -0,0 +1,19 @@
package studio.fantasyit.maid_useful_task.mixin;
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task.MaidRunOne;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import net.minecraft.server.level.ServerLevel;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
@Mixin(MaidRunOne.class)
abstract public class MaidRunOneMixin {
@Inject(method = "tryStart(Lnet/minecraft/server/level/ServerLevel;Lcom/github/tartaricacid/touhoulittlemaid/entity/passive/EntityMaid;J)Z", at = @At("HEAD"), cancellable = true,remap = false)
public void runOne(ServerLevel pLevel, EntityMaid maid, long pGameTime, CallbackInfoReturnable<Boolean> cir) {
if (MemoryUtil.getDestroyTargetMemory(maid) != null || MemoryUtil.getPlaceTarget(maid) != null)
cir.setReturnValue(false);
}
}

View File

@@ -0,0 +1,25 @@
package studio.fantasyit.maid_useful_task.registry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
import studio.fantasyit.maid_useful_task.memory.BlockTargetMemory;
import java.util.Optional;
public class MemoryModuleRegistry {
public static final DeferredRegister<MemoryModuleType<?>> REGISTER
= DeferredRegister.create(Registries.MEMORY_MODULE_TYPE, MaidUsefulTask.MODID);
public static final RegistryObject<MemoryModuleType<BlockTargetMemory>> DESTROY_TARGET
= REGISTER.register("block_targets", () -> new MemoryModuleType<>(Optional.of(BlockTargetMemory.CODEC)));
public static final RegistryObject<MemoryModuleType<BlockPos>> PLACE_TARGET
= REGISTER.register("place_target", () -> new MemoryModuleType<>(Optional.empty()));
public static void register(IEventBus eventBus) {
REGISTER.register(eventBus);
}
}

View File

@@ -0,0 +1,174 @@
package studio.fantasyit.maid_useful_task.task;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.ai.behavior.BehaviorControl;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import studio.fantasyit.maid_useful_task.behavior.DestoryBlockBehavior;
import studio.fantasyit.maid_useful_task.behavior.DestoryBlockMoveBehavior;
import studio.fantasyit.maid_useful_task.util.WrappedMaidFakePlayer;
import java.util.*;
public interface IMaidBlockDestroyTask {
default @Nullable List<BlockPos> toDestroyFromStanding(EntityMaid maid, BlockPos targetPos, BlockPos standPos) {
List<BlockPos> list = new ArrayList<>();
Vec3 eyePos = standPos.getCenter().add(0, maid.getEyeHeight() - 0.5, 0);
Boolean available = BlockGetter.traverseBlocks(eyePos, targetPos.getCenter(), maid.level(), (level, pos) -> {
BlockState state = level.getBlockState(pos);
if (state.isAir()) {
return null;
}
if (mayDestroy(maid, pos)) {
list.add(pos.immutable());
return null;
} else return false;
}, (a) -> true);
if (available) {
return list;
}
return null;
}
/**
* 获取尝试破坏的方块列表。不包含起点列表
*
* @param startPos 开始位置
* @param maid 执行操作的女仆
* @return 相连的所有方块
*/
default List<BlockPos> getTryDestroyBlockListBesidesStart(BlockPos startPos, BlockPos standPos, EntityMaid maid) {
Set<BlockPos> marked = new HashSet<>();
Queue<BlockPos> queue = new LinkedList<>();
List<BlockPos> result = new ArrayList<>();
final int[] dv = {0, 1, -1};
final int maxDXZ = 2;
queue.add(startPos);
marked.add(startPos);
// C(9), O(N)
while (!queue.isEmpty()) {
BlockPos pos = queue.poll();
for (int dx : dv) {
for (int dy : dv) {
for (int dz : dv) {
if (dx == 0 && dy == 0 && dz == 0) continue;
BlockPos target = pos.offset(dx, dy, dz);
if (Math.abs(target.getX() - standPos.getX()) > maxDXZ || Math.abs(target.getZ() - standPos.getZ()) > maxDXZ)
continue;
if (target.distSqr(standPos) > reachDistance() * reachDistance()) continue;
if (marked.contains(target)) continue;
if (!shouldDestroyBlock(maid, target)) continue;
List<BlockPos> targetList = toDestroyFromStanding(maid, target, standPos);
if (targetList == null) continue;
marked.add(target);
result.addAll(targetList);
queue.add(target);
}
}
}
}
return result;
}
/**
* 女仆是否想要破坏这个方块,需要判断工具符合等,将用于寻路判断
*
* @param maid 女仆
* @param pos 目标位置
* @return 是否想要破坏
*/
boolean shouldDestroyBlock(EntityMaid maid, BlockPos pos);
/**
* 女仆是否可以破坏这个方块,光线投射确定女仆的挖掘地点
*
* @param maid
* @param pos
* @return
*/
boolean mayDestroy(EntityMaid maid, BlockPos pos);
/**
* 女仆是否可以破坏这个方块,用于进行破坏前检查
*
* @param maid 女仆
* @param pos 位置
* @return 是否可以破坏
*/
default boolean canDestroyBlock(EntityMaid maid, BlockPos pos) {
if (maid.distanceToSqr(pos.getCenter()) > Math.pow(reachDistance(), 2)) {
return false;
}
return true;
}
/**
* 尝试破坏方块
*
* @param maid 女仆
* @param blockPos 位置
* @return
*/
default boolean tryDestroyBlock(EntityMaid maid, BlockPos blockPos) {
ServerLevel level = (ServerLevel) maid.level();
BlockState blockState = level.getBlockState(blockPos);
if (blockState.isAir()) {
return false;
} else {
FluidState fluidState = level.getFluidState(blockPos);
if (!(blockState.getBlock() instanceof BaseFireBlock)) {
level.levelEvent(2001, blockPos, Block.getId(blockState));
}
BlockEntity blockEntity = blockState.hasBlockEntity() ? level.getBlockEntity(blockPos) : null;
//改用MainHandItem来roll loot
maid.dropResourcesToMaidInv(blockState, level, blockPos, blockEntity, maid, maid.getMainHandItem());
boolean setResult = level.setBlock(blockPos, fluidState.createLegacyBlock(), 3);
if (setResult) {
level.gameEvent(GameEvent.BLOCK_DESTROY, blockPos, GameEvent.Context.of(maid, blockState));
}
return setResult;
}
}
/**
* 尝试拿取工具。如果没有工具什么都不需要操作后续交给canDestroy和shouldDestroy判断
*
* @param maid
*/
default void tryTakeOutTool(EntityMaid maid) {
}
default void tryTakeOutToolForTarget(EntityMaid maid, BlockPos pos) {
tryTakeOutTool(maid);
}
default boolean availableToGetDrop(EntityMaid maid, WrappedMaidFakePlayer fakePlayer, BlockPos pos, BlockState targetBlockState) {
return fakePlayer.hasCorrectToolForDrops(targetBlockState);
}
default int reachDistance() {
return 6;
}
default @NotNull List<Pair<Integer, BehaviorControl<? super EntityMaid>>> createBrainTasks(@NotNull EntityMaid entityMaid) {
return List.of(
Pair.of(5, new DestoryBlockBehavior()),
Pair.of(4, new DestoryBlockMoveBehavior())
);
}
}

View File

@@ -0,0 +1,51 @@
package studio.fantasyit.maid_useful_task.task;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.ai.behavior.BehaviorControl;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;
import studio.fantasyit.maid_useful_task.behavior.DestoryBlockBehavior;
import studio.fantasyit.maid_useful_task.behavior.DestoryBlockMoveBehavior;
import studio.fantasyit.maid_useful_task.util.WrappedMaidFakePlayer;
import java.util.List;
public interface IMaidBlockPlaceTask {
boolean shouldPlaceItemStack(EntityMaid maid, ItemStack itemStack);
boolean shouldPlacePos(EntityMaid maid, ItemStack itemStack, BlockPos pos);
default boolean tryPlaceBlock(EntityMaid maid, ItemStack itemStack, BlockPos pos){
Player fakePlayer = WrappedMaidFakePlayer.get(maid);
BlockHitResult result = null;
ClipContext rayTraceContext = new ClipContext(maid.getPosition(0).add(0, maid.getEyeHeight(), 0),
pos.getCenter(),
ClipContext.Block.OUTLINE,
ClipContext.Fluid.NONE,
fakePlayer);
result = maid.level().clip(rayTraceContext);
UseOnContext useContext = new UseOnContext(fakePlayer, InteractionHand.MAIN_HAND, result);
InteractionResult actionresult = fakePlayer.getItemInHand(InteractionHand.MAIN_HAND).onItemUseFirst(useContext);
if (actionresult == InteractionResult.PASS) {
InteractionResult interactionResult = fakePlayer.getItemInHand(InteractionHand.MAIN_HAND).useOn(useContext);
if (interactionResult.consumesAction()) {
return true;
}
}
return false;
}
default @NotNull List<Pair<Integer, BehaviorControl<? super EntityMaid>>> createBrainTasks(@NotNull EntityMaid entityMaid) {
return List.of(
Pair.of(5, new DestoryBlockBehavior()),
Pair.of(4, new DestoryBlockMoveBehavior())
);
}
}

View File

@@ -0,0 +1,165 @@
package studio.fantasyit.maid_useful_task.task;
import com.github.tartaricacid.touhoulittlemaid.api.task.IMaidTask;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.ai.behavior.BehaviorControl;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
import studio.fantasyit.maid_useful_task.behavior.DestoryBlockBehavior;
import studio.fantasyit.maid_useful_task.behavior.DestoryBlockMoveBehavior;
import studio.fantasyit.maid_useful_task.behavior.PlaceBlockBehavior;
import studio.fantasyit.maid_useful_task.behavior.PlaceBlockMoveBehavior;
import studio.fantasyit.maid_useful_task.util.WrappedMaidFakePlayer;
import java.util.ArrayList;
import java.util.List;
public class MaidTreeTask implements IMaidTask, IMaidBlockPlaceTask, IMaidBlockDestroyTask {
@Override
public ResourceLocation getUid() {
return new ResourceLocation(MaidUsefulTask.MODID, "maid_tree");
}
@Override
public ItemStack getIcon() {
return Items.OAK_SAPLING.getDefaultInstance();
}
@Override
public boolean enableLookAndRandomWalk(EntityMaid maid) {
return true;
}
@Nullable
@Override
public SoundEvent getAmbientSound(EntityMaid entityMaid) {
return null;
}
@Override
public boolean shouldDestroyBlock(EntityMaid maid, BlockPos pos) {
BlockState blockState = maid.level().getBlockState(pos);
return blockState.is(BlockTags.LOGS) && isValidNatureTree(maid, pos);
}
@Override
public boolean mayDestroy(EntityMaid maid, BlockPos pos) {
BlockState blockState = maid.level().getBlockState(pos);
if (blockState.is(BlockTags.LEAVES)) {
return true;
}
return blockState.is(BlockTags.LOGS);
}
@Override
public boolean shouldPlaceItemStack(EntityMaid maid, ItemStack itemStack) {
return itemStack.is(ItemTags.SAPLINGS);
}
@Override
public boolean shouldPlacePos(EntityMaid maid, ItemStack itemStack, BlockPos pos) {
ServerLevel level = (ServerLevel) maid.level();
if(!level.getBlockState(pos.below()).is(BlockTags.DIRT)) return false;
if (!level.getBlockState(pos).canBeReplaced()) return false;
final int[] dv = {0, 1, -1, 2, -2};
for (int dx : dv) {
for (int dy = 0; dy < 4; dy++) {
for (int dz : dv) {
if (dx == 0 && dy == 0 && dz == 0) continue;
if (!level.getBlockState(pos.offset(dx, dy, dz)).canBeReplaced())
return false;
}
}
}
return true;
}
@Override
public void tryTakeOutTool(EntityMaid maid) {
CombinedInvWrapper inv = maid.getAvailableInv(true);
for (int i = 0; i < inv.getSlots(); i++) {
if (inv.getStackInSlot(i).is(ItemTags.AXES)) {
@NotNull ItemStack tmp = inv.getStackInSlot(i);
inv.setStackInSlot(i, maid.getMainHandItem());
maid.setItemInHand(InteractionHand.MAIN_HAND, tmp);
return;
}
}
}
public void swapShearsOrNone(EntityMaid maid) {
CombinedInvWrapper inv = maid.getAvailableInv(true);
int target = -1;
for (int i = 0; i < inv.getSlots(); i++) {
if (inv.getStackInSlot(i).is(Items.SHEARS)) {
target = i;
break;
}
if (!inv.getStackInSlot(i).isDamageableItem()) {
target = i;
}
}
if (target != -1) {
@NotNull ItemStack tmp = inv.getStackInSlot(target);
inv.setStackInSlot(target, maid.getMainHandItem());
maid.setItemInHand(InteractionHand.MAIN_HAND, tmp);
}
}
@Override
public void tryTakeOutToolForTarget(EntityMaid maid, BlockPos pos) {
if (maid.level().getBlockState(pos).is(BlockTags.LEAVES)) {
swapShearsOrNone(maid);
} else {
tryTakeOutTool(maid);
}
}
@Override
public boolean availableToGetDrop(EntityMaid maid, WrappedMaidFakePlayer fakePlayer, BlockPos pos, BlockState targetBlockState) {
if (targetBlockState.is(BlockTags.LEAVES))
return true;
return IMaidBlockDestroyTask.super.availableToGetDrop(maid, fakePlayer, pos, targetBlockState);
}
protected boolean isValidNatureTree(EntityMaid maid, BlockPos startPos) {
final int[] dv = {0, 1, -1};
for (int dx : dv) {
for (int dz : dv) {
for (int dy = 0; dy < 6; dy++) {
BlockState blockState = maid.level().getBlockState(startPos.offset(dx, dy, dz));
if (blockState.is(BlockTags.LEAVES) && !blockState.getValue(LeavesBlock.PERSISTENT)) {
return true;
}
}
}
}
return false;
}
@Override
public List<Pair<Integer, BehaviorControl<? super EntityMaid>>> createBrainTasks(EntityMaid entityMaid) {
ArrayList<Pair<Integer, BehaviorControl<? super EntityMaid>>> list = new ArrayList<>();
list.add(Pair.of(5, new DestoryBlockBehavior()));
list.add(Pair.of(4, new DestoryBlockMoveBehavior()));
list.add(Pair.of(3, new PlaceBlockBehavior()));
list.add(Pair.of(2, new PlaceBlockMoveBehavior()));
return list;
}
}

View File

@@ -0,0 +1,38 @@
package studio.fantasyit.maid_useful_task.util;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.ai.memory.WalkTarget;
import net.minecraft.world.phys.Vec3;
import java.util.Optional;
public class Conditions {
public static boolean hasReachedValidTargetOrReset(EntityMaid maid){
return hasReachedValidTargetOrReset(maid, 2);
}
public static boolean hasReachedValidTargetOrReset(EntityMaid maid, float closeEnough) {
Brain<EntityMaid> brain = maid.getBrain();
return brain.getMemory(InitEntities.TARGET_POS.get()).map(targetPos -> {
Vec3 targetV3d = targetPos.currentPosition();
if (maid.distanceToSqr(targetV3d) > Math.pow(closeEnough, 2)) {
Optional<WalkTarget> walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET);
if (walkTarget.isEmpty() || !walkTarget.get().getTarget().currentPosition().equals(targetV3d)) {
brain.eraseMemory(InitEntities.TARGET_POS.get());
}
return false;
}
return true;
}).orElse(false);
}
public static boolean stopAndCheckStopped(EntityMaid maid) {
if (!maid.getNavigation().isDone()) {
maid.getNavigation().stop();
return false;
}
return maid.getDeltaMovement().length() < 0.2;
}
}

View File

@@ -0,0 +1,28 @@
package studio.fantasyit.maid_useful_task.util;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.items.wrapper.RangedWrapper;
import java.util.UUID;
import java.util.function.Predicate;
public class MaidUtils {
public static void swapToHand(EntityMaid maid, Predicate<ItemStack> isSuitable) {
RangedWrapper availableBackpackInv = maid.getAvailableBackpackInv();
for (int i = 0; i < availableBackpackInv.getSlots(); i++) {
ItemStack itemStack = availableBackpackInv.getStackInSlot(i);
if (isSuitable.test(itemStack)) {
ItemStack tmp = availableBackpackInv.getStackInSlot(i);
availableBackpackInv.setStackInSlot(i, maid.getMainHandItem());
maid.setItemInHand(InteractionHand.MAIN_HAND, tmp);
return;
}
}
}
}

View File

@@ -0,0 +1,53 @@
package studio.fantasyit.maid_useful_task.util;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.ai.behavior.BlockPosTracker;
import net.minecraft.world.entity.ai.behavior.PositionTracker;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import org.jetbrains.annotations.Nullable;
import studio.fantasyit.maid_useful_task.memory.BlockTargetMemory;
import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
import java.util.List;
import java.util.Optional;
public class MemoryUtil {
public static @Nullable BlockTargetMemory getDestroyTargetMemory(EntityMaid maid) {
Optional<BlockTargetMemory> memory = maid.getBrain().getMemory(MemoryModuleRegistry.DESTROY_TARGET.get());
return memory.orElse(null);
}
public static void setDestroyTargetMemory(EntityMaid maid, List<BlockPos> blockPosSet) {
maid.getBrain().setMemory(MemoryModuleRegistry.DESTROY_TARGET.get(), new BlockTargetMemory(blockPosSet));
}
public static void clearDestroyTargetMemory(EntityMaid maid) {
maid.getBrain().eraseMemory(MemoryModuleRegistry.DESTROY_TARGET.get());
}
public static void clearTarget(EntityMaid maid) {
maid.getBrain().eraseMemory(InitEntities.TARGET_POS.get());
maid.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET);
}
public static @Nullable BlockPos getTargetPos(EntityMaid maid) {
Optional<PositionTracker> memory = maid.getBrain().getMemory(InitEntities.TARGET_POS.get());
return memory.map(PositionTracker::currentBlockPosition).orElse(null);
}
public static @Nullable BlockPos getPlaceTarget(EntityMaid maid) {
Optional<BlockPos> memory = maid.getBrain().getMemory(MemoryModuleRegistry.PLACE_TARGET.get());
return memory.orElse(null);
}
public static void setPlaceTarget(EntityMaid maid, BlockPos blockPos) {
maid.getBrain().setMemory(MemoryModuleRegistry.PLACE_TARGET.get(), blockPos);
}
public static void clearPlaceTarget(EntityMaid maid) {
maid.getBrain().eraseMemory(MemoryModuleRegistry.PLACE_TARGET.get());
}
public static void setLookAt(EntityMaid maid, BlockPos pos) {
maid.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos));
}
}

View File

@@ -0,0 +1,185 @@
package studio.fantasyit.maid_useful_task.util;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.RelativeMovement;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.FakePlayer;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class WrappedMaidFakePlayer extends FakePlayer {
private static ConcurrentHashMap<UUID, WrappedMaidFakePlayer> cache = new ConcurrentHashMap<>();
private final EntityMaid maid;
public static WrappedMaidFakePlayer get(EntityMaid maid) {
if (cache.containsKey(maid.getUUID())) {
return cache.get(maid.getUUID());
} else {
WrappedMaidFakePlayer fakePlayer = new WrappedMaidFakePlayer(maid);
cache.put(maid.getUUID(), fakePlayer);
return fakePlayer;
}
}
private WrappedMaidFakePlayer(EntityMaid maid) {
super((ServerLevel) maid.level(), new GameProfile(UUID.randomUUID(), maid.getName().getString()));
this.maid = maid;
}
@Override
public boolean removeEffect(MobEffect p_21196_) {
return maid.removeEffect(p_21196_);
}
@Nullable
@Override
public MobEffectInstance removeEffectNoUpdate(@Nullable MobEffect p_21164_) {
return maid.removeEffectNoUpdate(p_21164_);
}
@Override
public boolean removeAllEffects() {
return maid.removeAllEffects();
}
@Override
public boolean addEffect(MobEffectInstance p_147208_, @Nullable Entity p_147209_) {
return maid.addEffect(p_147208_, p_147209_);
}
@Override
public boolean canBeAffected(MobEffectInstance p_21197_) {
return maid.canBeAffected(p_21197_);
}
@Override
public void forceAddEffect(MobEffectInstance p_147216_, @Nullable Entity p_147217_) {
maid.forceAddEffect(p_147216_, p_147217_);
}
@Nullable
@Override
public MobEffectInstance getEffect(MobEffect p_21125_) {
return maid.getEffect(p_21125_);
}
@Override
public Collection<MobEffectInstance> getActiveEffects() {
return maid.getActiveEffects();
}
@Override
public Map<MobEffect, MobEffectInstance> getActiveEffectsMap() {
return maid.getActiveEffectsMap();
}
@Override
public boolean hasEffect(MobEffect p_21024_) {
return maid.hasEffect(p_21024_);
}
@Override
public ItemStack getMainHandItem() {
if (maid == null) return ItemStack.EMPTY;
return maid.getMainHandItem();
}
@Override
public void setItemInHand(InteractionHand p_21009_, ItemStack p_21010_) {
maid.setItemInHand(p_21009_, p_21010_);
}
@Override
public void setItemSlot(EquipmentSlot p_36161_, ItemStack p_36162_) {
maid.setItemSlot(p_36161_, p_36162_);
}
@Override
public ItemStack getItemBySlot(EquipmentSlot p_36257_) {
if (maid == null) return ItemStack.EMPTY;
return maid.getItemBySlot(p_36257_);
}
@Override
public boolean isEyeInFluid(TagKey<Fluid> p_204030_) {
return maid.isEyeInFluid(p_204030_);
}
@Override
public boolean onGround() {
return maid.onGround();
}
@Override
public Level level() {
if (maid == null) return super.level();
return maid.level();
}
@Override
public ServerLevel serverLevel() {
if (maid == null) return super.serverLevel();
return (ServerLevel) maid.level();
}
@Override
public BlockPos blockPosition() {
if (maid == null) return BlockPos.ZERO;
return maid.blockPosition();
}
@Override
public Vec3 position() {
if (maid == null) return Vec3.ZERO;
return maid.position();
}
@Override
public void teleportTo(double p_8969_, double p_8970_, double p_8971_) {
if (maid == null) return;
maid.teleportTo(p_8969_, p_8970_, p_8971_);
}
@Override
public boolean teleportTo(ServerLevel p_265564_, double p_265424_, double p_265680_, double p_265312_, Set<RelativeMovement> p_265192_, float p_265059_, float p_265266_) {
if (maid == null) return false;
return maid.teleportTo(p_265564_, p_265424_, p_265680_, p_265312_, p_265192_, p_265059_, p_265266_);
}
@Override
public void teleportRelative(double p_251611_, double p_248861_, double p_252266_) {
maid.teleportRelative(p_251611_, p_248861_, p_252266_);
}
@Override
public void moveTo(double p_9171_, double p_9172_, double p_9173_) {
if (maid == null) return;
maid.moveTo(p_9171_, p_9172_, p_9173_);
}
@Override
public ChunkPos chunkPosition() {
return maid.chunkPosition();
}
}

View File

@@ -0,0 +1 @@
public net.minecraft.world.level.BlockGetter m_151361_(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Ljava/lang/Object;Ljava/util/function/BiFunction;Ljava/util/function/Function;)Ljava/lang/Object;

View File

@@ -0,0 +1,66 @@
# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="${mod_license}"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN),
# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers.
#clientSideOnly=true #optional - defaults to false if absent
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="${mod_id}" #mandatory
# The version number of the mod
version="${mod_version}" #mandatory
# A display name for the mod
displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="maid_useful_task.png" #optional
# A text field displayed in the mod UI
#credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors="${mod_authors}" #optional
# Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional)
# The description text for the mod (multi line!) (#mandatory)
description='''${mod_description}'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies."${mod_id}"]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH"# Here's another dependency
[[dependencies."${mod_id}"]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"

View File

@@ -0,0 +1,3 @@
{
"task.maid_useful_task.maid_tree": "Logging"
}

View File

@@ -0,0 +1,3 @@
{
"task.maid_useful_task.maid_tree": "伐木"
}

View File

@@ -0,0 +1,15 @@
{
"required": true,
"minVersion": "0.8",
"package": "studio.fantasyit.maid_useful_task.mixin",
"compatibilityLevel": "JAVA_8",
"refmap": "maid_useful_task.refmap.json",
"mixins": [
"MaidRunOneMixin"
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}

View File

@@ -0,0 +1,7 @@
{
"pack": {
"description": "maid_useful_task resources",
"pack_format": 26,
"forge:server_data_pack_format": 12
}
}