From 42873e7685d593e2243085471621ae3c96a89ed4 Mon Sep 17 00:00:00 2001 From: tartaric_acid Date: Sun, 8 Oct 2023 15:08:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0=201.20.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 9 +++++++++ gradle.properties | 2 +- .../ai/brain/task/MaidMoveToBlockTask.java | 18 +++++++++++++----- .../network/message/SendNameTagMessage.java | 4 +++- .../tileentity/TileEntityMaidBeacon.java | 2 +- src/main/resources/META-INF/mods.toml | 4 +--- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index d7cd8593f..93a846b3d 100644 --- a/build.gradle +++ b/build.gradle @@ -118,6 +118,15 @@ dependencies { implementation fg.deobf("teamtwilight:twilightforest:${twilight_forest_version}:universal") } +jar { + manifest { + attributes([ + "Implementation-Title" : project.name, + "Implementation-Version": "${version}" + ]) + } +} + tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' } diff --git a/gradle.properties b/gradle.properties index 05b3d32bd..58f6d19e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx4G org.gradle.daemon=false -mod_version=1.1.1 +mod_version=1.1.2 forge_version=1.19.2-43.2.0 mc_version=1.19.2 jei_version=11.4.0.286 diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidMoveToBlockTask.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidMoveToBlockTask.java index ee376b05e..b2da0063e 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidMoveToBlockTask.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidMoveToBlockTask.java @@ -32,15 +32,16 @@ public MaidMoveToBlockTask(float movementSpeed, int searchRange, int verticalSea protected final void searchForDestination(ServerLevel worldIn, EntityMaid maid) { BlockPos blockpos = maid.blockPosition(); - BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (int y = this.verticalSearchStart; y <= this.verticalSearchRange; y = y > 0 ? -y : 1 - y) { for (int i = 0; i < this.searchRange; ++i) { for (int x = 0; x <= i; x = x > 0 ? -x : 1 - x) { for (int z = x < i && x > -i ? i : 0; z <= i; z = z > 0 ? -z : 1 - z) { - blockPos.setWithOffset(blockpos, x, y - 1, z); - if (maid.isWithinRestriction(blockPos) && shouldMoveTo(worldIn, maid, blockPos) && checkPathReach(maid, blockPos)) { - BehaviorUtils.setWalkAndLookTargetMemories(maid, blockPos, this.movementSpeed, 0); - maid.getBrain().setMemory(InitEntities.TARGET_POS.get(), new BlockPosTracker(blockPos)); + mutableBlockPos.setWithOffset(blockpos, x, y - 1, z); + if (maid.isWithinRestriction(mutableBlockPos) && shouldMoveTo(worldIn, maid, mutableBlockPos) && checkPathReach(maid, mutableBlockPos) + && checkOwnerPos(maid, mutableBlockPos)) { + BehaviorUtils.setWalkAndLookTargetMemories(maid, mutableBlockPos, this.movementSpeed, 0); + maid.getBrain().setMemory(InitEntities.TARGET_POS.get(), new BlockPosTracker(mutableBlockPos)); this.setNextCheckTickCount(5); return; } @@ -50,6 +51,13 @@ protected final void searchForDestination(ServerLevel worldIn, EntityMaid maid) } } + private boolean checkOwnerPos(EntityMaid maid, BlockPos mutableBlockPos) { + if (maid.isHomeModeEnable()) { + return true; + } + return maid.getOwner() != null && mutableBlockPos.closerToCenterThan(maid.getOwner().position(), 8); + } + /** * 判定条件 * diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/network/message/SendNameTagMessage.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/network/message/SendNameTagMessage.java index 7861691cb..c4ef98cd9 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/network/message/SendNameTagMessage.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/network/message/SendNameTagMessage.java @@ -55,7 +55,9 @@ private static void setMaidNameTag(SendNameTagMessage message, ServerPlayer play maid.setCustomName(Component.literal(name)); maid.setCustomNameVisible(message.alwaysShow); maid.setPersistenceRequired(); - player.getMainHandItem().shrink(1); + if (!player.isCreative()) { + player.getMainHandItem().shrink(1); + } } } } diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/tileentity/TileEntityMaidBeacon.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/tileentity/TileEntityMaidBeacon.java index 254e19095..b58c7a9bb 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/tileentity/TileEntityMaidBeacon.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/tileentity/TileEntityMaidBeacon.java @@ -37,7 +37,7 @@ public TileEntityMaidBeacon(BlockPos blockPos, BlockState blockState) { } public static void serverTick(Level level, BlockPos pos, BlockState state, TileEntityMaidBeacon beacon) { - if (beacon.level != null && !level.isClientSide && level.dayTime() % 80L == 0L) { + if (beacon.level != null && !level.isClientSide && level.getGameTime() % 80L == 0L) { if (beacon.potionIndex != -1 && beacon.storagePower >= beacon.getEffectCost()) { beacon.storagePower = beacon.storagePower - beacon.getEffectCost(); beacon.updateBeaconEffect(level, BeaconEffect.getEffectByIndex(beacon.potionIndex).getEffect()); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 53eadd1e3..8a6265825 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -11,6 +11,4 @@ credits = "Verclene, ZUN" # A text field displayed in the mod UI authors = "TartaricAcid, Snownee, Succinum, Pajinyi, ZeniCrow, Paulzzh, Yuriscat, Lappland162" # The description text for the mod (multi line!) (#mandatory) -description = ''' - A new version of the minecraft mod inspired by the LittleMaidReengaged mod. - ''' \ No newline at end of file +description = "A new version of the minecraft mod inspired by the LittleMaidReengaged mod." \ No newline at end of file