This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityRockBreaker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package muramasa.gregtech.blockentity.single; | ||
|
||
import muramasa.antimatter.blockentity.BlockEntityMachine; | ||
import muramasa.antimatter.capability.machine.MachineRecipeHandler; | ||
import muramasa.antimatter.machine.types.Machine; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.material.Fluids; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class BlockEntityRockBreaker extends BlockEntityMachine<BlockEntityRockBreaker> { | ||
public BlockEntityRockBreaker(Machine<?> type, BlockPos pos, BlockState state) { | ||
super(type, pos, state); | ||
this.recipeHandler.set(() -> new MachineRecipeHandler<BlockEntityRockBreaker>(this){ | ||
@Override | ||
protected boolean canRecipeContinue() { | ||
return super.canRecipeContinue() && this.hasWaterAndLava(); | ||
} | ||
|
||
public boolean hasWaterAndLava() { | ||
boolean water = false; | ||
boolean lava = false; | ||
for(Direction direction : Direction.Plane.HORIZONTAL) { | ||
if (this.tile.level.isWaterAt(this.tile.getBlockPos().relative(direction))) water = true; | ||
if (this.tile.level.getFluidState(this.tile.getBlockPos().relative(direction)).getType() == Fluids.LAVA) lava = true; | ||
} | ||
return water && lava; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onBlockUpdate(BlockPos neighbor) { | ||
super.onBlockUpdate(neighbor); | ||
this.recipeHandler.ifPresent(MachineRecipeHandler::checkRecipe); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters