Add vintage lamp and improve backend
This commit is contained in:
parent
9758a0ad31
commit
37e3a8c2db
30 changed files with 300 additions and 72 deletions
|
@ -33,9 +33,9 @@ public abstract class LampBlock extends Block implements Waterloggable {
|
|||
public LampBlock(AbstractBlock.Settings settings, boolean defaultLightState, java.util.function.ToIntFunction<net.minecraft.block.BlockState> luminance) {
|
||||
super(settings.luminance(luminance == null ? (BlockState state) -> {
|
||||
if (state.get(INVERTED)) {
|
||||
return state.get(ON) ? 0 : 12;
|
||||
return state.get(ON) ? 0 : 14;
|
||||
} else {
|
||||
return state.get(ON) ? 12 : 0;
|
||||
return state.get(ON) ? 14 : 0;
|
||||
}
|
||||
} : luminance));
|
||||
this.defaultLightState = defaultLightState;
|
||||
|
|
|
@ -4,10 +4,7 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.text.Text;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
|
@ -18,34 +15,31 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.Config;
|
||||
import su.a71.new_soviet.NewSoviet;
|
||||
import su.a71.new_soviet.registration.NSE_Custom;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
import su.a71.new_soviet.registration.NSE_Sounds;
|
||||
|
||||
public class LightBulbBlock extends LampBlock {
|
||||
public class LightBulbLampBlock extends LampBlock {
|
||||
protected static final VoxelShape SHAPE;
|
||||
public static final BooleanProperty BROKEN;
|
||||
|
||||
public LightBulbBlock(Block.Settings settings) {
|
||||
public LightBulbLampBlock(Block.Settings settings) {
|
||||
super(settings, false, (BlockState state) -> {
|
||||
if (state.get(BROKEN)) {
|
||||
return 0;
|
||||
}
|
||||
if (state.get(INVERTED)) {
|
||||
return state.get(ON) ? 0 : 12;
|
||||
return state.get(ON) ? 0 : 14;
|
||||
} else {
|
||||
return state.get(ON) ? 12 : 0;
|
||||
return state.get(ON) ? 14 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -67,7 +61,7 @@ public class LightBulbBlock extends LampBlock {
|
|||
} else {
|
||||
player.getItemCooldownManager().set(NSE_Items.LIGHT_BULB, 10);
|
||||
player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized"));
|
||||
world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Custom.ELECTRIC_HIT, SoundCategory.AMBIENT, 0.8f, 1f);
|
||||
world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Sounds.ELECTRIC_HIT, SoundCategory.AMBIENT, 0.8f, 1f);
|
||||
if (!player.isCreative()) {
|
||||
player.damage(world.getDamageSources().lightningBolt(), NewSoviet.RANDOM.nextBetween(1, 4));
|
||||
}
|
|
@ -9,7 +9,7 @@ import net.minecraft.world.BlockView;
|
|||
import net.minecraft.world.WorldView;
|
||||
|
||||
public class TableLampBlock extends LampBlock {
|
||||
protected static final VoxelShape SHAPE;
|
||||
protected final VoxelShape SHAPE = getStandingShape();;
|
||||
|
||||
public TableLampBlock(AbstractBlock.Settings settings) {
|
||||
super(settings, true, null);
|
||||
|
@ -24,9 +24,7 @@ public class TableLampBlock extends LampBlock {
|
|||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static VoxelShape getStandingShape(){
|
||||
public VoxelShape getStandingShape(){
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.4375, 0.25, 0.4375, 0.5625, 0.875, 0.5625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.375, 0, 0.375, 0.625, 0.25, 0.625));
|
||||
|
@ -35,8 +33,4 @@ public class TableLampBlock extends LampBlock {
|
|||
shape.simplify();
|
||||
return shape;
|
||||
}
|
||||
|
||||
static {
|
||||
SHAPE = getStandingShape();
|
||||
}
|
||||
}
|
23
src/main/java/su/a71/new_soviet/blocks/VintageLampBlock.java
Normal file
23
src/main/java/su/a71/new_soviet/blocks/VintageLampBlock.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
|
||||
public class VintageLampBlock extends TableLampBlock {
|
||||
public VintageLampBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getStandingShape(){
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.28125, 0, 0.28125, 0.71875, 0.125, 0.71875));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.40625, 0.125, 0.40625, 0.59375, 0.625, 0.59375));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.4375, 0.625, 0.4375, 0.5625, 0.875, 0.5625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.1875, 0.875, 0.1875, 0.8125, 1.125, 0.8125));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.25, 1.125, 0.25, 0.75, 1.1875, 0.75));
|
||||
|
||||
shape.simplify();
|
||||
return shape;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue