Skip to content

Commit e234767

Browse files
committed
Fix contactors and probe
1 parent 711e971 commit e234767

6 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/main/java/falseresync/vivatech/world/block/ContactorBlock.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ protected void neighborChanged(BlockState state, Level level, BlockPos pos, Bloc
8989
}
9090

9191
@Override
92-
protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) {
93-
if (state.is(level.getBlockState(pos).getBlock())) {
92+
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) {
93+
if (state.is(oldState.getBlock())) {
9494
manageGridConnection(state, level, pos);
9595
}
96-
super.affectNeighborsAfterRemoval(state, level, pos, movedByPiston);
9796
}
9897

9998
private static void manageGridConnection(BlockState state, Level level, BlockPos pos) {

src/main/java/falseresync/vivatech/world/electricity/grid/Grid.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ public static <V, E> void replaceVertexIgnoringUndirectedEdgeEquality(Graph<V, E
318318
}
319319
}
320320

321+
public boolean isFrozen() {
322+
return frozen;
323+
}
324+
321325
public void tick() {
322326
pollChunks();
323327
if (frozen) {

src/main/java/falseresync/vivatech/world/item/ProbeItem.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package falseresync.vivatech.world.item;
22

33
import falseresync.vivatech.Vivatech;
4+
import net.minecraft.ChatFormatting;
45
import net.minecraft.core.BlockPos;
56
import net.minecraft.network.chat.Component;
67
import net.minecraft.server.level.ServerPlayer;
@@ -28,7 +29,11 @@ public InteractionResult useOn(UseOnContext context) {
2829
if (context.getPlayer() instanceof ServerPlayer player) {
2930
var grid = Vivatech.getPowerSystemsManager().getFor(context.getLevel().dimension()).getGridLookup().get(context.getClickedPos());
3031
if (grid != null) {
31-
player.displayClientMessage(Component.translatable("hud.vivatech.probe", Math.round(grid.getLastVoltage()), grid.getLastCurrent()), true);
32+
if (grid.isFrozen()) {
33+
player.displayClientMessage(Component.translatable("hud.vivatech.probe.grid_frozen").withStyle(ChatFormatting.BOLD).withStyle(ChatFormatting.DARK_RED), true);
34+
} else {
35+
player.displayClientMessage(Component.translatable("hud.vivatech.probe.grid_parameters", Math.round(grid.getLastVoltage()), grid.getLastCurrent()), true);
36+
}
3237
}
3338
}
3439
return super.useOn(context);

src/main/java/falseresync/vivatech/world/item/VivatechItems.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ private static BlockItem register(String name, Block block) {
6262

6363
private static BlockItem register(String name, Block block, Item.Properties properties) {
6464
var id = Vivatech.id(name);
65-
return Registry.register(BuiltInRegistries.ITEM, id, new BlockItem(block, properties.setId(ResourceKey.create(Registries.ITEM, id))));
65+
return Registry.register(BuiltInRegistries.ITEM, id, new BlockItem(block, properties
66+
.setId(ResourceKey.create(Registries.ITEM, id))
67+
.useBlockDescriptionPrefix()));
6668
}
6769
}

src/main/resources/assets/vivatech/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"item.vivatech.pliers": "Pliers",
1919
"item.vivatech.probe": "Probe",
2020

21-
"hud.vivatech.probe": "Voltage: %d - Current: %.2f",
21+
"hud.vivatech.probe.grid_frozen": "This grid is frozen! Some chunks are not loaded",
22+
"hud.vivatech.probe.grid_parameters": "Voltage: %d - Current: %.2f",
2223
"hud.vivatech.wire": "Not enough wire"
2324
}

src/main/resources/assets/vivatech/lang/ru_ru.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"item.vivatech.pliers": "Кусачки",
1919
"item.vivatech.probe": "Зонд",
2020

21-
"hud.vivatech.probe": "Напряжение: %d - Ток: %.2f",
21+
"hud.vivatech.probe.grid_frozen": "Эта сеть заморожена! Часть чанков не загружена",
22+
"hud.vivatech.probe.grid_parameters": "Напряжение: %d - Ток: %.2f",
2223
"hud.vivatech.wire": "Провод не достаёт"
2324
}

0 commit comments

Comments
 (0)