|
12 | 12 | import com.gregtechceu.gtceu.api.machine.feature.IDropSaveMachine; |
13 | 13 | import com.gregtechceu.gtceu.api.machine.feature.IInteractedMachine; |
14 | 14 | import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; |
| 15 | +import com.gregtechceu.gtceu.config.ConfigHolder; |
15 | 16 | import com.gregtechceu.gtceu.utils.GTTransferUtils; |
16 | 17 |
|
17 | 18 | import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; |
|
31 | 32 | import net.minecraft.world.InteractionHand; |
32 | 33 | import net.minecraft.world.InteractionResult; |
33 | 34 | import net.minecraft.world.entity.player.Player; |
| 35 | +import net.minecraft.world.item.ItemStack; |
34 | 36 | import net.minecraft.world.level.Level; |
35 | 37 | import net.minecraft.world.level.block.Block; |
36 | 38 | import net.minecraft.world.level.block.state.BlockState; |
@@ -58,6 +60,8 @@ public class DrumMachine extends MetaMachine implements IAutoOutputFluid, IDropS |
58 | 60 | @DescSynced |
59 | 61 | @RequireRerender |
60 | 62 | protected boolean autoOutputFluids; |
| 63 | + @Persisted |
| 64 | + protected boolean allowInputFromOutputSideFluids; |
61 | 65 | @Getter |
62 | 66 | private final int maxStoredFluids; |
63 | 67 | @Persisted |
@@ -150,14 +154,20 @@ public void setAutoOutputFluids(boolean allow) { |
150 | 154 | updateAutoOutputSubscription(); |
151 | 155 | } |
152 | 156 |
|
| 157 | + private static boolean canInputFluidsFromOutputSide() { |
| 158 | + return ConfigHolder.INSTANCE.machines.allowDrumsInputFluidsFromOutputSide; |
| 159 | + } |
| 160 | + |
153 | 161 | @Override |
154 | 162 | public boolean isAllowInputFromOutputSideFluids() { |
155 | | - return false; |
| 163 | + return canInputFluidsFromOutputSide() && this.allowInputFromOutputSideFluids; |
156 | 164 | } |
157 | 165 |
|
158 | | - // always is facing down, and can never accept fluids from output side |
| 166 | + // always is facing down, and can never accept fluids from output side by default |
159 | 167 | @Override |
160 | | - public void setAllowInputFromOutputSideFluids(boolean allow) {} |
| 168 | + public void setAllowInputFromOutputSideFluids(boolean allow) { |
| 169 | + this.allowInputFromOutputSideFluids = allow; |
| 170 | + } |
161 | 171 |
|
162 | 172 | @Override |
163 | 173 | public void setOutputFacingFluids(@Nullable Direction outputFacing) { |
@@ -214,28 +224,61 @@ public boolean saveBreak() { |
214 | 224 | @Override |
215 | 225 | protected InteractionResult onScrewdriverClick(Player playerIn, InteractionHand hand, Direction gridSide, |
216 | 226 | BlockHitResult hitResult) { |
| 227 | + if (!isRemote()) { |
| 228 | + if (canInputFluidsFromOutputSide()) { |
| 229 | + setAllowInputFromOutputSideFluids(!isAllowInputFromOutputSideFluids()); |
| 230 | + playerIn.sendSystemMessage( |
| 231 | + Component |
| 232 | + .translatable("gtceu.machine.basic.input_from_output_side." + |
| 233 | + (isAllowInputFromOutputSideFluids() ? "allow" : "disallow")) |
| 234 | + .append(Component.translatable("gtceu.creative.tank.fluid"))); |
| 235 | + } |
| 236 | + return InteractionResult.SUCCESS; |
| 237 | + } |
| 238 | + return super.onScrewdriverClick(playerIn, hand, gridSide, hitResult); |
| 239 | + } |
| 240 | + |
| 241 | + @Override |
| 242 | + protected InteractionResult onSoftMalletClick(Player playerIn, InteractionHand hand, Direction gridSide, |
| 243 | + BlockHitResult hitResult) { |
217 | 244 | if (!isRemote()) { |
218 | 245 | if (!playerIn.isShiftKeyDown()) { |
219 | 246 | setAutoOutputFluids(!isAutoOutputFluids()); |
220 | | - playerIn.sendSystemMessage(Component |
221 | | - .translatable("gtceu.machine.drum." + (autoOutputFluids ? "enable" : "disable") + "_output")); |
| 247 | + playerIn.sendSystemMessage( |
| 248 | + Component.translatable( |
| 249 | + "gtceu.machine.drum." + (autoOutputFluids ? "enable" : "disable") + "_output")); |
222 | 250 | return InteractionResult.SUCCESS; |
223 | 251 | } |
224 | 252 | } |
225 | | - return super.onScrewdriverClick(playerIn, hand, gridSide, hitResult); |
| 253 | + return super.onSoftMalletClick(playerIn, hand, gridSide, hitResult); |
226 | 254 | } |
227 | 255 |
|
228 | 256 | ////////////////////////////////////// |
229 | 257 | // ******* Rendering ********// |
230 | 258 | ////////////////////////////////////// |
| 259 | + |
| 260 | + @Override |
| 261 | + public boolean shouldRenderGrid(Player player, BlockPos pos, BlockState state, ItemStack held, |
| 262 | + Set<GTToolType> toolTypes) { |
| 263 | + return super.shouldRenderGrid(player, pos, state, held, toolTypes) || |
| 264 | + toolTypes.contains(GTToolType.SOFT_MALLET) || |
| 265 | + (canInputFluidsFromOutputSide() && toolTypes.contains(GTToolType.SCREWDRIVER)); |
| 266 | + } |
| 267 | + |
231 | 268 | @Override |
232 | 269 | public @Nullable ResourceTexture sideTips(Player player, BlockPos pos, BlockState state, Set<GTToolType> toolTypes, |
233 | 270 | Direction side) { |
234 | | - if (toolTypes.contains(GTToolType.SCREWDRIVER)) { |
| 271 | + if (toolTypes.contains(GTToolType.SOFT_MALLET)) { |
235 | 272 | if (side == getOutputFacingFluids()) { |
236 | 273 | return isAutoOutputFluids() ? GuiTextures.TOOL_DISABLE_AUTO_OUTPUT : GuiTextures.TOOL_AUTO_OUTPUT; |
237 | 274 | } |
238 | 275 | } |
| 276 | + if (canInputFluidsFromOutputSide() && toolTypes.contains(GTToolType.SCREWDRIVER)) { |
| 277 | + if (side == getOutputFacingFluids()) { |
| 278 | + return GuiTextures.TOOL_ALLOW_INPUT; |
| 279 | + } |
| 280 | + } |
| 281 | + |
239 | 282 | return super.sideTips(player, pos, state, toolTypes, side); |
240 | 283 | } |
241 | 284 | } |
0 commit comments