绑定器增加解绑功能
This commit is contained in:
parent
80779b9d3c
commit
69aa787775
|
|
@ -237,6 +237,31 @@ public class MirrorPatternProviderBlockEntity extends PatternProviderBlockEntity
|
|||
return Component.translatable("extendedae_plus.message.mirror_pattern_provider.missing_master");
|
||||
}
|
||||
|
||||
public boolean hasMasterBinding() {
|
||||
return this.masterDimension != null && this.masterPos != null;
|
||||
}
|
||||
|
||||
public boolean unbindFromMaster() {
|
||||
if (!(this.getLevel() instanceof ServerLevel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.hasMasterBinding()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var changed = this.clearMasterBinding(true);
|
||||
if (changed) {
|
||||
this.flushStateChanges();
|
||||
}
|
||||
this.scheduleImmediateSync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public Component createUnboundMessage() {
|
||||
return Component.translatable("extendedae_plus.message.mirror_pattern_provider.unbound");
|
||||
}
|
||||
|
||||
private int syncBoundMaster() {
|
||||
if (this.masterDimension == null || this.masterPos == null) {
|
||||
if (this.needsUnboundPatternCleanup) {
|
||||
|
|
@ -298,6 +323,7 @@ public class MirrorPatternProviderBlockEntity extends PatternProviderBlockEntity
|
|||
var changed = hadBinding;
|
||||
if (clearMirroredPatterns) {
|
||||
changed |= this.clearMirroredPatterns();
|
||||
changed |= this.resetMirroredSettingsToInitialState();
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
|
@ -367,6 +393,12 @@ public class MirrorPatternProviderBlockEntity extends PatternProviderBlockEntity
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean resetMirroredSettingsToInitialState() {
|
||||
var defaultState = this.getBlockState().getBlock().defaultBlockState();
|
||||
var defaultMirror = new MirrorPatternProviderBlockEntity(this.getBlockPos(), defaultState);
|
||||
return this.syncMirroredSettings(defaultMirror);
|
||||
}
|
||||
|
||||
private boolean hasDifferentMirroredSettings(PatternProviderBlockEntity master) {
|
||||
var mirrorLogic = this.getLogic();
|
||||
var masterLogic = master.getLogic();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,13 @@ public class MirrorPatternBindingToolItem extends Item {
|
|||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
if (mirror.hasMasterBinding()) {
|
||||
if (player != null && mirror.unbindFromMaster()) {
|
||||
player.displayClientMessage(mirror.createUnboundMessage(), true);
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
var selectedMaster = getSelectedMaster(stack);
|
||||
if (selectedMaster == null) {
|
||||
if (player != null) {
|
||||
|
|
@ -109,6 +116,7 @@ public class MirrorPatternBindingToolItem extends Item {
|
|||
|
||||
tooltipComponents.add(Component.translatable("item.extendedae_plus.mirror_pattern_binding_tool.tip.select"));
|
||||
tooltipComponents.add(Component.translatable("item.extendedae_plus.mirror_pattern_binding_tool.tip.bind"));
|
||||
tooltipComponents.add(Component.translatable("item.extendedae_plus.mirror_pattern_binding_tool.tip.unbind"));
|
||||
tooltipComponents.add(Component.translatable("item.extendedae_plus.mirror_pattern_binding_tool.tip.range"));
|
||||
|
||||
var selectedMaster = getSelectedMaster(stack);
|
||||
|
|
@ -219,7 +227,8 @@ public class MirrorPatternBindingToolItem extends Item {
|
|||
return;
|
||||
}
|
||||
|
||||
var bindResult = bindMirrorsInRange(level, rangeStart.pos(), clickedPos, selectedMaster);
|
||||
var rangeEnd = clickedPos.immutable();
|
||||
var bindResult = bindMirrorsInRange(level, rangeStart.pos(), rangeEnd, selectedMaster);
|
||||
clearSelectedRangeStart(stack);
|
||||
|
||||
if (bindResult.totalMirrors() == 0) {
|
||||
|
|
@ -232,6 +241,12 @@ public class MirrorPatternBindingToolItem extends Item {
|
|||
player.displayClientMessage(
|
||||
Component.translatable(
|
||||
"extendedae_plus.message.mirror_binding_tool.range_bound",
|
||||
rangeStart.pos().getX(),
|
||||
rangeStart.pos().getY(),
|
||||
rangeStart.pos().getZ(),
|
||||
rangeEnd.getX(),
|
||||
rangeEnd.getY(),
|
||||
rangeEnd.getZ(),
|
||||
bindResult.totalMirrors(),
|
||||
bindResult.boundMirrors(),
|
||||
bindResult.failedMirrors()),
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
"item.extendedae_plus.channel_card.owner.cleared": "Binding cleared",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.select": "Sneak-right-click a master pattern provider to select it",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.bind": "Right-click a mirror pattern provider to bind it to the selected master",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.unbind": "Right-click a bound mirror pattern provider to unbind it, even if a master is selected",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.range": "Sneak-right-click two mirror pattern providers to select a range and bind all mirrors inside it",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.selected": "Selected master provider: (%d, %d, %d)",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.dimension": "Dimension: %s",
|
||||
|
|
@ -245,13 +246,14 @@
|
|||
"extendedae_plus.message.mirror_pattern_provider.bound": "Mirror pattern provider bound to master provider: (%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_pattern_provider.following": "Mirror pattern provider is following master provider: (%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_pattern_provider.missing_master": "No adjacent master pattern provider was found.",
|
||||
"extendedae_plus.message.mirror_pattern_provider.unbound": "Mirror pattern provider unbound.",
|
||||
"extendedae_plus.message.mirror_pattern_provider.readonly": "Mirror pattern provider has no standalone UI and follows the master's state and direction.",
|
||||
"extendedae_plus.message.mirror_binding_tool.selected": "Selected master pattern provider: (%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_binding_tool.no_selection": "Sneak-right-click a master pattern provider first to select it.",
|
||||
"extendedae_plus.message.mirror_binding_tool.bind_failed": "Binding failed: the selected target is not a valid master pattern provider.",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_start_selected": "Selected range start: (%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_no_mirror": "No mirror pattern providers were found in the selected range.",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_bound": "Range binding complete: found %d mirror pattern providers, bound %d successfully, failed %d.",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_bound": "Range binding complete: start (%d, %d, %d), end (%d, %d, %d); found %d mirror pattern providers, bound %d successfully, failed %d.",
|
||||
"extendedae_plus.message.mirror_binding_tool.cleared": "Cleared the stored master pattern provider and range selection from the binding tool.",
|
||||
|
||||
"extendedae_plus.state.master": "Master",
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
"item.extendedae_plus.channel_card.owner.cleared": "已清除绑定",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.select": "潜行右键主样板供应器:选中主供应器",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.bind": "右键镜像样板供应器:绑定到当前选中的主供应器",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.unbind": "右键已绑定的镜像样板供应器:解除绑定(即使当前已选中主供应器)",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.tip.range": "潜行右键镜像样板供应器两次:选择起点和终点后批量范围绑定",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.selected": "当前选中主供应器:(%d, %d, %d)",
|
||||
"item.extendedae_plus.mirror_pattern_binding_tool.dimension": "维度:%s",
|
||||
|
|
@ -240,13 +241,14 @@
|
|||
"extendedae_plus.message.mirror_pattern_provider.bound": "镜像样板供应器已绑定到主供应器:(%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_pattern_provider.following": "镜像样板供应器当前跟随主供应器:(%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_pattern_provider.missing_master": "未找到相邻的主样板供应器。",
|
||||
"extendedae_plus.message.mirror_pattern_provider.unbound": "镜像样板供应器已解除绑定。",
|
||||
"extendedae_plus.message.mirror_pattern_provider.readonly": "镜像样板供应器没有独立界面,状态与朝向会跟随主供应器。",
|
||||
"extendedae_plus.message.mirror_binding_tool.selected": "已选中主样板供应器:(%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_binding_tool.no_selection": "请先潜行右键一个主样板供应器进行选中。",
|
||||
"extendedae_plus.message.mirror_binding_tool.bind_failed": "绑定失败:所选目标不是可用的主样板供应器。",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_start_selected": "已选中范围起点:(%d, %d, %d)",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_no_mirror": "所选范围内未找到镜像样板供应器。",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_bound": "范围绑定完成:找到 %d 个镜像样板供应器,成功绑定 %d 个,失败 %d 个。",
|
||||
"extendedae_plus.message.mirror_binding_tool.range_bound": "范围绑定完成:起点 (%d, %d, %d),终点 (%d, %d, %d);找到 %d 个镜像样板供应器,成功绑定 %d 个,失败 %d 个。",
|
||||
"extendedae_plus.message.mirror_binding_tool.cleared": "已清空绑定工具中记录的主样板供应器和范围选择。",
|
||||
|
||||
"extendedae_plus.state.master": "主模式",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user