材质&调整标签大小写敏感

This commit is contained in:
GaLicn 2025-12-12 09:57:31 +08:00
parent 84cfc1ccb2
commit 56b82e0e8e
10 changed files with 42 additions and 25 deletions

View File

@ -55,11 +55,11 @@ public class LabelNetworkRegistry extends SavedData {
}
/**
* 规范化标签trim + toLowerCase
* 规范化标签trim保持大小写敏感
*/
public static String normalizeLabel(String raw) {
if (raw == null) return null;
String t = raw.trim().toLowerCase(Locale.ROOT);
String t = raw.trim();
if (t.isEmpty()) return null;
if (t.length() > 64) {
t = t.substring(0, 64);

View File

@ -266,13 +266,13 @@ public class LabeledWirelessTransceiverScreen extends AbstractContainerScreen<La
private void applyFilter() {
String prevSelected = lastSelectedLabel;
String q = searchBox.getValue() == null ? "" : searchBox.getValue().trim().toLowerCase();
String q = searchBox.getValue() == null ? "" : searchBox.getValue().trim();
filtered.clear();
if (q.isEmpty()) {
filtered.addAll(entries);
} else {
for (LabelEntry e : entries) {
if (e.label().toLowerCase().contains(q)) {
if (e.label().contains(q)) {
filtered.add(e);
}
}

View File

@ -16,7 +16,7 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.Nullable;
@ -26,11 +26,11 @@ import org.jetbrains.annotations.Nullable;
* 取消所有徒手/道具调节只允许右键打开后续 UI当前仅占位返回 SUCCESS
*/
public class LabeledWirelessTransceiverBlock extends Block implements EntityBlock {
public static final IntegerProperty STATE = IntegerProperty.create("state", 0, 5);
public static final BooleanProperty STATE = BooleanProperty.create("state");
public LabeledWirelessTransceiverBlock(Properties props) {
super(props);
this.registerDefaultState(this.stateDefinition.any().setValue(STATE, 5));
this.registerDefaultState(this.stateDefinition.any().setValue(STATE, false));
}
@Override

View File

@ -223,28 +223,18 @@ public class LabeledWirelessTransceiverBlockEntity extends AEBaseBlockEntity imp
}
IGridNode node = this.getGridNode();
int newState = 5; // 默认无连接
boolean online = false;
if (node != null && node.isActive()) {
int usedChannels = 0;
for (var connection : node.getConnections()) {
usedChannels = Math.max(connection.getUsedChannels(), usedChannels);
}
if (usedChannels >= 32) {
newState = 4;
} else if (usedChannels >= 24) {
newState = 3;
} else if (usedChannels >= 16) {
newState = 2;
} else if (usedChannels >= 8) {
newState = 1;
} else if (usedChannels >= 0) {
newState = 0;
try {
var grid = node.getGrid();
online = grid != null && grid.getEnergyService().isNetworkPowered();
} catch (Throwable ignored) {
online = false;
}
}
if (currentState.getValue(LabeledWirelessTransceiverBlock.STATE) != newState) {
this.level.setBlock(this.worldPosition, currentState.setValue(LabeledWirelessTransceiverBlock.STATE, newState), 3);
if (currentState.getValue(LabeledWirelessTransceiverBlock.STATE) != online) {
this.level.setBlock(this.worldPosition, currentState.setValue(LabeledWirelessTransceiverBlock.STATE, online), 3);
}
}

View File

@ -0,0 +1,10 @@
{
"variants": {
"state=false": {
"model": "extendedae_plus:block/wirelesstransceiver/lable_wireless_transceiver_off"
},
"state=true": {
"model": "extendedae_plus:block/wirelesstransceiver/lable_wireless_transceiver_on"
}
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "extendedae_plus:block/wireless_transceiver/lable_wireless_transceiver_off"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "extendedae_plus:block/wireless_transceiver/lable_wireless_transceiver_on"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "extendedae_plus:block/wirelesstransceiver/lable_wireless_transceiver_off"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B