diff --git a/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java b/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java index f30c2e0..db9483e 100644 --- a/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java +++ b/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java @@ -248,6 +248,9 @@ public enum Lib39LangKey implements ILangKeyValueCollection { addLang(LangKeyValue.copyOf( Lib39Blocks.DOLL, ModPartEnum.BLOCK, dollName )); + addLang(LangKeyValue.copyOf( + Lib39Blocks.WALL_DOLL, ModPartEnum.BLOCK, dollName + )); addLang(LangKeyValue.ofKey( "tooltip.lib39.content.doll.hover.1", ModPartEnum.DESCRIPTION, "§eSkinOwner §7:§a %s ", "§e皮肤所有者§7:§a%s", "§e皮膚所有者§7:§a%s", "§e膚主§7:§a%s" diff --git a/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java b/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java index a4ecbfe..12f1708 100644 --- a/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java +++ b/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java @@ -635,8 +635,10 @@ public class WheelWidget extends AbstractWidget { float pixelOuterRadius = outerRadius * guiScale; float pixelAntiAliasing = 2.0f * guiScale; // 抗锯齿范围 - System.out.println("Shader Params - Center: (" + pixelCenterX + ", " + pixelCenterY + - "), InnerRadius: " + pixelInnerRadius + ", OuterRadius: " + pixelOuterRadius); +// if (Services.PLATFORM.isDevelopmentEnvironment()) { +// System.out.println("Shader Params - Center: (" + pixelCenterX + ", " + pixelCenterY + +// "), InnerRadius: " + pixelInnerRadius + ", OuterRadius: " + pixelOuterRadius); +// } ShaderInstance shader = Lib39Shaders.getRingShader(); shader.safeGetUniform("Center").set(pixelCenterX, pixelCenterY); diff --git a/common/src/main/java/top/r3944realms/lib39/client/renderer/block/DollBlockEntityRenderer.java b/common/src/main/java/top/r3944realms/lib39/client/renderer/block/DollBlockEntityRenderer.java index fd1796c..07cfb73 100644 --- a/common/src/main/java/top/r3944realms/lib39/client/renderer/block/DollBlockEntityRenderer.java +++ b/common/src/main/java/top/r3944realms/lib39/client/renderer/block/DollBlockEntityRenderer.java @@ -11,11 +11,15 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.SkullBlock; +import net.minecraft.world.level.block.WallSkullBlock; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.RotationSegment; import org.jetbrains.annotations.NotNull; import top.r3944realms.lib39.client.model.DollModel; import top.r3944realms.lib39.client.renderer.item.DollItemRenderer; -import top.r3944realms.lib39.content.block.DollBlock; +import top.r3944realms.lib39.content.block.AbstractDollBlock; +import top.r3944realms.lib39.content.block.WallDollBlock; import top.r3944realms.lib39.content.block.blockentity.DollBlockEntity; import top.r3944realms.lib39.util.lang.Pair; @@ -37,14 +41,15 @@ public class DollBlockEntityRenderer implements BlockEntityRenderer resourceLocationBooleanPair = DollItemRenderer.loadSkin(profile); poseStack.pushPose(); poseStack.translate(0.5, 1.5, 0.5); poseStack.scale(1.0F, -1.0F, -1.0F); - float rotation = facing.toYRot(); poseStack.mulPose(Axis.YP.rotationDegrees(rotation)); VertexConsumer vertexConsumer = buffer.getBuffer(RenderType.entityTranslucent(resourceLocationBooleanPair.first)); this.dollModel.slim = resourceLocationBooleanPair.second; diff --git a/common/src/main/java/top/r3944realms/lib39/content/block/AbstractDollBlock.java b/common/src/main/java/top/r3944realms/lib39/content/block/AbstractDollBlock.java new file mode 100644 index 0000000..604cfd1 --- /dev/null +++ b/common/src/main/java/top/r3944realms/lib39/content/block/AbstractDollBlock.java @@ -0,0 +1,226 @@ +package top.r3944realms.lib39.content.block; + +import com.mojang.authlib.GameProfile; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import top.r3944realms.lib39.content.block.blockentity.DollBlockEntity; +import top.r3944realms.lib39.content.block.property.DollPose; +import top.r3944realms.lib39.core.register.Lib39BlockEntities; +import top.r3944realms.lib39.core.register.Lib39Items; +import top.r3944realms.lib39.core.register.Lib39SoundEvents; +import top.r3944realms.lib39.util.GameProfileHelper; + +import java.util.List; + +/** + * The type Abstract doll block. + */ +@SuppressWarnings("deprecation") +public abstract class AbstractDollBlock extends BaseEntityBlock implements SimpleWaterloggedBlock { + /** + * The constant WATERLOGGED. + */ + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + private static final Properties properties = Properties.of() + .instrument(NoteBlockInstrument.BASEDRUM) + .sound(SoundType.WOOL) + .pushReaction(PushReaction.DESTROY) + .strength(0f, 10f) + .noOcclusion(); + private static final double PARTICLE_OFFSET_RANGE = 0.25; + private static final double PARTICLE_HEIGHT_OFFSET = 1.0; + private static final double PARTICLE_HEIGHT_VARIANCE = 0.2; + private static final float NOTE_COLOR_DIVISOR = 24.0F; + private static final int MAX_NOTE_COLORS = 4; + + private static final float BASE_VOLUME = 1.0f; + private static final float PITCH_VARIANCE = 0.5f; + private static final float BASE_PITCH = 0.75f; + + private static final VoxelShape DOLL_SHAPE = Block.box(2.0d, 0.0d, 2.0d, 14.0d, 12.0d, 14.0d); + /** + * The constant POSE. + */ + public static final EnumProperty POSE = EnumProperty.create("pose", DollPose.class); + + /** + * Instantiates a new Abstract doll block. + */ + public AbstractDollBlock() { + super(properties); + } + @Override + public boolean canBeReplaced(@NotNull BlockState state, @NotNull BlockPlaceContext useContext) { + return false; + } + + @Override + public @NotNull BlockState updateShape(@NotNull BlockState currentState, @NotNull Direction direction, @NotNull BlockState neighborState, + @NotNull LevelAccessor level, @NotNull BlockPos currentPos, @NotNull BlockPos neighborPos) { + if (currentState.getValue(WATERLOGGED)) { + level.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + return super.updateShape(currentState, direction, neighborState, level, currentPos, neighborPos); + } + + @Override + public @NotNull FluidState getFluidState(@NotNull BlockState blockState) { + return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState); + } + + @Override + public @NotNull InteractionResult use(@NotNull BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull Player player, + @NotNull InteractionHand hand, @NotNull BlockHitResult hitResult) { + if (level instanceof ServerLevel serverLevel) { + // 播放粒子效果 + spawnNoteParticles(serverLevel, blockPos); + // 播放音效 + playDollSound(serverLevel, blockPos); + } + return InteractionResult.SUCCESS; + } + /** + * 在玩偶位置生成音符粒子效果 + */ + private void spawnNoteParticles(ServerLevel serverLevel, BlockPos blockPos) { + Vec3 particlePosition = calculateParticlePosition(serverLevel, blockPos); + float noteColor = calculateNoteColor(serverLevel); + + serverLevel.sendParticles(ParticleTypes.NOTE, + particlePosition.x(), particlePosition.y(), particlePosition.z(), + 0, noteColor, 0, 0, 1); + } + + /** + * 计算粒子生成位置,添加随机偏移 + */ + private @NotNull Vec3 calculateParticlePosition(@NotNull ServerLevel serverLevel, BlockPos blockPos) { + return Vec3.atBottomCenterOf(blockPos).add( + (serverLevel.getRandom().nextFloat() - 0.5) * PARTICLE_OFFSET_RANGE * 2, + PARTICLE_HEIGHT_OFFSET + serverLevel.getRandom().nextFloat() * PARTICLE_HEIGHT_VARIANCE, + (serverLevel.getRandom().nextFloat() - 0.5) * PARTICLE_OFFSET_RANGE * 2 + ); + } + + /** + * 计算音符粒子的颜色 + */ + private float calculateNoteColor(@NotNull ServerLevel serverLevel) { + return serverLevel.getRandom().nextInt(MAX_NOTE_COLORS) / NOTE_COLOR_DIVISOR; + } + + /** + * 播放玩偶音效 + */ + private void playDollSound(@NotNull ServerLevel serverLevel, BlockPos blockPos) { + float pitch = BASE_PITCH + serverLevel.random.nextFloat() * PITCH_VARIANCE; + serverLevel.playSound(null, blockPos, Lib39SoundEvents.DUCK_TOY.get(), + SoundSource.BLOCKS, BASE_VOLUME, pitch); + } + + @Override + public @NotNull VoxelShape getShape(@NotNull BlockState blockState, @NotNull BlockGetter level, @NotNull BlockPos blockPos, @NotNull CollisionContext context) { + return DOLL_SHAPE; + } + + public @NotNull VoxelShape getOcclusionShape(@NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos) { + return Shapes.empty(); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState blockState) { + return Lib39BlockEntities.DOLL_BLOCK_ENTITY.get().create(blockPos, blockState); + } + + @SuppressWarnings("deprecation") + @Override + public @NotNull RenderShape getRenderShape(@NotNull BlockState state) { + return RenderShape.ENTITYBLOCK_ANIMATED; + } + + @Override + public @NotNull ItemStack getCloneItemStack(@NotNull BlockGetter level, @NotNull BlockPos pos, @NotNull BlockState state) { + ItemStack stack = super.getCloneItemStack(level, pos, state); + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof DollBlockEntity doll) { + GameProfile profile = doll.getOwnerProfile(); + if (profile != null) { + GameProfileHelper.saveProfileToItemStack(stack, profile); + } + } + return stack; + } + + /** + * 最重要的方法:重写掉落逻辑 + */ + @Override + @NotNull + public List getDrops(@NotNull BlockState state, @NotNull LootParams.Builder params) { + // 获取方块实体 + BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); + + if (blockEntity instanceof DollBlockEntity dollEntity) { + List customDrops = getCustomDrops(dollEntity, params); + if (customDrops != null) return customDrops; + } + return super.getDrops(state, params); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.@NotNull Builder builder) { + super.createBlockStateDefinition(builder); + builder.add(WATERLOGGED, POSE); + } + + /** + * 生成自定义掉落物 + */ + @Nullable + private List getCustomDrops(DollBlockEntity dollEntity, LootParams.Builder params) { + if (params.getOptionalParameter(LootContextParams.THIS_ENTITY) instanceof Player player) { + if (player.isCreative()) { + return List.of(); + } + } + GameProfile profile = dollEntity.getOwnerProfile(); + if (profile != null) { + ItemStack instance = Lib39Items.DOLL.get().getDefaultInstance(); + GameProfileHelper.saveProfileToItemStack(instance, profile); + return List.of(instance); + } + return null; + } +} diff --git a/common/src/main/java/top/r3944realms/lib39/content/block/DollBlock.java b/common/src/main/java/top/r3944realms/lib39/content/block/DollBlock.java index 4cfb4b5..4a1ea6d 100644 --- a/common/src/main/java/top/r3944realms/lib39/content/block/DollBlock.java +++ b/common/src/main/java/top/r3944realms/lib39/content/block/DollBlock.java @@ -1,235 +1,65 @@ package top.r3944realms.lib39.content.block; -import com.mojang.authlib.GameProfile; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.*; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.storage.loot.LootParams; -import net.minecraft.world.level.storage.loot.parameters.LootContextParams; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.r3944realms.lib39.content.block.blockentity.DollBlockEntity; import top.r3944realms.lib39.content.block.property.DollPose; -import top.r3944realms.lib39.core.register.Lib39BlockEntities; -import top.r3944realms.lib39.core.register.Lib39Items; -import top.r3944realms.lib39.core.register.Lib39SoundEvents; -import top.r3944realms.lib39.util.GameProfileHelper; - -import java.util.List; /** * The type Doll block. */ @SuppressWarnings("deprecation") -public class DollBlock extends HorizontalDirectionalBlock implements SimpleWaterloggedBlock, EntityBlock { - private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; +public class DollBlock extends AbstractDollBlock{ /** - * The constant POSE. + * The constant MAX. */ - public static final EnumProperty POSE = EnumProperty.create("pose", DollPose.class); + public static final int MAX = RotationSegment.getMaxSegmentIndex(); - private static final VoxelShape DOLL_SHAPE = Block.box(2.0d, 0.0d, 2.0d, 14.0d, 12.0d, 14.0d); - private static final Properties properties = Properties.of() - .instrument(NoteBlockInstrument.BASEDRUM) - .sound(SoundType.WOOL) - .pushReaction(PushReaction.DESTROY) - .strength(0f, 10f) - .noOcclusion(); - - private static final double PARTICLE_OFFSET_RANGE = 0.25; - private static final double PARTICLE_HEIGHT_OFFSET = 1.0; - private static final double PARTICLE_HEIGHT_VARIANCE = 0.2; - private static final float NOTE_COLOR_DIVISOR = 24.0F; - private static final int MAX_NOTE_COLORS = 4; - - private static final float BASE_VOLUME = 1.0f; - private static final float PITCH_VARIANCE = 0.5f; - private static final float BASE_PITCH = 0.75f; + private static final int ROTATIONS = MAX + 1; + /** + * The constant ROTATION. + */ + public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16; /** * Instantiates a new Doll block. */ public DollBlock() { - super(properties); - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.SOUTH) - .setValue(POSE, DollPose.DEFAULT) - .setValue(WATERLOGGED, false)); - } - - @Override - public boolean canBeReplaced(@NotNull BlockState state, @NotNull BlockPlaceContext useContext) { - return false; - } - - @Override - public @NotNull BlockState updateShape(@NotNull BlockState currentState, @NotNull Direction direction, @NotNull BlockState neighborState, - @NotNull LevelAccessor level, @NotNull BlockPos currentPos, @NotNull BlockPos neighborPos) { - if (currentState.getValue(WATERLOGGED)) { - level.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); - } - return super.updateShape(currentState, direction, neighborState, level, currentPos, neighborPos); - } - - @Override - public @NotNull FluidState getFluidState(@NotNull BlockState blockState) { - return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState); - } - - @Override - public @NotNull InteractionResult use(@NotNull BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull Player player, - @NotNull InteractionHand hand, @NotNull BlockHitResult hitResult) { - if (level instanceof ServerLevel serverLevel) { - // 播放粒子效果 - spawnNoteParticles(serverLevel, blockPos); - // 播放音效 - playDollSound(serverLevel, blockPos); - } - return InteractionResult.SUCCESS; - } - - /** - * 在玩偶位置生成音符粒子效果 - */ - private void spawnNoteParticles(ServerLevel serverLevel, BlockPos blockPos) { - Vec3 particlePosition = calculateParticlePosition(serverLevel, blockPos); - float noteColor = calculateNoteColor(serverLevel); - - serverLevel.sendParticles(ParticleTypes.NOTE, - particlePosition.x(), particlePosition.y(), particlePosition.z(), - 0, noteColor, 0, 0, 1); - } - - /** - * 计算粒子生成位置,添加随机偏移 - */ - private @NotNull Vec3 calculateParticlePosition(@NotNull ServerLevel serverLevel, BlockPos blockPos) { - return Vec3.atBottomCenterOf(blockPos).add( - (serverLevel.getRandom().nextFloat() - 0.5) * PARTICLE_OFFSET_RANGE * 2, - PARTICLE_HEIGHT_OFFSET + serverLevel.getRandom().nextFloat() * PARTICLE_HEIGHT_VARIANCE, - (serverLevel.getRandom().nextFloat() - 0.5) * PARTICLE_OFFSET_RANGE * 2 + super(); + this.registerDefaultState( + this.stateDefinition.any() + .setValue(POSE, DollPose.DEFAULT) + .setValue(WATERLOGGED, false) + .setValue(ROTATION, 0) ); } - - /** - * 计算音符粒子的颜色 - */ - private float calculateNoteColor(@NotNull ServerLevel serverLevel) { - return serverLevel.getRandom().nextInt(MAX_NOTE_COLORS) / NOTE_COLOR_DIVISOR; - } - - /** - * 播放玩偶音效 - */ - private void playDollSound(@NotNull ServerLevel serverLevel, BlockPos blockPos) { - float pitch = BASE_PITCH + serverLevel.random.nextFloat() * PITCH_VARIANCE; - serverLevel.playSound(null, blockPos, Lib39SoundEvents.DUCK_TOY.get(), - SoundSource.BLOCKS, BASE_VOLUME, pitch); - } - @Override public @Nullable BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { - FluidState fluidState = context.getLevel().getFluidState(context.getClickedPos()); - boolean isWaterlogged = fluidState.getType() == Fluids.WATER; - - return this.defaultBlockState() - .setValue(FACING, context.getHorizontalDirection().getOpposite()) - .setValue(WATERLOGGED, isWaterlogged) - .setValue(POSE, DollPose.DEFAULT); + BlockState stateForPlacement = super.getStateForPlacement(context); + return stateForPlacement != null ? stateForPlacement.setValue(ROTATION, RotationSegment.convertToSegment((context.getRotation()+180) % 360)) : null; } @Override - public @NotNull VoxelShape getShape(@NotNull BlockState blockState, @NotNull BlockGetter level, @NotNull BlockPos blockPos, @NotNull CollisionContext context) { - return DOLL_SHAPE; + public @NotNull BlockState rotate(@NotNull BlockState state, @NotNull Rotation rotation) { + return state.setValue(ROTATION, rotation.rotate(state.getValue(ROTATION), ROTATIONS)); + } + + @Override + public @NotNull BlockState mirror(@NotNull BlockState state, @NotNull Mirror mirror) { + return state.setValue(ROTATION, mirror.mirror(state.getValue(ROTATION), ROTATIONS)); } @Override protected void createBlockStateDefinition(StateDefinition.@NotNull Builder builder) { super.createBlockStateDefinition(builder); - builder.add(FACING, WATERLOGGED, POSE); - } - - @Nullable - @Override - public BlockEntity newBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState blockState) { - return Lib39BlockEntities.DOLL_BLOCK_ENTITY.get().create(blockPos, blockState); - } - - @SuppressWarnings("deprecation") - @Override - public @NotNull RenderShape getRenderShape(@NotNull BlockState state) { - return RenderShape.ENTITYBLOCK_ANIMATED; - } - - @Override - public ItemStack getCloneItemStack(BlockGetter level, BlockPos pos, BlockState state) { - ItemStack stack = super.getCloneItemStack(level, pos, state); - BlockEntity blockEntity = level.getBlockEntity(pos); - if (blockEntity instanceof DollBlockEntity doll) { - GameProfile profile = doll.getOwnerProfile(); - if (profile != null) { - GameProfileHelper.saveProfileToItemStack(stack, profile); - } - } - return stack; - } - - /** - * 最重要的方法:重写掉落逻辑 - */ - @Override - @NotNull - public List getDrops(@NotNull BlockState state, @NotNull LootParams.Builder params) { - // 获取方块实体 - BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); - - if (blockEntity instanceof DollBlockEntity dollEntity) { - List customDrops = getCustomDrops(dollEntity, params); - if (customDrops != null) return customDrops; - } - return super.getDrops(state, params); - } - - /** - * 生成自定义掉落物 - */ - @Nullable - private List getCustomDrops(DollBlockEntity dollEntity, LootParams.Builder params) { - if (params.getOptionalParameter(LootContextParams.THIS_ENTITY) instanceof Player player) { - if (player.isCreative()) { - return List.of(); - } - } - GameProfile profile = dollEntity.getOwnerProfile(); - if (profile != null) { - ItemStack instance = Lib39Items.DOLL.get().getDefaultInstance(); - GameProfileHelper.saveProfileToItemStack(instance, profile); - return List.of(instance); - } - return null; + builder.add(ROTATION); } } diff --git a/common/src/main/java/top/r3944realms/lib39/content/block/WallDollBlock.java b/common/src/main/java/top/r3944realms/lib39/content/block/WallDollBlock.java new file mode 100644 index 0000000..92d8634 --- /dev/null +++ b/common/src/main/java/top/r3944realms/lib39/content/block/WallDollBlock.java @@ -0,0 +1,56 @@ +package top.r3944realms.lib39.content.block; + +import net.minecraft.core.Direction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import top.r3944realms.lib39.content.block.property.DollPose; + +/** + * The type Wall doll block. + */ +@SuppressWarnings({"deprecation"}) +public class WallDollBlock extends AbstractDollBlock { + /** + * The constant FACING. + */ + public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; + + /** + * Instantiates a new Wall doll block. + */ + public WallDollBlock() { + super(); + this.registerDefaultState( + this.stateDefinition.any() + .setValue(POSE, DollPose.DEFAULT) + .setValue(WATERLOGGED, false) + .setValue(FACING, Direction.NORTH) + ); + } + public @NotNull BlockState rotate(@NotNull BlockState state, @NotNull Rotation rotation) { + return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); + } + + public @NotNull BlockState mirror(@NotNull BlockState state, @NotNull Mirror mirror) { + return state.rotate(mirror.getRotation(state.getValue(FACING))); + } + + @Override + public @Nullable BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { + BlockState stateForPlacement = super.getStateForPlacement(context); + return stateForPlacement != null ? stateForPlacement.setValue(FACING, context.getHorizontalDirection().getOpposite()) : null; + } + + protected void createBlockStateDefinition(StateDefinition.@NotNull Builder builder) { + super.createBlockStateDefinition(builder); + builder.add(FACING); + } +} diff --git a/common/src/main/java/top/r3944realms/lib39/content/item/DollItem.java b/common/src/main/java/top/r3944realms/lib39/content/item/DollItem.java index 8fdc61c..8f3319b 100644 --- a/common/src/main/java/top/r3944realms/lib39/content/item/DollItem.java +++ b/common/src/main/java/top/r3944realms/lib39/content/item/DollItem.java @@ -1,11 +1,12 @@ package top.r3944realms.lib39.content.item; import com.mojang.authlib.GameProfile; +import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Equipable; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.StandingAndWallBlockItem; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; @@ -18,14 +19,14 @@ import java.util.List; /** * The type Doll item. */ -public class DollItem extends BlockItem implements Equipable { +public class DollItem extends StandingAndWallBlockItem implements Equipable { /** * Instantiates a new Doll item. * * @param properties the properties */ public DollItem(Properties properties) { - super(Lib39Blocks.DOLL.get(), properties); + super(Lib39Blocks.DOLL.get(), Lib39Blocks.WALL_DOLL.get(), properties, Direction.DOWN); } diff --git a/common/src/main/java/top/r3944realms/lib39/core/register/Lib39Blocks.java b/common/src/main/java/top/r3944realms/lib39/core/register/Lib39Blocks.java index a3d3710..9fb5757 100644 --- a/common/src/main/java/top/r3944realms/lib39/core/register/Lib39Blocks.java +++ b/common/src/main/java/top/r3944realms/lib39/core/register/Lib39Blocks.java @@ -13,5 +13,9 @@ public class Lib39Blocks { * The constant DOLL. */ public static Supplier DOLL; + /** + * The Wall doll. + */ + public static Supplier WALL_DOLL; } diff --git a/fabric/build.gradle b/fabric/build.gradle index b3116c9..9f43bab 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -4,6 +4,9 @@ plugins { id 'multiloader-loader' id 'fabric-loom' } +repositories { + maven { url 'https://maven.covers1624.net/' } +} dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" mappings loom.layered { @@ -18,6 +21,7 @@ dependencies { implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' implementation project(":common") testImplementation "net.fabricmc:fabric-loader-junit:${fabric_loader_version}" + localRuntime 'net.covers1624:DevLogin:0.1.0.5' } loom { @@ -36,10 +40,13 @@ loom { runs { client { client() + client() + ideConfigGenerated true + programArgs '--launch_target', 'net.fabricmc.loader.impl.launch.knot.KnotClient' + mainClass.set 'net.covers1624.devlogin.DevLogin' setConfigName("Fabric Client") ideConfigGenerated(true) runDir("run") - programArgs "--username", "R3944Realms" def args = [ "-Dlib39.modid=${mod_id}".toString(), "-Dlib39.output=${generatedOutput}".toString(), @@ -74,9 +81,6 @@ loom { ] vmArgs.addAll(args) } - gameTest { - - } } } diff --git a/fabric/src/main/java/top/r3944realms/lib39/Lib39Fabric.java b/fabric/src/main/java/top/r3944realms/lib39/Lib39Fabric.java index b52e301..cb73020 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/Lib39Fabric.java +++ b/fabric/src/main/java/top/r3944realms/lib39/Lib39Fabric.java @@ -8,6 +8,9 @@ import top.r3944realms.lib39.core.register.FabricLib39Items; import top.r3944realms.lib39.core.register.FabricLib39SoundEvents; import top.r3944realms.lib39.example.FabricLib39Example; +/** + * The type Lib 39 fabric. + */ public class Lib39Fabric implements ModInitializer { @Override diff --git a/fabric/src/main/java/top/r3944realms/lib39/Lib39FabricClient.java b/fabric/src/main/java/top/r3944realms/lib39/Lib39FabricClient.java index c324c0b..1f98a86 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/Lib39FabricClient.java +++ b/fabric/src/main/java/top/r3944realms/lib39/Lib39FabricClient.java @@ -9,6 +9,9 @@ import top.r3944realms.lib39.client.ShaderRegistry; import top.r3944realms.lib39.core.event.FabricCommonEventHandler; import top.r3944realms.lib39.core.network.FabricNetworkHandler; +/** + * The type Lib 39 fabric client. + */ public class Lib39FabricClient implements ClientModInitializer { @Override public void onInitializeClient() { diff --git a/fabric/src/main/java/top/r3944realms/lib39/api/callback/AnvilUpdateCallback.java b/fabric/src/main/java/top/r3944realms/lib39/api/callback/AnvilUpdateCallback.java index d2dd26f..45a07f3 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/api/callback/AnvilUpdateCallback.java +++ b/fabric/src/main/java/top/r3944realms/lib39/api/callback/AnvilUpdateCallback.java @@ -17,41 +17,68 @@ public class AnvilUpdateCallback { public interface AnvilUpdate { /** * 当铁砧内容改变时调用 - * @param left 左侧输入槽的物品 - * @param right 右侧输入槽的物品 + * + * @param left 左侧输入槽的物品 + * @param right 右侧输入槽的物品 * @param outputSlot 输出槽的物品 - * @param name 输入的名字 - * @param baseCost 基础花费 - * @param player 玩家 + * @param name 输入的名字 + * @param baseCost 基础花费 + * @param player 玩家 * @return AnvilUpdateResult 包含处理结果,如果返回null则继续默认处理 */ AnvilUpdateResult onAnvilUpdate(ItemStack left, ItemStack right, ItemStack outputSlot, String name, int baseCost, Player player); } - /** + /** * 铁砧更新结果 */ public record AnvilUpdateResult(ItemStack output, int cost, int materialCost, boolean cancel) { + /** + * Cancelled anvil update result. + * + * @return the anvil update result + */ public static AnvilUpdateResult cancelled() { return new AnvilUpdateResult(ItemStack.EMPTY, 0, 0, true); } - public static AnvilUpdateResult passed() { + /** + * Passed anvil update result. + * + * @return the anvil update result + */ + public static AnvilUpdateResult passed() { return new AnvilUpdateResult(ItemStack.EMPTY, 0, 0, false); } - public static AnvilUpdateResult withOutput(ItemStack output, int cost, int materialCost) { + /** + * With output anvil update result. + * + * @param output the output + * @param cost the cost + * @param materialCost the material cost + * @return the anvil update result + */ + public static AnvilUpdateResult withOutput(ItemStack output, int cost, int materialCost) { return new AnvilUpdateResult(output, cost, materialCost, false); } + /** + * Should override boolean. + * + * @return the boolean + */ public boolean shouldOverride() { return !output.isEmpty(); } } - // 创建事件实例 + /** + * The constant EVENT. + */ +// 创建事件实例 public static final Event EVENT = EventFactory.createArrayBacked( AnvilUpdate.class, (listeners) -> (left, right, outputSlot, name, baseCost, player) -> { diff --git a/fabric/src/main/java/top/r3944realms/lib39/api/callback/MinecraftSetUpServiceCallback.java b/fabric/src/main/java/top/r3944realms/lib39/api/callback/MinecraftSetUpServiceCallback.java index 1a9f87f..aefca7d 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/api/callback/MinecraftSetUpServiceCallback.java +++ b/fabric/src/main/java/top/r3944realms/lib39/api/callback/MinecraftSetUpServiceCallback.java @@ -33,7 +33,7 @@ public interface MinecraftSetUpServiceCallback { * * @param services the services * @param mainThreadExecutor the main thread executor - * @return 结果枚举 + * @return 结果枚举 action result */ ActionResult load(Services services, Executor mainThreadExecutor); } diff --git a/fabric/src/main/java/top/r3944realms/lib39/api/callback/RegisterCommandHelpCallback.java b/fabric/src/main/java/top/r3944realms/lib39/api/callback/RegisterCommandHelpCallback.java index 8eb7336..27cd51e 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/api/callback/RegisterCommandHelpCallback.java +++ b/fabric/src/main/java/top/r3944realms/lib39/api/callback/RegisterCommandHelpCallback.java @@ -12,9 +12,19 @@ import top.r3944realms.lib39.core.command.model.CommandNode; import top.r3944realms.lib39.core.command.model.CommandPath; import top.r3944realms.lib39.core.command.model.Parameter; +/** + * The interface Register command help callback. + */ @FunctionalInterface public interface RegisterCommandHelpCallback { + /** + * Register action result. + * + * @param registrar the registrar + * @return the action result + */ ActionResult register(RegisterCommandHelpCallback.Registrar registrar); + /** * 创建 Event 实例 */ @@ -30,6 +40,10 @@ public interface RegisterCommandHelpCallback { return ActionResult.PASS; } ); + + /** + * The interface Registrar. + */ interface Registrar { /** * Gets id. @@ -66,6 +80,7 @@ public interface RegisterCommandHelpCallback { * @param description 命令描述 */ void registerHelp(CommandNode CommandNode, MutableComponent description); + /** * 注册命令帮助信息 * @@ -73,6 +88,7 @@ public interface RegisterCommandHelpCallback { * @param descriptionKey 命令描述的语言键 */ void registerHelp(CommandNode CommandNode, String descriptionKey); + /** * 注册命令参数 * @@ -81,6 +97,10 @@ public interface RegisterCommandHelpCallback { */ void registerParameters(CommandPath commandPath, Parameter.Builder parametersBuilder); } + + /** + * The type Command help registrar. + */ record CommandHelpRegistrar(LiteralArgumentBuilder builder, ICommandHelpManager helpManager, CommandBuildContext context) implements Registrar { @Override public ResourceLocation getID() { diff --git a/fabric/src/main/java/top/r3944realms/lib39/api/callback/SyncManagerRegisterCallback.java b/fabric/src/main/java/top/r3944realms/lib39/api/callback/SyncManagerRegisterCallback.java index 9e34e6a..87bffc4 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/api/callback/SyncManagerRegisterCallback.java +++ b/fabric/src/main/java/top/r3944realms/lib39/api/callback/SyncManagerRegisterCallback.java @@ -21,6 +21,7 @@ public interface SyncManagerRegisterCallback { * 注册同步管理器的回调方法 * * @param registrar 注册器实例 + * @return the action result */ ActionResult registerSyncManagers(Registrar registrar); @@ -47,6 +48,8 @@ public interface SyncManagerRegisterCallback { /** * 获取 Fabric 同步管理器实例 + * + * @return the sync data 2 lookup manager */ SyncData2LookupManager manager(); @@ -120,6 +123,10 @@ public interface SyncManagerRegisterCallback { } } } + + /** + * The type Sync manager registrar. + */ record SyncManagerRegistrar( SyncData2LookupManager manager) implements SyncManagerRegisterCallback.Registrar { diff --git a/fabric/src/main/java/top/r3944realms/lib39/api/callback/client/ClientWorldCallback.java b/fabric/src/main/java/top/r3944realms/lib39/api/callback/client/ClientWorldCallback.java index 57d06ce..4de0472 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/api/callback/client/ClientWorldCallback.java +++ b/fabric/src/main/java/top/r3944realms/lib39/api/callback/client/ClientWorldCallback.java @@ -4,25 +4,50 @@ import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; import net.minecraft.client.multiplayer.ClientLevel; +/** + * The interface Client world callback. + */ public interface ClientWorldCallback { + /** + * The constant LOAD. + */ Event LOAD = EventFactory.createArrayBacked(ClientWorldCallback.Load.class, (callbacks) -> (world) -> { for (Load callback : callbacks) { callback.onWorldLoad(world); } }); + /** + * The constant UNLOAD. + */ Event UNLOAD = EventFactory.createArrayBacked(ClientWorldCallback.Unload.class, (callbacks) -> (world) -> { for (Unload callback : callbacks) { callback.onWorldUnload(world); } }); + /** + * The interface Unload. + */ @FunctionalInterface interface Unload { + /** + * On world unload. + * + * @param clientLevel the client level + */ void onWorldUnload(ClientLevel clientLevel); } + /** + * The interface Load. + */ @FunctionalInterface interface Load { + /** + * On world load. + * + * @param clientLevel the client level + */ void onWorldLoad(ClientLevel clientLevel); } } diff --git a/fabric/src/main/java/top/r3944realms/lib39/client/BlockEntityRendererRegistry.java b/fabric/src/main/java/top/r3944realms/lib39/client/BlockEntityRendererRegistry.java index 13a1741..b1e85ce 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/client/BlockEntityRendererRegistry.java +++ b/fabric/src/main/java/top/r3944realms/lib39/client/BlockEntityRendererRegistry.java @@ -4,7 +4,13 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import top.r3944realms.lib39.client.renderer.block.DollBlockEntityRenderer; import top.r3944realms.lib39.core.register.Lib39BlockEntities; +/** + * The type Block entity renderer registry. + */ public class BlockEntityRendererRegistry { + /** + * Register. + */ public static void register() { BlockEntityRenderers.register( Lib39BlockEntities.DOLL_BLOCK_ENTITY.get(), diff --git a/fabric/src/main/java/top/r3944realms/lib39/client/ItemRendererRegistry.java b/fabric/src/main/java/top/r3944realms/lib39/client/ItemRendererRegistry.java index e57402b..63c52dd 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/client/ItemRendererRegistry.java +++ b/fabric/src/main/java/top/r3944realms/lib39/client/ItemRendererRegistry.java @@ -4,7 +4,13 @@ import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry; import top.r3944realms.lib39.client.renderer.item.DollItemRenderer; import top.r3944realms.lib39.core.register.Lib39Items; +/** + * The type Item renderer registry. + */ public class ItemRendererRegistry { + /** + * Register. + */ public static void register() { BuiltinItemRendererRegistry.INSTANCE.register( Lib39Items.DOLL.get(), diff --git a/fabric/src/main/java/top/r3944realms/lib39/client/LayerDefinitionRegistry.java b/fabric/src/main/java/top/r3944realms/lib39/client/LayerDefinitionRegistry.java index 2c9cfe9..d26df64 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/client/LayerDefinitionRegistry.java +++ b/fabric/src/main/java/top/r3944realms/lib39/client/LayerDefinitionRegistry.java @@ -3,7 +3,13 @@ package top.r3944realms.lib39.client; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; import top.r3944realms.lib39.client.model.DollModel; +/** + * The type Layer definition registry. + */ public class LayerDefinitionRegistry { + /** + * Register. + */ public static void register() { EntityModelLayerRegistry.registerModelLayer( DollModel.LAYER_LOCATION, DollModel::createBodyLayer diff --git a/fabric/src/main/java/top/r3944realms/lib39/client/ShaderRegistry.java b/fabric/src/main/java/top/r3944realms/lib39/client/ShaderRegistry.java index c481bd1..7cfe34b 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/client/ShaderRegistry.java +++ b/fabric/src/main/java/top/r3944realms/lib39/client/ShaderRegistry.java @@ -5,7 +5,13 @@ import net.fabricmc.fabric.api.client.rendering.v1.CoreShaderRegistrationCallbac import top.r3944realms.lib39.Lib39; import top.r3944realms.lib39.client.shader.Lib39Shaders; +/** + * The type Shader registry. + */ public class ShaderRegistry { + /** + * Register. + */ public static void register() { CoreShaderRegistrationCallback.EVENT.register( context -> { context.register( diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/event/FabricCommonEventHandler.java b/fabric/src/main/java/top/r3944realms/lib39/core/event/FabricCommonEventHandler.java index 54d9405..acc02ee 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/event/FabricCommonEventHandler.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/event/FabricCommonEventHandler.java @@ -44,7 +44,13 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; +/** + * The type Fabric common event handler. + */ public class FabricCommonEventHandler { + /** + * The Sync data 2 manager. + */ static volatile SyncData2LookupManager syncData2Manager; private static boolean isSync2MInitialized = false; private static ServerLevel sl; @@ -57,6 +63,7 @@ public class FabricCommonEventHandler { public static ServerLevel getServerLevel() { return sl; } + /** * Gets sync data 2 manager. * @@ -65,6 +72,13 @@ public class FabricCommonEventHandler { public static SyncData2LookupManager getSyncData2Manager() { return syncData2Manager; } + + /** + * On server world load. + * + * @param server the server + * @param serverLevel the server level + */ public static void onServerWorldLoad(MinecraftServer server, ServerLevel serverLevel) { if (!serverLevel.dimension().equals(Level.OVERWORLD)) return; synchronized (FabricCommonEventHandler.class) { @@ -80,6 +94,12 @@ public class FabricCommonEventHandler { } + /** + * On server world un load. + * + * @param server the server + * @param serverLevel the server level + */ public static void onServerWorldUnLoad(MinecraftServer server, @NotNull ServerLevel serverLevel) { if (!serverLevel.dimension().equals(Level.OVERWORLD)) return; sl = null; @@ -87,6 +107,11 @@ public class FabricCommonEventHandler { isSync2MInitialized = false; } + /** + * On server tick. + * + * @param server the server + */ public static void onServerTick(MinecraftServer server) { if (syncData2Manager == null) return; if (server.getTickCount() % 10 == 0) @@ -94,6 +119,12 @@ public class FabricCommonEventHandler { syncData2Manager.forEach(((resourceLocation, iSyncManager) -> iSyncManager.foreach(ISyncData::checkIfDirtyThenUpdate))); } + /** + * On entity join world. + * + * @param entity the entity + * @param level the level + */ public static void onEntityJoinWorld(@NotNull Entity entity, ServerLevel level) { if (entity.level().isClientSide) return; @@ -104,6 +135,12 @@ public class FabricCommonEventHandler { } } + /** + * On entity leave world. + * + * @param entity the entity + * @param level the level + */ public static void onEntityLeaveWorld(@NotNull Entity entity, ServerLevel level) { if (entity.level().isClientSide) return; @@ -115,6 +152,7 @@ public class FabricCommonEventHandler { } private static final Map, ResourceKey[]> itemAddMap = new ConcurrentHashMap<>(); private static final Map, List>> tabToItemsMap = new ConcurrentHashMap<>(); + /** * Add item to tabs. * @@ -131,6 +169,9 @@ public class FabricCommonEventHandler { } } + /** + * Init common. + */ public static void initCommon() { try { Class.forName("top.r3944realms.lib39.base.command.Lib39CommandHelpManager"); @@ -166,7 +207,16 @@ public class FabricCommonEventHandler { new Lib39HelpCommand(commandDispatcher, commandBuildContext); }); } + + /** + * The type Client opt. + */ public static class ClientOpt implements IClientOnly { + /** + * On client world load. + * + * @param clientLevel the client level + */ public static void onClientWorldLoad(@NotNull ClientLevel clientLevel) { synchronized (FabricCommonEventHandler.ClientOpt.class) { IClientOnly.check(() -> { @@ -180,6 +230,12 @@ public class FabricCommonEventHandler { }); } } + + /** + * On client world un load. + * + * @param clientLevel the client level + */ public static void onClientWorldUnLoad(@NotNull ClientLevel clientLevel) { synchronized (FabricCommonEventHandler.ClientOpt.class) { IClientOnly.check(() -> ILevelHelper.LevelHelper.CLIENT.setLevel(null)); @@ -187,6 +243,9 @@ public class FabricCommonEventHandler { } } + /** + * Init client. + */ public static void initClient() { ClientWorldCallback.LOAD.register(ClientOpt::onClientWorldLoad); ClientWorldCallback.LOAD.register(ClientOpt::onClientWorldUnLoad); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/network/FabricNetworkHandler.java b/fabric/src/main/java/top/r3944realms/lib39/core/network/FabricNetworkHandler.java index 04f9479..5d4178d 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/network/FabricNetworkHandler.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/network/FabricNetworkHandler.java @@ -3,6 +3,9 @@ package top.r3944realms.lib39.core.network; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import top.r3944realms.lib39.core.network.toClient.SyncNBTLookupDataEntityS2CPacket; +/** + * The type Fabric network handler. + */ public class FabricNetworkHandler { /** diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/network/toClient/SyncNBTLookupDataEntityS2CPacket.java b/fabric/src/main/java/top/r3944realms/lib39/core/network/toClient/SyncNBTLookupDataEntityS2CPacket.java index 3183e28..53b170d 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/network/toClient/SyncNBTLookupDataEntityS2CPacket.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/network/toClient/SyncNBTLookupDataEntityS2CPacket.java @@ -19,13 +19,23 @@ import top.r3944realms.lib39.core.sync.SyncData2Manager; import java.util.Optional; +/** + * The type Sync nbt lookup data entity s 2 c packet. + */ public record SyncNBTLookupDataEntityS2CPacket(int entityId, ResourceLocation id, CompoundTag data) implements FabricPacket { + /** + * The constant SYNC_NBT_LOOKUP_PACKET_ID. + */ public static final ResourceLocation SYNC_NBT_LOOKUP_PACKET_ID = Lib39.rl("sync_nbt_lookup_data_entity"); + /** + * The constant TYPE. + */ public static final PacketType TYPE = PacketType.create( SYNC_NBT_LOOKUP_PACKET_ID, buf -> new SyncNBTLookupDataEntityS2CPacket(buf.readInt(), buf.readResourceLocation(), buf.readNbt()) ); + /** * Instantiates a new Sync nbt data s 2 c pack. * @@ -50,6 +60,13 @@ public record SyncNBTLookupDataEntityS2CPacket(int entityId, ResourceLocation id } + /** + * Receive. + * + * @param packet the packet + * @param localPlayer the local player + * @param packetSender the packet sender + */ public static void receive(@NotNull SyncNBTLookupDataEntityS2CPacket packet, @NotNull LocalPlayer localPlayer, PacketSender packetSender) { Level level = localPlayer.level(); Entity entity = level.getEntity(packet.entityId); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39BlockEntities.java b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39BlockEntities.java index 0ff87c1..02899b3 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39BlockEntities.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39BlockEntities.java @@ -14,13 +14,25 @@ import java.util.function.Supplier; * The type Lib 39 block entities. */ public class FabricLib39BlockEntities { + /** + * Init. + */ @SuppressWarnings("DataFlowIssue") public static void init() { Lib39BlockEntities.DOLL_BLOCK_ENTITY = register("doll", BlockEntityType.Builder - .of(DollBlockEntity::new, Lib39Blocks.DOLL.get()) + .of(DollBlockEntity::new, Lib39Blocks.DOLL.get(), Lib39Blocks.WALL_DOLL.get()) .build(null) ); } + + /** + * Register @ not null supplier. + * + * @param the type parameter + * @param path the path + * @param blockEntityType the block entity type + * @return the @ not null supplier + */ @Contract(pure = true) public static > @NotNull Supplier register(String path, T blockEntityType) { T item = Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Lib39.rl(path), blockEntityType); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Blocks.java b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Blocks.java index 8d206f6..3bd1eaf 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Blocks.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Blocks.java @@ -7,6 +7,7 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import top.r3944realms.lib39.Lib39; import top.r3944realms.lib39.content.block.DollBlock; +import top.r3944realms.lib39.content.block.WallDollBlock; import top.r3944realms.lib39.util.block.BlockRegistryBuilder; import java.util.function.Supplier; @@ -15,13 +16,30 @@ import java.util.function.Supplier; * The type Lib 39 blocks. */ public class FabricLib39Blocks { - public static void init() { + /** + * Init. + */ + public static void init() { Lib39Blocks.DOLL = BlockRegistryBuilder .create() .withName("doll") .registerBlock((name , block) -> register(name, block.get()), DollBlock::new) .build(); + Lib39Blocks.WALL_DOLL = BlockRegistryBuilder + .create() + .withName("wall_doll") + .registerBlock((name , block) -> register(name, block.get()), WallDollBlock::new) + .build(); } + + /** + * Register @ not null supplier. + * + * @param the type parameter + * @param path the path + * @param block the block + * @return the @ not null supplier + */ @Contract(pure = true) public static @NotNull Supplier register(String path, T block) { T item = Registry.register(BuiltInRegistries.BLOCK, Lib39.rl(path), block); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Items.java b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Items.java index 34d21e0..94fff57 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Items.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39Items.java @@ -14,9 +14,21 @@ import java.util.function.Supplier; * The type Ex lib 39 items. */ public class FabricLib39Items { + /** + * Init. + */ public static void init() { Lib39Items.DOLL = register("doll", new DollItem(new Item.Properties())); } + + /** + * Register @ not null supplier. + * + * @param the type parameter + * @param path the path + * @param item the item + * @return the @ not null supplier + */ @Contract(pure = true) public static @NotNull Supplier register(String path, T item) { T register = Registry.register(BuiltInRegistries.ITEM, Lib39.rl(path), item); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39SoundEvents.java b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39SoundEvents.java index 2b8d503..7f647c0 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39SoundEvents.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/register/FabricLib39SoundEvents.java @@ -13,9 +13,21 @@ import java.util.function.Supplier; * The type Lib 39 sound events. */ public class FabricLib39SoundEvents { + /** + * Init. + */ public static void init() { Lib39SoundEvents.DUCK_TOY = register("duck_toy", SoundEvent.createFixedRangeEvent(Lib39SoundEvents.RL_DUCK_TOY, 32.0f)); } + + /** + * Register @ not null supplier. + * + * @param the type parameter + * @param path the path + * @param soundEvent the sound event + * @return the @ not null supplier + */ @Contract(pure = true) public static @NotNull Supplier register(String path, T soundEvent) { T register = Registry.register(BuiltInRegistries.SOUND_EVENT, Lib39.rl(path), soundEvent); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/sync/IEntityApiLookUpImplExtend.java b/fabric/src/main/java/top/r3944realms/lib39/core/sync/IEntityApiLookUpImplExtend.java index 26eb719..58afba3 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/sync/IEntityApiLookUpImplExtend.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/sync/IEntityApiLookUpImplExtend.java @@ -2,6 +2,19 @@ package top.r3944realms.lib39.core.sync; import net.minecraft.world.entity.Entity; +/** + * The interface Entity api look up impl extend. + * + * @param the type parameter + * @param the type parameter + */ public interface IEntityApiLookUpImplExtend { + /** + * Lib 39 find without check a. + * + * @param entity the entity + * @param context the context + * @return the a + */ A lib39$findWithoutCheck(Entity entity, C context); } diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/sync/IFabricUpdate.java b/fabric/src/main/java/top/r3944realms/lib39/core/sync/IFabricUpdate.java index 38fe50a..5b799b2 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/sync/IFabricUpdate.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/sync/IFabricUpdate.java @@ -9,6 +9,9 @@ import top.r3944realms.lib39.core.network.toClient.SyncNBTLookupDataEntityS2CPac import java.util.List; +/** + * The interface Fabric update. + */ public interface IFabricUpdate extends IUpdate { default void update() { ServerLevel serverLevel = FabricCommonEventHandler.getServerLevel(); diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/sync/ILib39SyncDataHolder.java b/fabric/src/main/java/top/r3944realms/lib39/core/sync/ILib39SyncDataHolder.java index d988f29..64a36bc 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/sync/ILib39SyncDataHolder.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/sync/ILib39SyncDataHolder.java @@ -5,9 +5,30 @@ import net.minecraft.nbt.Tag; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; +/** + * The interface Lib 39 sync data holder. + */ public interface ILib39SyncDataHolder { + /** + * Lib 39 get sync data compound tag. + * + * @return the compound tag + */ CompoundTag lib39$getSyncData(); + + /** + * Lib 39 set sync data. + * + * @param tag the tag + */ void lib39$setSyncData(CompoundTag tag); + + /** + * Lib 39 inject save sync data compound tag. + * + * @param tag the tag + * @return the compound tag + */ default CompoundTag lib39$injectSaveSyncData(CompoundTag tag) { if (lib39$getSyncData() != null && !lib39$getSyncData().isEmpty()) { tag.put("Lib39Data", lib39$getSyncData()); @@ -15,22 +36,43 @@ public interface ILib39SyncDataHolder { return tag; } + /** + * Lib 39 inject load sync data. + * + * @param tag the tag + */ default void lib39$injectLoadSyncData(@NotNull CompoundTag tag) { if (tag.contains("Lib39Data", Tag.TAG_COMPOUND)) { lib39$setSyncData(tag.getCompound("Lib39Data")); } } + /** + * Save sync data. + * + * @param syncData the sync data + */ default void saveSyncData(@NotNull NBTEntitySyncData syncData) { lib39$getSyncData().put(syncData.id.toDebugFileName(), syncData.serializeNBT()); } + /** + * Load sync data. + * + * @param syncData the sync data + */ default void loadSyncData(NBTEntitySyncData syncData) { if (syncData != null && lib39$getSyncData().contains(syncData.id.toDebugFileName())) { syncData.deserializeNBT(lib39$getSyncData().getCompound(syncData.id.toDebugFileName())); } } + /** + * Gets holder. + * + * @param entity the entity + * @return the holder + */ static ILib39SyncDataHolder getHolder(Entity entity) { return (ILib39SyncDataHolder) entity; } diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncData2LookupManager.java b/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncData2LookupManager.java index 191bb57..6461f1e 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncData2LookupManager.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncData2LookupManager.java @@ -10,7 +10,13 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +/** + * The type Sync data 2 lookup manager. + */ public class SyncData2LookupManager extends SyncData2Manager>> { + /** + * The Typed entries. + */ protected final Map> typedEntries = Maps.newConcurrentMap(); @Override @@ -18,12 +24,17 @@ public class SyncData2LookupManager extends SyncData2Manager the type parameter + */ protected static class TypedSyncEntry> extends SyncData2Manager.TypedSyncEntry { /** * Instantiates a new Typed sync entry for Fabric * - * @param manager the manager - * @param apiLookup the EntityApiLookup instance + * @param manager the manager + * @param apiLookup the EntityApiLookup instance */ @SuppressWarnings("unchecked") public TypedSyncEntry(ISyncManager manager, @Nullable EntityApiLookup apiLookup) { @@ -40,10 +51,10 @@ public class SyncData2LookupManager extends SyncData2Manager the type parameter - * @param key the key - * @param manager the manager - * @param dataClass the data class + * @param the type parameter + * @param key the key + * @param manager the manager + * @param dataClass the data class */ public > void registerManager( ResourceLocation key, @@ -62,9 +73,9 @@ public class SyncData2LookupManager extends SyncData2Manager the type parameter - * @param key the key - * @param apiLookup the EntityApiLookup + * @param the type parameter + * @param key the key + * @param apiLookup the EntityApiLookup */ public > void bindApiLookup(ResourceLocation key, EntityApiLookup apiLookup) { Objects.requireNonNull(key, "ResourceLocation key cannot be null"); @@ -94,6 +105,11 @@ public class SyncData2LookupManager extends SyncData2Manager the type parameter + * @param id the id + * @param entry the entry + * @param newApiLookup the new api lookup */ protected > void updateApiLookupInEntry( ResourceLocation id, diff --git a/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncLookupProvider.java b/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncLookupProvider.java index 8612e54..fc6240e 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncLookupProvider.java +++ b/fabric/src/main/java/top/r3944realms/lib39/core/sync/SyncLookupProvider.java @@ -6,8 +6,25 @@ import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.Nullable; import top.r3944realms.lib39.core.event.FabricCommonEventHandler; +/** + * The type Sync lookup provider. + * + * @param the type parameter + */ public abstract class SyncLookupProvider implements EntityApiLookup.EntityApiProvider { + /** + * Create empty lookup t. + * + * @param entity the entity + * @return the t + */ protected abstract T createEmptyLookup(Entity entity); + + /** + * Gets id. + * + * @return the id + */ protected abstract ResourceLocation getId(); @SuppressWarnings("unchecked") @Override diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/FabricLib39Example.java b/fabric/src/main/java/top/r3944realms/lib39/example/FabricLib39Example.java index 9fb1e47..dbed3fd 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/FabricLib39Example.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/FabricLib39Example.java @@ -6,8 +6,12 @@ import top.r3944realms.lib39.example.core.event.FabricExCommonEventHandler; import top.r3944realms.lib39.example.core.network.FabricExNetworkHandler; import top.r3944realms.lib39.example.core.register.FabricExLib39Items; +/** + * The type Fabric lib 39 example. + */ public class FabricLib39Example { private static boolean registered = false; + /** * Instantiates a new Lib 39 example. */ @@ -17,6 +21,10 @@ public class FabricLib39Example { registered = true; } } + + /** + * Init. + */ public void init() { FabricExCommonEventHandler.init(); FabricExLib39Items.init(); diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/content/data/FabricTestSyncLookupProvider.java b/fabric/src/main/java/top/r3944realms/lib39/example/content/data/FabricTestSyncLookupProvider.java index a9e68e4..0a8155c 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/content/data/FabricTestSyncLookupProvider.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/content/data/FabricTestSyncLookupProvider.java @@ -4,7 +4,13 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import top.r3944realms.lib39.core.sync.SyncLookupProvider; +/** + * The type Fabric test sync lookup provider. + */ public class FabricTestSyncLookupProvider extends SyncLookupProvider { + /** + * The constant INSTANCE. + */ public static final FabricTestSyncLookupProvider INSTANCE = new FabricTestSyncLookupProvider(); @Override diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricFabricItem.java b/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricFabricItem.java index 2b332d5..cd54ed7 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricFabricItem.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricFabricItem.java @@ -13,8 +13,16 @@ import top.r3944realms.lib39.example.content.data.AbstractedTestSyncData; import top.r3944realms.lib39.example.content.data.FabricTestSyncData; import top.r3944realms.lib39.example.core.network.FabricClientDataPacket; +/** + * The type Fabric fabric item. + */ public class FabricFabricItem extends AbstractFabricItem { + /** + * Instantiates a new Fabric fabric item. + * + * @param properties the properties + */ public FabricFabricItem(Properties properties) { super(properties); } @@ -31,6 +39,12 @@ public class FabricFabricItem extends AbstractFabricItem { } } + /** + * Gets static data. + * + * @param target the target + * @return the static data + */ public static @Nullable AbstractedTestSyncData getStaticData(Entity target) { try { AbstractedTestSyncData abstractData = EntityApiLookup.get(FabricTestSyncData.ID, AbstractedTestSyncData.class, Void.class).find(target, null); @@ -43,6 +57,13 @@ public class FabricFabricItem extends AbstractFabricItem { return null; } + /** + * Handle client data from packet. + * + * @param player the player + * @param clientData the client data + * @param targetEntityId the target entity id + */ public static void handleClientDataFromPacket(@NotNull ServerPlayer player, AbstractedTestSyncData clientData, int targetEntityId) { Entity target = player.level().getEntity(targetEntityId); diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricNeoForgeItem.java b/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricNeoForgeItem.java index 35ac285..1645b8b 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricNeoForgeItem.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/content/item/FabricNeoForgeItem.java @@ -5,8 +5,16 @@ import net.minecraft.world.entity.Entity; import top.r3944realms.lib39.example.content.data.AbstractedTestSyncData; import top.r3944realms.lib39.example.content.data.FabricTestSyncData; +/** + * The type Fabric neo forge item. + */ public class FabricNeoForgeItem extends AbstractNeoForgeItem { + /** + * Instantiates a new Fabric neo forge item. + * + * @param properties the properties + */ public FabricNeoForgeItem(Properties properties) { super(properties); } diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39Compat.java b/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39Compat.java index 71a2107..c41cd4b 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39Compat.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39Compat.java @@ -9,7 +9,10 @@ import top.r3944realms.lib39.core.compat.ICompat; * The type Lib 39 compat. */ public class FabricLib39Compat implements ICompat { - boolean initialized = false; + /** + * The Initialized. + */ + boolean initialized = false; /** * The constant INSTANCE. */ diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39CompatManager.java b/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39CompatManager.java index 81a3436..a9663c7 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39CompatManager.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/core/compat/FabricLib39CompatManager.java @@ -3,6 +3,9 @@ package top.r3944realms.lib39.example.core.compat; import top.r3944realms.lib39.Lib39; import top.r3944realms.lib39.core.compat.CompatManager; +/** + * The type Fabric lib 39 compat manager. + */ public class FabricLib39CompatManager extends CompatManager { /** * Instantiates a new Compat manager. diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/core/event/FabricExCommonEventHandler.java b/fabric/src/main/java/top/r3944realms/lib39/example/core/event/FabricExCommonEventHandler.java index 7fe0e04..fb97039 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/core/event/FabricExCommonEventHandler.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/core/event/FabricExCommonEventHandler.java @@ -14,6 +14,9 @@ import top.r3944realms.lib39.example.core.compat.FabricLib39CompatManager; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +/** + * The type Fabric ex common event handler. + */ public class FabricExCommonEventHandler { /** * Gets compat manager. @@ -35,6 +38,10 @@ public class FabricExCommonEventHandler { * The Compat manager. */ static volatile CompatManager compatManager; + + /** + * Init. + */ public static void init() { SyncManagerRegisterCallback.EVENT.register(registrar -> { registrar.register( diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricClientDataPacket.java b/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricClientDataPacket.java index e7ad484..ed53995 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricClientDataPacket.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricClientDataPacket.java @@ -16,8 +16,14 @@ import top.r3944realms.lib39.example.content.item.FabricFabricItem; * The type Client data packet. */ public class FabricClientDataPacket implements FabricPacket { + /** + * The constant CLIENT_TEST_DATA. + */ public static final ResourceLocation CLIENT_TEST_DATA = Lib39.rl("client_test_data"); + /** + * The constant TYPE. + */ public static final PacketType TYPE = PacketType.create( CLIENT_TEST_DATA, FabricClientDataPacket::new @@ -58,6 +64,13 @@ public class FabricClientDataPacket implements FabricPacket { return TYPE; } + /** + * Receive. + * + * @param packet the packet + * @param serverPlayer the server player + * @param packetSender the packet sender + */ public static void receive(@NotNull FabricClientDataPacket packet, @NotNull ServerPlayer serverPlayer, PacketSender packetSender) { FabricFabricItem.handleClientDataFromPacket(serverPlayer, packet.clientData, packet.targetEntityId); } diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricExNetworkHandler.java b/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricExNetworkHandler.java index b128bff..4eb696a 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricExNetworkHandler.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/core/network/FabricExNetworkHandler.java @@ -2,6 +2,9 @@ package top.r3944realms.lib39.example.core.network; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +/** + * The type Fabric ex network handler. + */ public class FabricExNetworkHandler { /** * 注册服务器接收的数据包 diff --git a/fabric/src/main/java/top/r3944realms/lib39/example/core/register/FabricExLib39Items.java b/fabric/src/main/java/top/r3944realms/lib39/example/core/register/FabricExLib39Items.java index 5a4e0b5..aad06fe 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/example/core/register/FabricExLib39Items.java +++ b/fabric/src/main/java/top/r3944realms/lib39/example/core/register/FabricExLib39Items.java @@ -10,6 +10,9 @@ import top.r3944realms.lib39.example.content.item.ForgeItem; * The type Ex lib 39 items. */ public class FabricExLib39Items { + /** + * Init. + */ public static void init() { ExLib39Items.FABRIC = FabricLib39Items.register("fabric", new FabricFabricItem( new Item.Properties() diff --git a/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinApiLookUpImpl.java b/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinApiLookUpImpl.java index 0459d0e..65e5d76 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinApiLookUpImpl.java +++ b/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinApiLookUpImpl.java @@ -14,6 +14,12 @@ import top.r3944realms.lib39.core.sync.IEntityApiLookUpImplExtend; import java.util.List; import java.util.Objects; +/** + * The type Mixin api look up. + * + * @param the type parameter + * @param the type parameter + */ @SuppressWarnings("UnstableApiUsage") @Mixin(value = EntityApiLookupImpl.class, remap = false) public class MixinApiLookUpImpl implements IEntityApiLookUpImplExtend { diff --git a/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinEntity.java b/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinEntity.java index db2e51c..fb5d3c6 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinEntity.java +++ b/fabric/src/main/java/top/r3944realms/lib39/mixin/MixinEntity.java @@ -15,8 +15,16 @@ import top.r3944realms.lib39.core.sync.NBTEntitySyncData; import java.util.UUID; +/** + * The type Mixin entity. + */ @Mixin(Entity.class) public abstract class MixinEntity implements ILib39SyncDataHolder { + /** + * Gets uuid. + * + * @return the uuid + */ @Shadow public abstract UUID getUUID(); @Unique diff --git a/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinAnvilMenu.java b/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinAnvilMenu.java index b534ee8..b9c4af7 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinAnvilMenu.java +++ b/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinAnvilMenu.java @@ -13,6 +13,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import top.r3944realms.lib39.api.callback.AnvilUpdateCallback; +/** + * The type Mixin anvil menu. + */ @Mixin(AnvilMenu.class) public abstract class MixinAnvilMenu extends AbstractContainerMenu { @Shadow @@ -25,6 +28,12 @@ public abstract class MixinAnvilMenu extends AbstractContainerMenu { @Unique private Player cachedPlayer; + /** + * Instantiates a new Mixin anvil menu. + * + * @param menuType the menu type + * @param containerId the container id + */ protected MixinAnvilMenu(@Nullable MenuType menuType, int containerId) { super(menuType, containerId); } diff --git a/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinMinecraft.java b/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinMinecraft.java index 4174778..9b23be9 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinMinecraft.java +++ b/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/MixinMinecraft.java @@ -26,6 +26,9 @@ import javax.annotation.Nullable; */ @Mixin(Minecraft.class) public abstract class MixinMinecraft extends ReentrantBlockableEventLoop implements WindowEventHandler { + /** + * The Level. + */ @Shadow @Nullable public ClientLevel level; /** @@ -36,16 +39,30 @@ public abstract class MixinMinecraft extends ReentrantBlockableEventLoop original) { if (levelClient != null) ClientWorldCallback.UNLOAD.invoker().onWorldUnload(levelClient); original.call(levelClient); } + + /** + * Clear level callback. + * + * @param original the original + */ @WrapMethod(method = "clearLevel()V") public void clearLevel$callback(Operation original) { if (level != null) ClientWorldCallback.UNLOAD.invoker().onWorldUnload(level); original.call(); } + /** * Set level setup. * diff --git a/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/client/MixinClientLevel.java b/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/client/MixinClientLevel.java index b7ccc17..3930d42 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/client/MixinClientLevel.java +++ b/fabric/src/main/java/top/r3944realms/lib39/mixin/callback/client/MixinClientLevel.java @@ -18,8 +18,24 @@ import top.r3944realms.lib39.api.callback.client.ClientWorldCallback; import java.util.function.Supplier; +/** + * The type Mixin client level. + */ @Mixin(ClientLevel.class) public abstract class MixinClientLevel extends Level { + /** + * Instantiates a new Mixin client level. + * + * @param levelData the level data + * @param dimension the dimension + * @param registryAccess the registry access + * @param dimensionTypeRegistration the dimension type registration + * @param profiler the profiler + * @param isClientSide the is client side + * @param isDebug the is debug + * @param biomeZoomSeed the biome zoom seed + * @param maxChainedNeighborUpdates the max chained neighbor updates + */ protected MixinClientLevel(WritableLevelData levelData, ResourceKey dimension, RegistryAccess registryAccess, Holder dimensionTypeRegistration, Supplier profiler, boolean isClientSide, boolean isDebug, long biomeZoomSeed, int maxChainedNeighborUpdates) { super(levelData, dimension, registryAccess, dimensionTypeRegistration, profiler, isClientSide, isDebug, biomeZoomSeed, maxChainedNeighborUpdates); } diff --git a/fabric/src/main/java/top/r3944realms/lib39/platform/FabricHelpCommandHook.java b/fabric/src/main/java/top/r3944realms/lib39/platform/FabricHelpCommandHook.java index ea491a2..f300f64 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/platform/FabricHelpCommandHook.java +++ b/fabric/src/main/java/top/r3944realms/lib39/platform/FabricHelpCommandHook.java @@ -7,7 +7,13 @@ import top.r3944realms.lib39.api.callback.RegisterCommandHelpCallback; import top.r3944realms.lib39.core.command.ICommandHelpManager; import top.r3944realms.lib39.platform.services.IHelpCommandHook; +/** + * The enum Fabric help command hook. + */ public enum FabricHelpCommandHook implements IHelpCommandHook { + /** + * Instance fabric help command hook. + */ INSTANCE; @Override diff --git a/fabric/src/main/java/top/r3944realms/lib39/platform/FabricPlatformHelper.java b/fabric/src/main/java/top/r3944realms/lib39/platform/FabricPlatformHelper.java index 2271c65..bed879d 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/platform/FabricPlatformHelper.java +++ b/fabric/src/main/java/top/r3944realms/lib39/platform/FabricPlatformHelper.java @@ -11,6 +11,9 @@ import top.r3944realms.lib39.platform.services.IUtilHelper; import java.util.Objects; +/** + * The type Fabric platform helper. + */ public class FabricPlatformHelper implements IPlatformHelper { @Override diff --git a/fabric/src/main/java/top/r3944realms/lib39/platform/FabricUtilHelper.java b/fabric/src/main/java/top/r3944realms/lib39/platform/FabricUtilHelper.java index 4a8b5ac..810881c 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/platform/FabricUtilHelper.java +++ b/fabric/src/main/java/top/r3944realms/lib39/platform/FabricUtilHelper.java @@ -4,7 +4,13 @@ import top.r3944realms.lib39.platform.services.IUtilHelper; import top.r3944realms.lib39.util.FabricBlockRegistryBuilder; import top.r3944realms.lib39.util.block.BlockRegistryBuilder; +/** + * The enum Fabric util helper. + */ public enum FabricUtilHelper implements IUtilHelper { + /** + * Instance fabric util helper. + */ INSTANCE; @Override public BlockRegistryBuilder getBlockRegistryBuilder() { diff --git a/fabric/src/main/java/top/r3944realms/lib39/util/FabricBlockRegistryBuilder.java b/fabric/src/main/java/top/r3944realms/lib39/util/FabricBlockRegistryBuilder.java index af6be89..b966743 100644 --- a/fabric/src/main/java/top/r3944realms/lib39/util/FabricBlockRegistryBuilder.java +++ b/fabric/src/main/java/top/r3944realms/lib39/util/FabricBlockRegistryBuilder.java @@ -8,6 +8,9 @@ import top.r3944realms.lib39.util.block.BlockRegistryBuilder; import java.util.function.Supplier; +/** + * The type Fabric block registry builder. + */ public class FabricBlockRegistryBuilder extends BlockRegistryBuilder { @SafeVarargs @Override diff --git a/forge/build.gradle b/forge/build.gradle index d876983..393aeee 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -22,6 +22,7 @@ legacyForge { validateAccessTransformers = true def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg') + def generated = project(':common').file('src/generated/resources/') if (at.exists()) { accessTransformers = ["src/main/resources/META-INF/accesstransformer.cfg"] } diff --git a/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockLootTable.java b/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockLootTable.java index 0132b92..b355985 100644 --- a/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockLootTable.java +++ b/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockLootTable.java @@ -13,6 +13,6 @@ public class Lib39BlockLootTable extends BlockLootTables { */ public Lib39BlockLootTable() { super(ForgeLib39Blocks.BLOCKS); - dropSelf(Lib39Blocks.DOLL); + dropSelf(Lib39Blocks.DOLL, Lib39Blocks.WALL_DOLL); } } diff --git a/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockStatesProvider.java b/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockStatesProvider.java index 30c6005..b2abf58 100644 --- a/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockStatesProvider.java +++ b/forge/src/main/java/top/r3944realms/lib39/base/datagen/provider/Lib39BlockStatesProvider.java @@ -3,7 +3,6 @@ package top.r3944realms.lib39.base.datagen.provider; import net.minecraft.core.Direction; import net.minecraft.data.PackOutput; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ModelFile; @@ -39,15 +38,16 @@ public class Lib39BlockStatesProvider extends BlockStateProvider { models().existingFileHelper ); - getVariantBuilder(doll).forAllStates(state -> { - Direction direction = state.getValue(BlockStateProperties.HORIZONTAL_FACING); - int rotationY = getMainNorthRotationY(direction); + getVariantBuilder(doll).forAllStates(state -> ConfiguredModel.builder() + .modelFile(modelFile) + .build()); + + Block wallDoll = Lib39Blocks.WALL_DOLL.get(); + + getVariantBuilder(wallDoll).forAllStates(state -> ConfiguredModel.builder() + .modelFile(modelFile) + .build()); - return ConfiguredModel.builder() - .modelFile(modelFile) - .rotationY(rotationY) - .build(); - }); } @Contract(pure = true) diff --git a/forge/src/main/java/top/r3944realms/lib39/content/item/ForgeDollItem.java b/forge/src/main/java/top/r3944realms/lib39/content/item/ForgeDollItem.java index 1e7ad8e..38a80eb 100644 --- a/forge/src/main/java/top/r3944realms/lib39/content/item/ForgeDollItem.java +++ b/forge/src/main/java/top/r3944realms/lib39/content/item/ForgeDollItem.java @@ -7,7 +7,15 @@ import top.r3944realms.lib39.client.renderer.item.DollItemRenderer; import java.util.function.Consumer; +/** + * The type Forge doll item. + */ public class ForgeDollItem extends DollItem { + /** + * Instantiates a new Forge doll item. + * + * @param properties the properties + */ public ForgeDollItem(Properties properties) { super(properties); } diff --git a/forge/src/main/java/top/r3944realms/lib39/core/compat/ForgeCompatManager.java b/forge/src/main/java/top/r3944realms/lib39/core/compat/ForgeCompatManager.java index 1b6e9db..659c0f8 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/compat/ForgeCompatManager.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/compat/ForgeCompatManager.java @@ -19,11 +19,30 @@ import java.util.function.Consumer; */ @SuppressWarnings("unused") public abstract class ForgeCompatManager extends CompatManager { - protected final IEventBus modEventBus, gameEventBus; + /** + * The Mod event bus. + */ + protected final IEventBus modEventBus, /** + * The Game event bus. + */ + gameEventBus; + /** + * The Compats. + */ protected final Map compats = new HashMap<>(); - // 存储事件监听器配置 + /** + * The Listener configs. + */ +// 存储事件监听器配置 protected final List listenerConfigs = new ArrayList<>(); + /** + * Instantiates a new Forge compat manager. + * + * @param id the id + * @param modEventBus the mod event bus + * @param gameEventBus the game event bus + */ public ForgeCompatManager(ResourceLocation id, IEventBus modEventBus, IEventBus gameEventBus) { super(id); this.modEventBus = modEventBus; @@ -223,6 +242,9 @@ public abstract class ForgeCompatManager extends CompatManager { addListenerForCompat(compatId, null, bus); } + /** + * The type Listener config. + */ protected static class ListenerConfig { /** * The Compat id. diff --git a/forge/src/main/java/top/r3944realms/lib39/core/event/ClientEventHandler.java b/forge/src/main/java/top/r3944realms/lib39/core/event/ClientEventHandler.java index 0c96c9f..7e374b3 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/event/ClientEventHandler.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/event/ClientEventHandler.java @@ -30,6 +30,7 @@ public class ClientEventHandler { * On register shaders. * * @param event the event + * @throws IOException the io exception */ @SubscribeEvent public static void onRegisterShaders(RegisterShadersEvent event) throws IOException { diff --git a/forge/src/main/java/top/r3944realms/lib39/core/event/CommonEventHandler.java b/forge/src/main/java/top/r3944realms/lib39/core/event/CommonEventHandler.java index 46f061b..6eb0ddf 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/event/CommonEventHandler.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/event/CommonEventHandler.java @@ -220,6 +220,7 @@ public class CommonEventHandler { public static class Mod extends CommonEventHandler { private static final Map, ResourceKey[]> itemAddMap = new ConcurrentHashMap<>(); private static final Map, List>> tabToItemsMap = new ConcurrentHashMap<>(); + /** * On fml common setup. * diff --git a/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39BlockEntities.java b/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39BlockEntities.java index 78edf16..53a8119 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39BlockEntities.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39BlockEntities.java @@ -20,7 +20,7 @@ public class ForgeLib39BlockEntities { //noinspection DataFlowIssue Lib39BlockEntities.DOLL_BLOCK_ENTITY = BLOCK_ENTITY_TYPES.register("doll", () -> BlockEntityType.Builder - .of(DollBlockEntity::new, Lib39Blocks.DOLL.get()) + .of(DollBlockEntity::new, Lib39Blocks.DOLL.get(), Lib39Blocks.WALL_DOLL.get()) .build(null) ); } diff --git a/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39Blocks.java b/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39Blocks.java index 91395a9..096a1a0 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39Blocks.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/register/ForgeLib39Blocks.java @@ -6,6 +6,7 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import top.r3944realms.lib39.Lib39; import top.r3944realms.lib39.content.block.DollBlock; +import top.r3944realms.lib39.content.block.WallDollBlock; import top.r3944realms.lib39.util.block.BlockRegistryBuilder; /** @@ -23,8 +24,14 @@ public class ForgeLib39Blocks { .withName("doll") .registerBlock(BLOCKS::register, DollBlock::new) .build(); + Lib39Blocks.WALL_DOLL = BlockRegistryBuilder + .create() + .withName("wall_doll") + .registerBlock(BLOCKS::register, WallDollBlock::new) + .build(); } + /** * Register. * diff --git a/forge/src/main/java/top/r3944realms/lib39/core/sync/IForgeUpdate.java b/forge/src/main/java/top/r3944realms/lib39/core/sync/IForgeUpdate.java index 95f0a16..cb98ba4 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/sync/IForgeUpdate.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/sync/IForgeUpdate.java @@ -3,6 +3,9 @@ package top.r3944realms.lib39.core.sync; import top.r3944realms.lib39.core.network.NetworkHandler; import top.r3944realms.lib39.core.network.toClient.SyncNBTCapDataEntityS2CPacket; +/** + * The interface Forge update. + */ public interface IForgeUpdate extends IUpdate { default void update() { NetworkHandler.sendToAllPlayer(new SyncNBTCapDataEntityS2CPacket(getSyncData().entityId(), getSyncData().id, getSyncData().serializeNBT())); diff --git a/forge/src/main/java/top/r3944realms/lib39/core/sync/SyncData2CapManager.java b/forge/src/main/java/top/r3944realms/lib39/core/sync/SyncData2CapManager.java index 6a6d1c6..d9203e5 100644 --- a/forge/src/main/java/top/r3944realms/lib39/core/sync/SyncData2CapManager.java +++ b/forge/src/main/java/top/r3944realms/lib39/core/sync/SyncData2CapManager.java @@ -14,6 +14,9 @@ import java.util.Optional; */ @SuppressWarnings("unused") public class SyncData2CapManager extends SyncData2Manager>> { + /** + * The Typed entries. + */ protected final Map> typedEntries = Maps.newConcurrentMap(); @Override @@ -21,6 +24,11 @@ public class SyncData2CapManager extends SyncData2Manager the type parameter + */ protected static class TypedSyncEntry> extends SyncData2Manager.TypedSyncEntry, T> { /** * Instantiates a new Typed sync entry. @@ -87,6 +95,14 @@ public class SyncData2CapManager extends SyncData2Manager the type parameter + * @param id the id + * @param entry the entry + * @param newCapability the new capability + */ protected > void updateCapabilityInEntry(ResourceLocation id, TypedSyncEntry entry, Capability newCapability) { updateDataProviderInEntry(id, entry, key -> newCapability != null ? key.getCapability(newCapability).resolve() : Optional.empty()); } diff --git a/forge/src/main/java/top/r3944realms/lib39/example/ForgeLib39Example.java b/forge/src/main/java/top/r3944realms/lib39/example/ForgeLib39Example.java index 1bfb9f1..7daad75 100644 --- a/forge/src/main/java/top/r3944realms/lib39/example/ForgeLib39Example.java +++ b/forge/src/main/java/top/r3944realms/lib39/example/ForgeLib39Example.java @@ -7,8 +7,12 @@ import top.r3944realms.lib39.example.core.event.ExCommonEventHandler; import top.r3944realms.lib39.example.core.network.ExNetworkHandler; import top.r3944realms.lib39.example.core.register.ForgeExLib39Items; +/** + * The type Forge lib 39 example. + */ public class ForgeLib39Example { private static boolean registered = false; + /** * Instantiates a new Lib 39 example. */ @@ -19,6 +23,10 @@ public class ForgeLib39Example { registered = true; } } + + /** + * Init. + */ public void init() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ForgeExLib39Items.register(modEventBus); diff --git a/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39Compat.java b/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39Compat.java index 1f668cf..3ee8b19 100644 --- a/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39Compat.java +++ b/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39Compat.java @@ -12,7 +12,10 @@ import top.r3944realms.lib39.core.compat.IForgeCompat; * The type Lib 39 compat. */ public class Lib39Compat implements IForgeCompat { - boolean initialized = false; + /** + * The Initialized. + */ + boolean initialized = false; /** * The constant INSTANCE. */ diff --git a/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39CompatManager.java b/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39CompatManager.java index 8daa1ca..ca3d58b 100644 --- a/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39CompatManager.java +++ b/forge/src/main/java/top/r3944realms/lib39/example/compat/Lib39CompatManager.java @@ -4,11 +4,14 @@ import net.minecraftforge.eventbus.api.IEventBus; import top.r3944realms.lib39.Lib39; import top.r3944realms.lib39.core.compat.ForgeCompatManager; +/** + * The type Lib 39 compat manager. + */ public class Lib39CompatManager extends ForgeCompatManager { /** * Instantiates a new Compat manager. * - * @param path the path + * @param path the path * @param modEventBus the mod event bus * @param gameEventBus the game event bus */ diff --git a/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeFabricItem.java b/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeFabricItem.java index 4f601a8..3b3dccb 100644 --- a/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeFabricItem.java +++ b/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeFabricItem.java @@ -13,8 +13,16 @@ import top.r3944realms.lib39.example.content.data.TestSyncData; import top.r3944realms.lib39.example.core.network.ClientDataPacket; import top.r3944realms.lib39.example.core.network.ExNetworkHandler; +/** + * The type Forge fabric item. + */ public class ForgeFabricItem extends AbstractFabricItem { + /** + * Instantiates a new Forge fabric item. + * + * @param properties the properties + */ public ForgeFabricItem(Properties properties) { super(properties); } @@ -29,6 +37,12 @@ public class ForgeFabricItem extends AbstractFabricItem { ExNetworkHandler.INSTANCE.sendToServer(new ClientDataPacket(clientData, targetEntityId)); } + /** + * Gets static data. + * + * @param target the target + * @return the static data + */ public static @Nullable AbstractedTestSyncData getStaticData(Entity target) { try { AbstractedTestSyncData abstractData = target.getCapability(ExCapabilityHandler.TEST_CAP).resolve().orElse(null); @@ -41,6 +55,13 @@ public class ForgeFabricItem extends AbstractFabricItem { return null; } + /** + * Handle client data from packet. + * + * @param player the player + * @param clientData the client data + * @param targetEntityId the target entity id + */ public static void handleClientDataFromPacket(@NotNull ServerPlayer player, AbstractedTestSyncData clientData, int targetEntityId) { Entity target = player.level().getEntity(targetEntityId); diff --git a/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeNeoForgeItem.java b/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeNeoForgeItem.java index 6c0df8f..951cf37 100644 --- a/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeNeoForgeItem.java +++ b/forge/src/main/java/top/r3944realms/lib39/example/content/item/ForgeNeoForgeItem.java @@ -7,8 +7,16 @@ import top.r3944realms.lib39.example.content.data.AbstractedTestSyncData; import top.r3944realms.lib39.example.content.data.ExCapabilityHandler; import top.r3944realms.lib39.example.content.data.TestSyncData; +/** + * The type Forge neo forge item. + */ public class ForgeNeoForgeItem extends AbstractNeoForgeItem{ + /** + * Instantiates a new Forge neo forge item. + * + * @param properties the properties + */ public ForgeNeoForgeItem(Properties properties) { super(properties); } @@ -17,6 +25,13 @@ public class ForgeNeoForgeItem extends AbstractNeoForgeItem{ protected AbstractedTestSyncData getData(Entity entity) { return getStaticData(entity); } + + /** + * Gets static data. + * + * @param target the target + * @return the static data + */ @SuppressWarnings("JavaExistingMethodCanBeUsed") public static @Nullable AbstractedTestSyncData getStaticData(Entity target) { try { diff --git a/forge/src/main/java/top/r3944realms/lib39/example/core/event/ExCommonEventHandler.java b/forge/src/main/java/top/r3944realms/lib39/example/core/event/ExCommonEventHandler.java index b2c675a..012b54b 100644 --- a/forge/src/main/java/top/r3944realms/lib39/example/core/event/ExCommonEventHandler.java +++ b/forge/src/main/java/top/r3944realms/lib39/example/core/event/ExCommonEventHandler.java @@ -71,7 +71,11 @@ public class ExCommonEventHandler { * The type Mod. */ public static class Mod extends ExCommonEventHandler { + /** + * The constant EVENT_BUS. + */ public static final IEventBus EVENT_BUS = FMLJavaModLoadingContext.get().getModEventBus(); + /** * Gets compat manager. * diff --git a/forge/src/main/java/top/r3944realms/lib39/platform/ForgeHelpCommandHook.java b/forge/src/main/java/top/r3944realms/lib39/platform/ForgeHelpCommandHook.java index fc9d22e..57e3270 100644 --- a/forge/src/main/java/top/r3944realms/lib39/platform/ForgeHelpCommandHook.java +++ b/forge/src/main/java/top/r3944realms/lib39/platform/ForgeHelpCommandHook.java @@ -8,7 +8,13 @@ import top.r3944realms.lib39.api.event.RegisterCommandHelpEvent; import top.r3944realms.lib39.core.command.ICommandHelpManager; import top.r3944realms.lib39.platform.services.IHelpCommandHook; +/** + * The enum Forge help command hook. + */ public enum ForgeHelpCommandHook implements IHelpCommandHook { + /** + * Instance forge help command hook. + */ INSTANCE; @Override diff --git a/forge/src/main/java/top/r3944realms/lib39/platform/ForgePlatformHelper.java b/forge/src/main/java/top/r3944realms/lib39/platform/ForgePlatformHelper.java index 7b39c12..226a702 100644 --- a/forge/src/main/java/top/r3944realms/lib39/platform/ForgePlatformHelper.java +++ b/forge/src/main/java/top/r3944realms/lib39/platform/ForgePlatformHelper.java @@ -8,6 +8,9 @@ import top.r3944realms.lib39.platform.services.IHelpCommandHook; import top.r3944realms.lib39.platform.services.IPlatformHelper; import top.r3944realms.lib39.platform.services.IUtilHelper; +/** + * The type Forge platform helper. + */ public class ForgePlatformHelper implements IPlatformHelper { @Override diff --git a/forge/src/main/java/top/r3944realms/lib39/platform/ForgeUtilHelper.java b/forge/src/main/java/top/r3944realms/lib39/platform/ForgeUtilHelper.java index d2239f7..47a17ba 100644 --- a/forge/src/main/java/top/r3944realms/lib39/platform/ForgeUtilHelper.java +++ b/forge/src/main/java/top/r3944realms/lib39/platform/ForgeUtilHelper.java @@ -4,7 +4,13 @@ import top.r3944realms.lib39.platform.services.IUtilHelper; import top.r3944realms.lib39.util.ForgeBlockRegistryBuilder; import top.r3944realms.lib39.util.block.BlockRegistryBuilder; +/** + * The enum Forge util helper. + */ public enum ForgeUtilHelper implements IUtilHelper { + /** + * Instance forge util helper. + */ INSTANCE; @Override public BlockRegistryBuilder getBlockRegistryBuilder() { diff --git a/forge/src/main/java/top/r3944realms/lib39/util/ForgeBlockRegistryBuilder.java b/forge/src/main/java/top/r3944realms/lib39/util/ForgeBlockRegistryBuilder.java index bc44d1c..9c1ae62 100644 --- a/forge/src/main/java/top/r3944realms/lib39/util/ForgeBlockRegistryBuilder.java +++ b/forge/src/main/java/top/r3944realms/lib39/util/ForgeBlockRegistryBuilder.java @@ -8,6 +8,9 @@ import top.r3944realms.lib39.util.block.BlockRegistryBuilder; import java.util.function.Supplier; +/** + * The type Forge block registry builder. + */ public class ForgeBlockRegistryBuilder extends BlockRegistryBuilder { @SafeVarargs @Override