-
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.
- Loading branch information
Showing
5 changed files
with
59 additions
and
1 deletion.
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
45 changes: 45 additions & 0 deletions
45
src/main/java/xyz/nucleoid/extras/lobby/block/tater/LightTaterBlock.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,45 @@ | ||
package xyz.nucleoid.extras.lobby.block.tater; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.LightBlock; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.particle.BlockStateParticleEffect; | ||
import net.minecraft.particle.ParticleEffect; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public class LightTaterBlock extends MarkerTaterBlock { | ||
public LightTaterBlock(Settings settings, String texture) { | ||
super(settings, Blocks.LIGHT, texture); | ||
} | ||
|
||
@Override | ||
public ParticleEffect getBlockParticleEffect(BlockState state, ServerWorld world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
return getLightParticle(world.getLightLevel(pos)); | ||
} | ||
|
||
@Override | ||
public double getPlayerParticleYOffset() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public ParticleEffect getPlayerParticleEffect(ServerPlayerEntity player) { | ||
BlockPos pos = BlockPos.ofFloored(player.getX(), player.getY() + this.getPlayerParticleYOffset(), player.getZ()); | ||
|
||
return getLightParticle(player.getWorld().getLightLevel(pos)); | ||
} | ||
|
||
private static BlockState getLightState(int level) { | ||
return Blocks.LIGHT.getDefaultState().with(LightBlock.LEVEL_15, level); | ||
} | ||
|
||
private static ParticleEffect getLightParticle(int level) { | ||
return new BlockStateParticleEffect(ParticleTypes.BLOCK_MARKER, getLightState(level)); | ||
} | ||
} |
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