Add lightbulb item for fixing lightbulb lamp

This commit is contained in:
Andrew-71 2023-08-06 23:32:19 +03:00
parent 8b1bc49709
commit cd0ba2f0e2
7 changed files with 22 additions and 17 deletions

View file

@ -1,13 +1,5 @@
Ideas for block functionality
Radio: Inventory where you can put music disks, and a UI to play, shuffle (and pause?) them. Like a jukebox on steroids
Radio: Like a jukebox on steroids. Maybe container for disks, maybe a way to connect to real radio. Who knows.
TV: CC compatible peripheral which combines a speaker and an 8x8 monitor
Crate: Inventory, like a barrel but smaller
Air Raid Siren: when powered (?), plays chosen frequency in chosen way at chosen sound. CC Peripheral attached
Lamp: Both bedside and ceiling are one block, Lamp, that functions sort of like a lantern
Landmine:
попали -> кабум
тронули не лопатой -> кабум 80%
тронули лопатой(сломали) -> 25% кабум
обезвредили лопатой (ПКМ задержать) -> не кабум
Crate: Like a shulker box but much smaller (but cheaper!)

View file

@ -26,6 +26,7 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
import su.a71.new_soviet.registration.NSE_Custom;
import su.a71.new_soviet.registration.NSE_Items;
public class LightBulbBlock extends Block implements Waterloggable {
protected static final VoxelShape SHAPE;
@ -69,9 +70,12 @@ public class LightBulbBlock extends Block implements Waterloggable {
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
// if (!world.isClient && !state.get(BROKEN)) {
// world.setBlockState(pos, (BlockState)state.with(ON, !state.get(ON)), 1);
// }
if (!world.isClient && state.get(BROKEN) && player.getInventory().getMainHandStack().getItem() == NSE_Items.LIGHT_BULB) {
if (!player.isCreative())
player.getInventory().getMainHandStack().decrement(1);
world.setBlockState(pos, (BlockState)state.with(BROKEN, false)
.with(ON, world.isReceivingRedstonePower(pos)), 2);
}
return super.onUse(state, world, pos, player, hand, hit);
}