Compare commits
2 commits
d99e8fd54c
...
cd0ba2f0e2
Author | SHA1 | Date | |
---|---|---|---|
cd0ba2f0e2 | |||
8b1bc49709 |
9 changed files with 82 additions and 29 deletions
|
@ -1,10 +1,13 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -13,25 +16,29 @@ 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 net.minecraft.block.RedstoneLampBlock;
|
||||
import net.minecraft.block.TorchBlock;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CeilingFanBlock extends Block {
|
||||
public class CeilingFanBlock extends Block implements Waterloggable {
|
||||
protected static final VoxelShape SHAPE;
|
||||
public static final BooleanProperty ON;
|
||||
public static final BooleanProperty WATERLOGGED;
|
||||
|
||||
public CeilingFanBlock(Block.Settings settings) {
|
||||
super(settings);
|
||||
this.setDefaultState((BlockState)this.getDefaultState().with(ON, false));
|
||||
this.setDefaultState((BlockState)this.getDefaultState().with(ON, false).with(WATERLOGGED, false));
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return (BlockState)this.getDefaultState().with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
||||
return (BlockState)this.getDefaultState()
|
||||
.with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()))
|
||||
.with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER);
|
||||
}
|
||||
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
||||
|
@ -44,10 +51,17 @@ public class CeilingFanBlock extends Block {
|
|||
world.setBlockState(pos, (BlockState)state.cycle(ON), 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return direction == Direction.UP && !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
|
||||
}
|
||||
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
if ((Boolean)state.get(ON) && !world.isReceivingRedstonePower(pos)) {
|
||||
world.setBlockState(pos, (BlockState)state.cycle(ON), 2);
|
||||
|
@ -55,13 +69,17 @@ public class CeilingFanBlock extends Block {
|
|||
}
|
||||
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(new Property[]{ON});
|
||||
builder.add(new Property[]{ON, WATERLOGGED});
|
||||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
Direction direction = Direction.UP;
|
||||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
|
@ -70,5 +88,6 @@ public class CeilingFanBlock extends Block {
|
|||
static {
|
||||
SHAPE = VoxelShapes.union(Block.createCuboidShape(4.0, 2.0, 4.0, 12.0, 7.0, 12.0), Block.createCuboidShape(7.0, 7.0, 7.0, 9.0, 13.0, 9.0), Block.createCuboidShape(6.0, 13.0, 6.0, 10.0, 16.0, 10.0));
|
||||
ON = RedstoneTorchBlock.LIT;
|
||||
WATERLOGGED = Properties.WATERLOGGED;
|
||||
}
|
||||
}
|
|
@ -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!)
|
|
@ -3,6 +3,8 @@ package su.a71.new_soviet.blocks;
|
|||
import net.minecraft.block.*;
|
||||
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;
|
||||
|
@ -10,6 +12,8 @@ import net.minecraft.state.StateManager;
|
|||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -18,23 +22,29 @@ 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.registration.NSE_Custom;
|
||||
import su.a71.new_soviet.registration.NSE_Items;
|
||||
|
||||
public class LightBulbBlock extends Block {
|
||||
public class LightBulbBlock extends Block implements Waterloggable {
|
||||
protected static final VoxelShape SHAPE;
|
||||
public static final BooleanProperty ON;
|
||||
public static final BooleanProperty BROKEN;
|
||||
public static final BooleanProperty WATERLOGGED;
|
||||
|
||||
public LightBulbBlock(Block.Settings settings) {
|
||||
super(settings);
|
||||
this.setDefaultState((BlockState)this.getDefaultState().with(ON, false).with(BROKEN, false));
|
||||
super(settings.luminance((BlockState state) -> state.get(ON) && !state.get(BROKEN) ? 12 : 0));
|
||||
this.setDefaultState((BlockState)this.getDefaultState().with(ON, false).with(BROKEN, false).with(WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return (BlockState)this.getDefaultState().with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos())).with(BROKEN, false);
|
||||
return (BlockState)this.getDefaultState()
|
||||
.with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()))
|
||||
.with(BROKEN, false)
|
||||
.with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER);
|
||||
}
|
||||
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
||||
|
@ -50,6 +60,25 @@ public class LightBulbBlock extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return direction == Direction.UP && !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
|
||||
if (!state.get(BROKEN)) {
|
||||
|
@ -66,7 +95,11 @@ public class LightBulbBlock extends Block {
|
|||
}
|
||||
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(new Property[]{ON, BROKEN});
|
||||
builder.add(new Property[]{ON, BROKEN, WATERLOGGED});
|
||||
}
|
||||
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
|
@ -86,5 +119,6 @@ public class LightBulbBlock extends Block {
|
|||
SHAPE = VoxelShapes.union(Block.createCuboidShape(7, 15, 7, 9, 16, 9), Block.createCuboidShape(7, 6, 7, 9, 8, 9)); //VoxelShapes.union(Block.createCuboidShape(4.0, 2.0, 4.0, 12.0, 7.0, 12.0), Block.createCuboidShape(7.0, 7.0, 7.0, 9.0, 13.0, 9.0), Block.createCuboidShape(6.0, 13.0, 6.0, 10.0, 16.0, 10.0));
|
||||
ON = RedstoneTorchBlock.LIT;
|
||||
BROKEN = Properties.CRACKED;
|
||||
WATERLOGGED = Properties.WATERLOGGED;
|
||||
}
|
||||
}
|
|
@ -90,11 +90,10 @@ public class SirenBlock extends HorizontalFacingBlock {
|
|||
|
||||
public float getSirenVolume(World world, BlockPos pos) {
|
||||
return switch (world.getReceivedRedstonePower(pos)) {
|
||||
case 1, 2, 3 -> 2f;
|
||||
case 4, 5, 6 -> 3f;
|
||||
case 7, 8, 9 -> 4f;
|
||||
case 10, 11, 12 -> 5f;
|
||||
case 13, 14, 15, 16 -> 6f;
|
||||
case 4, 5, 6 -> 2f;
|
||||
case 7, 8, 9 -> 3f;
|
||||
case 10, 11, 12 -> 4f;
|
||||
case 13, 14, 15, 16 -> 5f;
|
||||
default -> 1f;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class NSE_Custom {
|
|||
public static final TVBlock BROWN_TV = new TVBlock(FabricBlockSettings.create().mapColor(MapColor.TERRACOTTA_BROWN));
|
||||
public static final RadioBlock RADIO = new RadioBlock();
|
||||
public static final LampBlock LAMP = new LampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final LightBulbBlock LIGHT_BULB = new LightBulbBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final LightBulbBlock LIGHT_BULB = new LightBulbBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.GLASS).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = SoundEvent.of(new Identifier("new_soviet", "light_bulb_broken_sound"));
|
||||
|
||||
public static final CeilingFanBlock CEILING_FAN = new CeilingFanBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
|
|
|
@ -28,16 +28,16 @@ public class NSE_Items {
|
|||
// Like an iron axe but a hoe and slightly faster (-2.8f vs -3.1f) and a bit weaker (6 vs 6.5 damage)
|
||||
public static final ToolItem SICKLE = new HoeItem(ToolMaterials.IRON, 6, -2.8F, new Item.Settings());
|
||||
|
||||
// TODO: Currently same as golden apple
|
||||
public static final FoodComponent COCONUT_FC = (new FoodComponent.Builder()).hunger(4).saturationModifier(1.2F).statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100, 1), 1.0F).statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 2400, 0), 1.0F).alwaysEdible().build();
|
||||
public static final Item COCONUT = new Item(new Item.Settings().food(COCONUT_FC).rarity(Rarity.EPIC));
|
||||
|
||||
public static final DiceItem DICE_D6 = new DiceItem(new Item.Settings().maxCount(6));
|
||||
public static final DiceD4Item DICE_D4 = new DiceD4Item(new Item.Settings().maxCount(6));
|
||||
public static final DiceD20Item DICE_D20 = new DiceD20Item(new Item.Settings().maxCount(6));
|
||||
|
||||
public static final SoundEvent DICE_SOUND = SoundEvent.of(new Identifier("new_soviet", "dice_sound"));
|
||||
|
||||
public static final Item LIGHT_BULB = new Item(new Item.Settings());
|
||||
|
||||
private static final ItemGroup NSE_ITEMS_TAB = FabricItemGroup.builder()
|
||||
.icon(() -> new ItemStack(SICKLE))
|
||||
.displayName(Text.translatable("itemGroup.new_soviet.items"))
|
||||
|
@ -60,6 +60,7 @@ public class NSE_Items {
|
|||
register("dice_d6", () -> DICE_D6, NSE_ITEMS_TAB);
|
||||
register("dice_d4", () -> DICE_D4, NSE_ITEMS_TAB);
|
||||
register("dice_d20", () -> DICE_D20, NSE_ITEMS_TAB);
|
||||
register("light_bulb_item", () -> LIGHT_BULB, NSE_ITEMS_TAB);
|
||||
|
||||
Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "dice_sound"), DICE_SOUND);
|
||||
}
|
||||
|
|
|
@ -150,5 +150,6 @@
|
|||
"block.new_soviet.blue_concrete_with_bars": "Blue Concrete With Bars",
|
||||
"block.new_soviet.red_concrete_with_bars": "Red Concrete With Bars",
|
||||
"subtitles.new_soviet.light_bulb_broken": "Light bulb breaks",
|
||||
"block.new_soviet.light_bulb": "Light Bulb"
|
||||
"block.new_soviet.light_bulb": "Light Bulb Lamp",
|
||||
"item.new_soviet.light_bulb_item": "Light Bulb"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"credit": "Karoter2",
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "new_soviet:item/bulb"
|
||||
}
|
||||
}
|
BIN
src/main/resources/assets/new_soviet/textures/item/bulb.png
Normal file
BIN
src/main/resources/assets/new_soviet/textures/item/bulb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 315 B |
Loading…
Reference in a new issue