Skip to content

Commit

Permalink
update zh_cn and fix servux protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jun 28, 2024
1 parent c360724 commit 44d0f95
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/irtimaled/bbor/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.irtimaled.bbor.common.messages.servux.ServuxStructurePackets;
import com.irtimaled.bbor.common.models.DimensionId;
import com.irtimaled.bbor.mixin.access.IKeyBinding;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;

import java.util.Map;
Expand Down Expand Up @@ -56,7 +55,7 @@ public void init() {
EventBus.subscribe(UpdateWorldSpawnReceived.class, this::onUpdateWorldSpawnReceived);
EventBus.subscribe(SaveLoaded.class, e -> clear());
EventBus.subscribe(GameJoin.class, e -> {
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
final ClientPlayNetworkHandler networkHandler = e.handler();
if (networkHandler == null) {
System.err.println("network handler is null");
return;
Expand All @@ -65,6 +64,7 @@ public void init() {
if (!ConfigManager.keepCacheBetweenSessions.get()) {
clear();
}
SlimeChunkProvider.setSeed(this.seed);
networkHandler.sendPacket(ServuxStructurePackets.subscribe().build());
});

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/irtimaled/bbor/client/events/GameJoin.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.irtimaled.bbor.client.events;

public class GameJoin {
import net.minecraft.client.network.ClientPlayNetworkHandler;

public record GameJoin(ClientPlayNetworkHandler handler) {
}
9 changes: 0 additions & 9 deletions src/main/java/com/irtimaled/bbor/client/gui/ListScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ public abstract class ListScreen extends Screen {
this.lastScreen = lastScreen;
}

ListScreen() {
this(null);
}

protected void onDoneClicked() {
ClientInterop.displayScreen(lastScreen);
}
Expand Down Expand Up @@ -69,11 +65,6 @@ protected void render(DrawContext ctx, int mouseX, int mouseY) {
ctx.drawTextWithShadow(this.textRenderer, version, left, top, -10658467);
}

@Override
public void tick() {
// this.searchField.tick(); TODO fix
}

@Override
public boolean keyPressed(int key, int scanCode, int modifiers) {
return super.keyPressed(key, scanCode, modifiers) || this.searchField.keyPressed(key, scanCode, modifiers);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/irtimaled/bbor/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CommonProxy {
private final Map<Integer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
private final Map<DimensionId, StructureProcessor> structureProcessors = new HashMap<>();
private final Map<DimensionId, BoundingBoxCache> dimensionCache = new ConcurrentHashMap<>();
private Long seed = null;
protected Long seed = null;
private Integer spawnX = null;
private Integer spawnZ = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.irtimaled.bbor.common.messages.servux;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.GeneratorOptionsHolder;
import net.minecraft.registry.CombinedDynamicRegistries;
import net.minecraft.registry.DynamicRegistryManager;
Expand All @@ -21,16 +22,16 @@
import java.util.concurrent.Executors;

public class RegistryUtil {
static final DynamicRegistryManager.Immutable REGISTRY_MANAGER = null; // TODO fix
static final DynamicRegistryManager.Immutable REGISTRY_MANAGER;

static {
/* TODO fix
final ExecutorService executorService = Executors.newSingleThreadExecutor();

try {
ResourcePackManager resourcePackManager = new ResourcePackManager(new VanillaDataPackProvider());
ResourcePackManager resourcePackManager = VanillaDataPackProvider.createClientManager();
SaveLoading.DataPacks dataPacks = new SaveLoading.DataPacks(resourcePackManager, DataConfiguration.SAFE_MODE, false, true);
SaveLoading.ServerConfig serverConfig = new SaveLoading.ServerConfig(dataPacks, CommandManager.RegistrationEnvironment.INTEGRATED, 2);
// DO NOT CONVERT THIS TO LAMBDA DUE TO FREEZES
CompletableFuture<GeneratorOptionsHolder> completableFuture = SaveLoading.load(
serverConfig,
context -> new SaveLoading.LoadContext<>(
Expand All @@ -54,7 +55,6 @@ public GeneratorOptionsHolder create(LifecycledResourceManager resourceManager,
} finally {
executorService.shutdown();
}
*/
}

record WorldCreationSettings(WorldGenSettings worldGenSettings, DataConfiguration dataConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import com.irtimaled.bbor.common.messages.SubscribeToServer;
import com.irtimaled.bbor.common.messages.protocols.PacketSplitter;
import com.irtimaled.bbor.common.messages.servux.ServuxStructurePackets;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.NetworkThreadUtils;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.CustomPayload;
Expand All @@ -36,9 +34,9 @@ private void onChunkUnload(UnloadChunkS2CPacket packet, CallbackInfo ci) {
// CommonInterop.loadWorldStructures(this.world);
// }

@Inject(method = "onGameJoin", at = @At("HEAD"))
@Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;<init>(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ClientPlayNetworkHandler;)V"))
private void onGameJoin(CallbackInfo ci) {
EventBus.publish(new GameJoin());
EventBus.publish(new GameJoin((ClientPlayNetworkHandler) (Object) this));
}

@Inject(method = "sendChatCommand", at = @At("HEAD"), cancellable = true)
Expand Down Expand Up @@ -72,11 +70,13 @@ private void onCustomPayload(CustomPayload customPayload, CallbackInfo ci) {
data = PacketSplitter.receive((ClientPlayPacketListener) this, payload);
if (data != null) {
PayloadReader reader = new PayloadReader(data);
// ServuxStructurePackets.handleEvent(reader); TODO fix
ServuxStructurePackets.handleEvent(reader);
}
} finally {
if (data != null)
if (data != null) {
data.release();
}
// ci.cancel();
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/assets/bbor/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
"bbor.key.toggleActive": "切换激活",
"bbor.tabs.structures": "结构",
"bbor.options.active": "激活",
"bbor.options.outerBoxOnly": "显示边框",
"bbor.options.outerBoxOnly": "仅显示外轮廓",
"bbor.options.fill": "填充面",
"bbor.options.showSettingsButton": "显示设置按钮",
"bbor.options.fastRender": "快速渲染: %s",
"bbor.options.fastRender.0": "",
"bbor.options.fastRender.1": "",
"bbor.options.fastRender.2": "",
"bbor.options.asyncBuilding": "使用异步渲染",
"bbor.options.maxY": "最大 Y: %s",
"bbor.options.asyncBuilding": "使用异步渲染构建器",
"bbor.options.maxY": "渲染高度: %s",
"bbor.options.maxY.activated": "激活高度",
"bbor.options.maxY.player": "玩家高度",
"bbor.options.maxY.seaLevel": "海平面高度",
"bbor.options.distance": "距离: %s",
"bbor.options.distance": "渲染距离: %s",
"bbor.options.distance.nearest": "最近",
"bbor.options.distance.nearer": "较近",
"bbor.options.distance.normal": "标准",
"bbor.options.distance.farther": "较远",
"bbor.options.distance.far": "",
"bbor.options.distance.veryFar": "非常远",
"bbor.options.distance.y": "距离(Y): %s",
"bbor.options.distance.xz": "距离 (X/Z): %s",
"bbor.options.distance.y": "渲染距离(Y): %s",
"bbor.options.distance.xz": "渲染距离 (X/Z): %s",
"bbor.options.safe_light": "安全亮度: %s",
"bbor.render.received_types": "结构边框获取方式",
"bbor.render.received_types.auto": "自动选择",
Expand Down

0 comments on commit 44d0f95

Please sign in to comment.