Various minor improvements

This commit is contained in:
Andrew-71 2023-09-04 22:32:39 +03:00
parent 466408a67d
commit d2631b7714
8 changed files with 58 additions and 38 deletions

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"new_soviet:tv",
"new_soviet:red_tv",
"new_soviet:brown_tv"
]
}

View file

@ -27,7 +27,7 @@ import net.minecraft.util.Util;
import su.a71.new_soviet.registration.NSE_Blocks;
import su.a71.new_soviet.registration.NSE_Custom;
import su.a71.new_soviet.registration.NSE_Items;
import su.a71.new_soviet.util.NSE_Tags;
import su.a71.new_soviet.registration.NSE_Tags;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@ -820,6 +820,11 @@ public class DataGeneration implements DataGeneratorEntrypoint {
.add(NSE_Blocks.MEAT_TEETH)
.add(NSE_Blocks.PURPLE_GOO);
getOrCreateTagBuilder(NSE_Tags.Blocks.TV)
.add(NSE_Custom.TV)
.add(NSE_Custom.RED_TV)
.add(NSE_Custom.BROWN_TV);
getOrCreateTagBuilder(BlockTags.DOORS)
.add(NSE_Blocks.CHISELED_BIRCH_DOOR)
.add(NSE_Blocks.CHISELED_OAK_DOOR)

View file

@ -11,6 +11,7 @@ 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.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
@ -60,7 +61,7 @@ public class LightBulbLampBlock extends LampBlock {
return ActionResult.SUCCESS;
} else {
player.getItemCooldownManager().set(NSE_Items.LIGHT_BULB, 10);
player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized"), true);
player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized").formatted(Formatting.YELLOW), true);
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));
@ -71,7 +72,6 @@ public class LightBulbLampBlock extends LampBlock {
return ActionResult.PASS;
} else {
return super.onUse(state, world, pos, player, hand, hit);
}
}

View file

@ -1,9 +1,7 @@
package su.a71.new_soviet.blocks.lamps.lamp_post;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.*;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
@ -16,19 +14,22 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
public class LampPostBaseBlock extends Block {
// public BooleanProperty is_extension = Properties.ATTACHED;
public class LampPostBaseBlock extends Block implements Waterloggable {
protected static final VoxelShape SHAPE_BASE;
protected static final VoxelShape SHAPE_ATTACHED;
public static final BooleanProperty WATERLOGGED;
public LampPostBaseBlock(Settings settings) {
super(settings);
this.setDefaultState(this.stateManager.getDefaultState().with(Properties.ATTACHED, false));
this.setDefaultState(this.stateManager.getDefaultState()
.with(Properties.ATTACHED, false)
.with(WATERLOGGED, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.ATTACHED);
builder.add(Properties.ATTACHED, WATERLOGGED);
}
@Override
@ -37,23 +38,20 @@ public class LampPostBaseBlock extends Block {
return SHAPE_ATTACHED;
};
return SHAPE_BASE;
// Direction dir = state.get(FACING);
// return switch (dir) {
// case NORTH -> SHAPE.north();
// case SOUTH -> SHAPE.south();
// case EAST -> SHAPE.east();
// case WEST -> SHAPE.west();
// default -> VoxelShapes.fullCube();
// };
}
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 !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state.with(Properties.ATTACHED, world.getBlockState(pos.down()).getBlock() instanceof LampPostBaseBlock), direction, neighborState, world, pos, neighborPos);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(Properties.ATTACHED, ctx.getWorld().getBlockState(ctx.getBlockPos().down()).getBlock() instanceof LampPostBaseBlock);
return super.getPlacementState(ctx)
.with(Properties.ATTACHED, ctx.getWorld().getBlockState(ctx.getBlockPos().down()).getBlock() instanceof LampPostBaseBlock)
.with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER);
}
public static VoxelShape getBaseShape(){
@ -65,8 +63,13 @@ public class LampPostBaseBlock extends Block {
return shape;
}
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
}
static {
SHAPE_ATTACHED = VoxelShapes.cuboid(0.4375, 0, 0.4375, 0.5625, 1, 0.5625);
SHAPE_BASE = getBaseShape();
WATERLOGGED = Properties.WATERLOGGED;
}
}

View file

@ -15,7 +15,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;
import su.a71.new_soviet.registration.NSE_Sounds;
import su.a71.new_soviet.util.NSE_Tags;
import su.a71.new_soviet.registration.NSE_Tags;
import java.util.Map;
import java.util.function.Consumer;

View file

@ -12,6 +12,8 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
@ -49,5 +51,9 @@ public class NSE_BaseRegistration {
FabricBlockEntityTypeBuilder.create(factory, blocks).build());
}
public static TagKey<Block> createTag(String name) {
return TagKey.of(RegistryKeys.BLOCK, new Identifier(NewSoviet.MOD_ID, name));
}
public static void init() {}
}

View file

@ -0,0 +1,15 @@
package su.a71.new_soviet.registration;
import net.minecraft.block.Block;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import su.a71.new_soviet.NewSoviet;
public class NSE_Tags extends NSE_BaseRegistration{
public static class Blocks {
public static final TagKey<Block> RAKE_MINEABLE = createTag("rake");
public static final TagKey<Block> TV = createTag("tv");
}
}

View file

@ -1,17 +0,0 @@
package su.a71.new_soviet.util;
import net.minecraft.block.Block;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import su.a71.new_soviet.NewSoviet;
public class NSE_Tags {
public class Blocks {
public static final TagKey<Block> RAKE_MINEABLE =
createTag("rake");
private static TagKey<Block> createTag(String name) {
return TagKey.of(RegistryKeys.BLOCK, new Identifier(NewSoviet.MOD_ID, name));
}
}
}