规整注释
This commit is contained in:
parent
a82876824d
commit
2a865f74d5
|
|
@ -30,8 +30,6 @@ import java.util.Comparator;
|
||||||
* - 负责标签到频道(频率)的分配与复用;
|
* - 负责标签到频道(频率)的分配与复用;
|
||||||
* - 创建/销毁虚拟节点,所有收发器连接到同一虚拟节点;
|
* - 创建/销毁虚拟节点,所有收发器连接到同一虚拟节点;
|
||||||
* - 记录在线端点集合,端点卸载后需调用 unregister。
|
* - 记录在线端点集合,端点卸载后需调用 unregister。
|
||||||
*
|
|
||||||
* UI 未实现,仅提供服务端逻辑。
|
|
||||||
*/
|
*/
|
||||||
public class LabelNetworkRegistry extends SavedData {
|
public class LabelNetworkRegistry extends SavedData {
|
||||||
public static final String SAVE_ID = ExtendedAEPlus.MODID + "_label_networks";
|
public static final String SAVE_ID = ExtendedAEPlus.MODID + "_label_networks";
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,6 @@ import org.lwjgl.glfw.GLFW;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签无线收发器屏幕(UI 占位,等待按钮布局).
|
|
||||||
* 纹理:textures/gui/lable_wireless_transceiver_gui.png,尺寸 256x156.
|
|
||||||
* 标签无线收发器屏幕(UI 占位,等待按钮布局)。
|
|
||||||
* 纹理:textures/gui/lable_wireless_transceiver_gui.png,尺寸 256x156。
|
|
||||||
*/
|
|
||||||
public class LabeledWirelessTransceiverScreen extends AbstractContainerScreen<LabeledWirelessTransceiverMenu> {
|
public class LabeledWirelessTransceiverScreen extends AbstractContainerScreen<LabeledWirelessTransceiverMenu> {
|
||||||
private static final ResourceLocation TEX = ExtendedAEPlus.id("textures/gui/lable_wireless_transceiver_gui.png");
|
private static final ResourceLocation TEX = ExtendedAEPlus.id("textures/gui/lable_wireless_transceiver_gui.png");
|
||||||
private static final int BTN_U = 2;
|
private static final int BTN_U = 2;
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,6 @@ import java.util.EnumSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签无线收发器方块实体:
|
|
||||||
* - 无主从区分,通过标签映射频道并连接至虚拟节点;
|
|
||||||
* - 无 UI(占位),仅提供服务端逻辑与状态更新;
|
|
||||||
* - 保留频率字段用于状态显示。
|
|
||||||
*/
|
|
||||||
public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity implements IWirelessEndpoint, IInWorldGridNodeHost, MenuProvider {
|
public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity implements IWirelessEndpoint, IInWorldGridNodeHost, MenuProvider {
|
||||||
|
|
||||||
private IManagedGridNode managedNode;
|
private IManagedGridNode managedNode;
|
||||||
|
|
@ -64,13 +58,11 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
this.managedNode.setVisualRepresentation(ModItems.LABELED_WIRELESS_TRANSCEIVER.get().getDefaultInstance());
|
this.managedNode.setVisualRepresentation(ModItems.LABELED_WIRELESS_TRANSCEIVER.get().getDefaultInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== IInWorldGridNodeHost ===================== */
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable IGridNode getGridNode(Direction dir) {
|
public @Nullable IGridNode getGridNode(Direction dir) {
|
||||||
return getGridNode();
|
return getGridNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== IWirelessEndpoint ===================== */
|
|
||||||
@Override
|
@Override
|
||||||
public ServerLevel getServerLevel() {
|
public ServerLevel getServerLevel() {
|
||||||
Level lvl = super.getLevel();
|
Level lvl = super.getLevel();
|
||||||
|
|
@ -92,7 +84,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
return super.isRemoved();
|
return super.isRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== 菜单接口 ===================== */
|
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return Component.translatable("block.extendedae_plus.labeled_wireless_transceiver");
|
return Component.translatable("block.extendedae_plus.labeled_wireless_transceiver");
|
||||||
|
|
@ -103,8 +94,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
return new LabeledWirelessTransceiverMenu(id, inv, this.worldPosition);
|
return new LabeledWirelessTransceiverMenu(id, inv, this.worldPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== 公共方法 ===================== */
|
|
||||||
|
|
||||||
public void setPlacerId(@Nullable UUID placerId, @Nullable String placerName) {
|
public void setPlacerId(@Nullable UUID placerId, @Nullable String placerName) {
|
||||||
this.placerId = placerId;
|
this.placerId = placerId;
|
||||||
this.placerName = placerName;
|
this.placerName = placerName;
|
||||||
|
|
@ -130,9 +119,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
return labelForDisplay;
|
return labelForDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用/切换标签。空或非法标签将清空并断开。
|
|
||||||
*/
|
|
||||||
public void applyLabel(@Nullable String rawLabel) {
|
public void applyLabel(@Nullable String rawLabel) {
|
||||||
ServerLevel sl = getServerLevel();
|
ServerLevel sl = getServerLevel();
|
||||||
if (sl == null) return;
|
if (sl == null) return;
|
||||||
|
|
@ -153,9 +139,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 清空标签并断开连接。
|
|
||||||
*/
|
|
||||||
public void clearLabel() {
|
public void clearLabel() {
|
||||||
ServerLevel sl = getServerLevel();
|
ServerLevel sl = getServerLevel();
|
||||||
if (sl != null) {
|
if (sl != null) {
|
||||||
|
|
@ -168,10 +151,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 在加载或跨区块迁移后重新获取网络并重连。
|
|
||||||
* @param ensureRegister 为 true 时,如果保存的标签不存在网络则尝试重新注册。
|
|
||||||
*/
|
|
||||||
public void refreshLabel(boolean ensureRegister) {
|
public void refreshLabel(boolean ensureRegister) {
|
||||||
ServerLevel sl = getServerLevel();
|
ServerLevel sl = getServerLevel();
|
||||||
if (sl == null) return;
|
if (sl == null) return;
|
||||||
|
|
@ -215,16 +194,12 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== Tick ===================== */
|
|
||||||
public static void serverTick(Level level, BlockPos pos, BlockState state, LabeledWirelessTransceiverBlockEntity be) {
|
public static void serverTick(Level level, BlockPos pos, BlockState state, LabeledWirelessTransceiverBlockEntity be) {
|
||||||
if (!(level instanceof ServerLevel)) return;
|
if (!(level instanceof ServerLevel)) return;
|
||||||
be.labelLink.updateStatus();
|
be.labelLink.updateStatus();
|
||||||
be.updateState();
|
be.updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据连接状态更新方块状态。
|
|
||||||
*/
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
if (this.level == null || this.level.isClientSide) return;
|
if (this.level == null || this.level.isClientSide) return;
|
||||||
if (this.beingRemoved || this.isRemoved()) return;
|
if (this.beingRemoved || this.isRemoved()) return;
|
||||||
|
|
@ -249,7 +224,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== AECableType 展示 ===================== */
|
|
||||||
@Override
|
@Override
|
||||||
public AECableType getCableConnectionType(Direction dir) {
|
public AECableType getCableConnectionType(Direction dir) {
|
||||||
if (this.level == null) return AECableType.GLASS;
|
if (this.level == null) return AECableType.GLASS;
|
||||||
|
|
@ -263,7 +237,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
return AECableType.GLASS;
|
return AECableType.GLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== 生命周期 ===================== */
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
|
|
@ -277,7 +250,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== NBT ===================== */
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAdditional(CompoundTag tag) {
|
public void saveAdditional(CompoundTag tag) {
|
||||||
super.saveAdditional(tag);
|
super.saveAdditional(tag);
|
||||||
|
|
@ -316,7 +288,6 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== AE2 节点监听 ===================== */
|
|
||||||
enum NodeListener implements IGridNodeListener<LabeledWirelessTransceiverBlockEntity> {
|
enum NodeListener implements IGridNodeListener<LabeledWirelessTransceiverBlockEntity> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user