-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #168
- Loading branch information
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/xyz/nucleoid/extras/lobby/block/TransientOxidizableDoorBlock.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,37 @@ | ||
package xyz.nucleoid.extras.lobby.block; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.DoorBlock; | ||
import net.minecraft.block.Oxidizable; | ||
import net.minecraft.block.OxidizableDoorBlock; | ||
import net.minecraft.block.enums.DoubleBlockHalf; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
public class TransientOxidizableDoorBlock extends TransientDoorBlock implements Oxidizable { | ||
private final Oxidizable.OxidationLevel oxidationLevel; | ||
|
||
public TransientOxidizableDoorBlock(Block block, Block.Settings settings) { | ||
super(block, settings); | ||
this.oxidationLevel = block instanceof OxidizableDoorBlock door ? door.getDegradationLevel() : Oxidizable.OxidationLevel.UNAFFECTED; | ||
} | ||
|
||
@Override | ||
protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { | ||
if (state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER) { | ||
this.tickDegradation(state, world, pos, random); | ||
} | ||
} | ||
|
||
@Override | ||
protected boolean hasRandomTicks(BlockState state) { | ||
return Oxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent(); | ||
} | ||
|
||
@Override | ||
public OxidationLevel getDegradationLevel() { | ||
return this.oxidationLevel; | ||
} | ||
} |
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