Skip to content

Commit

Permalink
add xaeroWorldName
Browse files Browse the repository at this point in the history
  • Loading branch information
plusls committed Jul 16, 2021
1 parent 84df8fe commit 486c088
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 7 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fabric-api >= 0.28
- [刷怪的最大Y值](#刷怪的最大Y值-spawnYMax)
- [刷怪的最小Y值](#刷怪的最小Y值-spawnYMin)
- [全局刷怪群系](#全局刷怪群系-spawnBiome)
- [Xaero小地图世界名](#Xaero小地图世界名-xaeroWorldName)
- [PCA调试模式](#PCA调试模式-pcaDebug)

## 规则列表
Expand Down Expand Up @@ -159,6 +160,15 @@ Carpet 默认实现的潜影盒可堆叠只能让潜影盒在地面上堆叠,
- 参考选项: `true`, `false`
- 分类: `PCA`, `feature`

### Xaero小地图世界名 (xaeroWorldName)

设置 Xaero 世界名来同步世界 ID,"#none" 表示不同步

- 类型: `String`
- 默认值: `#none`
- 参考选项: `#none`
- 分类: `PCA`, `PROTOCOL`

### PCA调试模式 (pcaDebug)

开启后会打印调试信息
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.17
yarn_mappings=1.17+build.13
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.14
loader_version=0.11.6
# check available versions on maven for the given minecraft version you are using
# https://masa.dy.fi/maven
carpet_core_version=1.4.40+v210608
carpet_core_version=1.4.44+v210714
# Mod Properties
mod_version=0.1.8
mod_version=0.1.9
maven_group=net.fabricmc
archives_base_name=plusls-carpet-addition
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.36.0+1.17
fabric_version=0.37.0+1.17
9 changes: 9 additions & 0 deletions src/main/java/com/plusls/carpet/PcaSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ public enum PCA_SPAWN_BIOME {
)
public static boolean quickLeafDecay = false;

public static final String xaeroWorldNameNone = "#none";
@Rule(
desc = "set xaero world name to sync word id to xaerominimap, \"#none\" is disable.",
category = {PCA, PROTOCOL},
strict = false,
options = {xaeroWorldNameNone}
)
public static String xaeroWorldName = xaeroWorldNameNone;

// debug
@Rule(
desc = "pcaDebug mode",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.plusls.carpet.mixin.rule.xaeroWorldName;

import com.plusls.carpet.PcaSettings;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
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.CallbackInfo;

import java.util.zip.CRC32;

@Mixin(PlayerManager.class)
public class MixinPlayerManager {
@Inject(method = "sendWorldInfo", at = @At(value = "RETURN"))
public void preOnSendWorldInfo(ServerPlayerEntity player, ServerWorld world, CallbackInfo ci) {
if (PcaSettings.xaeroWorldName.equals(PcaSettings.xaeroWorldNameNone)) {
return;
}
Identifier xaeroworldmap = new Identifier("xaeroworldmap", "main");
Identifier xaerominimap = new Identifier("xaerominimap", "main");

CRC32 crc = new CRC32();
crc.update(PcaSettings.xaeroWorldName.getBytes());
ByteBuf buf = Unpooled.buffer();
buf.writeByte(0);
buf.writeInt((int) crc.getValue());

ServerPlayNetworking.send(player, xaeroworldmap, new PacketByteBuf(buf.duplicate()));
ServerPlayNetworking.send(player, xaerominimap, new PacketByteBuf(buf.duplicate()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ShulkerBoxItemUtil {
public static boolean isEmptyShulkerBoxItem(ItemStack itemStack) {
if (itemStack.getItem() instanceof BlockItem &&
((BlockItem) itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock) {
NbtCompound nbt = itemStack.getTag();
NbtCompound nbt = itemStack.getNbt();
if (nbt != null && nbt.contains("BlockEntityTag", 10)) {
NbtCompound tag = nbt.getCompound("BlockEntityTag");
if (tag.contains("Items", 9)) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/pca/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"rule.spawnYMin.desc": "刷怪的最小 Y 值,会影响刷怪塔效率,114514 为默认",
"rule.spawnBiome.name": "全局刷怪群系",
"rule.spawnBiome.desc": "全局刷怪群系,会影响整个游戏,DEFAULT 为默认",
"rule.xaeroWorldName.name": "Xaero 小地图世界名",
"rule.xaeroWorldName.desc": "设置 Xaero 世界名来同步世界 ID,\"#none\" 表示不同步",
"rule.pcaDebug.name": "PCA调试模式",
"rule.pcaDebug.desc": "打印更多调试信息"
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/pca.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"rule.spawnBiome.MixinSpawnHelper",
"rule.spawnYRange.MixinSpawnHelper",
"rule.useDyeOnShulkerBox.MixinDyeItem",
"rule.useDyeOnShulkerBox.MixinPotionItem"
"rule.useDyeOnShulkerBox.MixinPotionItem",
"rule.xaeroWorldName.MixinPlayerManager"
],
"client": [
],
Expand Down

0 comments on commit 486c088

Please sign in to comment.