Skip to content

Commit b816bcb

Browse files
committed
Linear accelerator fixes
1 parent ba638e7 commit b816bcb

14 files changed

Lines changed: 62 additions & 13 deletions

File tree

src/generated/resources/assets/nuclearcraft/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2782,5 +2782,6 @@
27822782
"validation.structure.wrong_corner": "Wrong corner block at: %s",
27832783
"validation.structure.wrong_inner": "Wrong Block at: %s",
27842784
"validation.structure.wrong_outer": "Wrong Casing at: %s",
2785-
"validation.structure.wrong_proportions": "Wrong proportions"
2785+
"validation.structure.wrong_proportions": "Wrong proportions",
2786+
"tooltip.nc.accelerator.too_hot": "Accelerator is too hot"
27862787
}

src/main/java/igentuman/nc/block/ElectromagnetBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ public void appendHoverText(ItemStack pStack, @javax.annotation.Nullable BlockGe
6161
}
6262

6363
public int getHeatRate() {
64-
return prefab().getHeatRate();
64+
return prefab().getHeat();
6565
}
6666
}

src/main/java/igentuman/nc/block/accelerator/AcceleratorIonSourcePortBlock.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import igentuman.nc.block.accelerator.entity.AcceleratorIonSourcePortBE;
44
import igentuman.nc.container.AcceleratorIonSourcePortContainer;
5+
import igentuman.nc.multiblock.MultiblockHandler;
56
import net.minecraft.core.BlockPos;
67
import net.minecraft.core.Direction;
78
import net.minecraft.network.chat.Component;
@@ -70,6 +71,19 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pS
7071
return ACCELERATOR_BE.get(NAME).get().create(pPos, pState);
7172
}
7273

74+
@Override
75+
public void onPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pMovedByPiston) {
76+
super.onPlace(pState, pLevel, pPos, pOldState, pMovedByPiston);
77+
MultiblockHandler.get(pLevel.dimension()).trackBlockChange(pPos, true);
78+
}
79+
80+
@Override
81+
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
82+
super.onRemove(state, level, pos, newState, isMoving);
83+
if(level.isClientSide()) return;
84+
MultiblockHandler.get(level.dimension()).trackBlockChange(pos, true);
85+
}
86+
7387
@Override
7488
public InteractionResult use(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Player player, InteractionHand hand, BlockHitResult result) {
7589

src/main/java/igentuman/nc/block/accelerator/AcceleratorPortBlock.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import igentuman.nc.block.accelerator.entity.AcceleratorPortBE;
44
import igentuman.nc.container.AcceleratorPortContainer;
5+
import igentuman.nc.multiblock.MultiblockHandler;
56
import net.minecraft.ChatFormatting;
67
import net.minecraft.core.BlockPos;
78
import net.minecraft.core.Direction;
@@ -80,6 +81,19 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pS
8081
return ACCELERATOR_BE.get(NAME).get().create(pPos, pState);
8182
}
8283

84+
@Override
85+
public void onPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pMovedByPiston) {
86+
super.onPlace(pState, pLevel, pPos, pOldState, pMovedByPiston);
87+
MultiblockHandler.get(pLevel.dimension()).trackBlockChange(pPos, true);
88+
}
89+
90+
@Override
91+
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
92+
super.onRemove(state, level, pos, newState, isMoving);
93+
if(level.isClientSide()) return;
94+
MultiblockHandler.get(level.dimension()).trackBlockChange(pos, true);
95+
}
96+
8397
@Override
8498
public InteractionResult use(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Player player, InteractionHand hand, BlockHitResult result) {
8599

src/main/java/igentuman/nc/block/accelerator/entity/AbstractAcceleratorControllerBE.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,8 @@ public <T> LazyOptional<T> getPeripheral(@Nonnull Capability<T> cap, @Nullable
362362
public <T> LazyOptional<T> getOCDevice(Capability<T> cap, Direction side) {
363363
return LazyOptional.empty();
364364
}
365+
366+
public boolean isAcceleratorTooHot() {
367+
return (heatRate - coolingRate) > maxTemperature;
368+
}
365369
}

src/main/java/igentuman/nc/block/accelerator/entity/LinearAcceleratorControllerBE.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public HashMap<String, String> getAnalyzeReport() {
187187
}
188188

189189
private boolean accelerateParticle() {
190+
if (isAcceleratorTooHot()) {
191+
return false;
192+
}
190193
hasParticle = false;
191194
if(energyStorage().getEnergyStored() < energyRequired) {
192195
return false;

src/main/java/igentuman/nc/client/gui/accelerator/LinearAcceleratorControllerScreen.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,12 @@ protected void renderLabels(@NotNull GuiGraphics graphics, int mouseX, int mouse
157157

158158
if(isCasingValid()) {
159159
if (isInteriorValid()) {
160-
graphics.drawString(font, __("tooltip.nc.accelerator.voltage", container().getVoltage()), 37, 50, 0xffffff);
161-
graphics.drawString(font, __("tooltip.nc.accelerator.efficiency", numberFormat(container().getEfficiency())+"%"), 37, 60, 0xffffff);
162-
graphics.drawString(font, __("tooltip.nc.accelerator.strength", numberFormat(container().getStrength())), 37, 70, 0xffffff);
160+
graphics.drawString(font, __("tooltip.nc.accelerator.voltage", container().getVoltage()), 37, 50, 0xffffff);
161+
graphics.drawString(font, __("tooltip.nc.accelerator.efficiency", numberFormat(container().getEfficiency()) + "%"), 37, 60, 0xffffff);
162+
graphics.drawString(font, __("tooltip.nc.accelerator.strength", numberFormat(container().getStrength())), 37, 70, 0xffffff);
163+
if (isAcceleratorTooHot()) {
164+
graphics.drawString(font, __("tooltip.nc.accelerator.too_hot"), 37, 80, ChatFormatting.RED.getColor());
165+
}
163166
} else {
164167
interiorTootip = applyFormat(__(getValidationResultKey(), getValidationResultData()), ChatFormatting.RED);
165168
}
@@ -168,6 +171,10 @@ protected void renderLabels(@NotNull GuiGraphics graphics, int mouseX, int mouse
168171
renderTooltips(graphics, mouseX-relX, mouseY-relY);
169172
}
170173

174+
private boolean isAcceleratorTooHot() {
175+
return container().isAcceleratorTooHot();
176+
}
177+
171178
private Object getValidationResultData() {
172179
return container().getValidationResultData().toShortString();
173180
}

src/main/java/igentuman/nc/container/LinearAcceleratorContainer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public double getProgress() {
113113
}
114114

115115
public int getMaxHeat() {
116-
return blockEntity.maxTemperature;
116+
return blockEntity.heatMax;
117117
}
118118

119119
public double getFocus() {
@@ -179,4 +179,8 @@ public int getHeating() {
179179
public int getNetHeat() {
180180
return blockEntity.heatRate - blockEntity.coolingRate;
181181
}
182+
183+
public boolean isAcceleratorTooHot() {
184+
return blockEntity.isAcceleratorTooHot();
185+
}
182186
}

src/main/java/igentuman/nc/content/Electromagnets.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,5 @@ public int getEfficiency() {
132132
public int getMaxTemp() {
133133
return maxTemp;
134134
}
135-
136-
public int getHeatRate() {
137-
return 100; // TODO: make it configurable
138-
}
139135
}
140136
}

src/main/java/igentuman/nc/datagen/NCLanguageProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ private void tooltips() {
656656
add("tooltip.nc.accelerator.focus", "Focus: %s");
657657
add("tooltip.nc.accelerator.quadroupoles", "Quadrupoles: %s");
658658
add("tooltip.nc.accelerator.dipoles", "Dipoles: %s");
659+
add("tooltip.nc.accelerator.too_hot", "Accelerator is too hot");
659660
add("tooltip.nc.accelerator.voltage", "Voltage: %sV");
660661
add("tooltip.nc.accelerator.amplifiers", "Amplifiers: %s");
661662
add("tooltip.nc.accelerator.coolers", "Coolers: %s");

0 commit comments

Comments
 (0)