diff --git a/build.gradle b/build.gradle index 99b2fb7..f21ec97 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.5-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index e7b6c4f..3e4fa51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,19 +2,18 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true -# Fabric Properties -# check these on https://fabricmc.net/develop -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.4 -loader_version=0.15.10 - # Mod Properties -mod_version=1.1.5 +mod_version=1.1.6 maven_group=com.seacroak.plushables archives_base_name=plushables +# Fabric Properties +minecraft_version=1.20.4 +yarn_mappings=1.20.4+build.3 +loader_version=0.15.10 + # Dependencies -fabric_version=0.91.6+1.20.2 +fabric_version=0.97.0+1.20.4 # MidnightLib -midnightlib_version=1.5.0-fabric \ No newline at end of file +midnightlib_version=1.5.3-fabric \ No newline at end of file diff --git a/src/main/java/com/seacroak/plushables/PlushablesMod.java b/src/main/java/com/seacroak/plushables/PlushablesMod.java index dcd7891..314377b 100644 --- a/src/main/java/com/seacroak/plushables/PlushablesMod.java +++ b/src/main/java/com/seacroak/plushables/PlushablesMod.java @@ -36,7 +36,7 @@ public void onInitialize() { PlushablesNetworking.registerGlobalSoundPacketReceiverWithoutPlayer(); PlushablesNetworking.registerGlobalParticlePacketReceiver(); PlushablesNetworking.registerGlobalAnimationPacketReceiver(); - + LOGGER.info("[Plushables] Finished loading!"); } } \ No newline at end of file diff --git a/src/main/java/com/seacroak/plushables/PlushablesModClient.java b/src/main/java/com/seacroak/plushables/PlushablesModClient.java index 30f592d..33864fb 100644 --- a/src/main/java/com/seacroak/plushables/PlushablesModClient.java +++ b/src/main/java/com/seacroak/plushables/PlushablesModClient.java @@ -13,10 +13,16 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.client.render.RenderLayer; import net.minecraft.particle.ParticleEffect; import net.minecraft.sound.SoundEvent; +import net.minecraft.text.ClickEvent; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; public final class PlushablesModClient implements ClientModInitializer { @@ -56,11 +62,27 @@ public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(MainRegistry.CLUCKY_PLUSHABLE, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(MainRegistry.DRAGON_PLUSHABLE, RenderLayer.getCutout()); + /* Clientside Commands */ + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) + -> dispatcher.register(ClientCommandManager.literal("plushables") + .executes(context -> { + context.getSource().sendFeedback(Text.translatable("command.plushables.root")); + return 1; + } + ) + .then(ClientCommandManager.literal("wiki") + .executes(context -> { + context.getSource().sendFeedback(Text.translatable("command.plushables.wiki").setStyle(Style.EMPTY.withColor(Formatting.BLUE).withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,"https://plushables.khazoda.com")))); + return 1; + }) + ) + ) + ); /* Config Sync Networking Packet Client Receipt */ ClientPlayNetworking.registerGlobalReceiver(ConfigPacketHandler.PACKET_ID, ((client, handler, buf, responseSender) -> { var packet = ConfigPacket.read(buf); - if(client == null) return; + if (client == null) return; client.execute(() -> { PlushablesNetworking.priorityConfig(packet.enable_basket, packet.allow_all_block_items_in_baskets); }); @@ -70,7 +92,9 @@ public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(SoundPacketHandler.PACKET_ID_PLAYER, ((client, handler, buf, responseSender) -> { var packet = PlayerSoundPacket.read(buf); SoundEvent decodedSoundEvent = PacketDecoder.decodeSoundEvent(packet.soundIdentifier); - if(client == null) return; + if (client == null) return; + + assert client.player != null; if (packet.player == client.player.getUuid()) return; client.execute(() -> { @@ -85,7 +109,7 @@ public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(SoundPacketHandler.PACKET_ID_NO_PLAYER, ((client, handler, buf, responseSender) -> { var packet = NoPlayerSoundPacket.read(buf); SoundEvent decodedSoundEvent = PacketDecoder.decodeSoundEvent(packet.soundIdentifier); - if(client == null) return; + if (client == null) return; client.execute(() -> { if (client.world == null) return; @@ -97,7 +121,9 @@ public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(ParticlePacketHandler.PACKET_ID, ((client, handler, buf, responseSender) -> { var packet = ParticlePacket.read(buf); ParticleEffect decodedParticles = PacketDecoder.decodeParticle(packet.particleIdentifier); - if(client == null) return; + if (client == null) return; + + assert client.player != null; if (packet.player == client.player.getUuid()) return; client.execute(() -> { @@ -111,7 +137,9 @@ public void onInitializeClient() { /* Animation Event Networking Packet Client Receipt */ ClientPlayNetworking.registerGlobalReceiver(AnimationPacketHandler.PACKET_ID, ((client, handler, buf, responseSender) -> { var packet = AnimationPacket.read(buf); - if(client == null) return; + if (client == null) return; + + assert client.player != null; if (packet.player == client.player.getUuid()) return; client.execute(() -> { @@ -121,5 +149,7 @@ public void onInitializeClient() { }); })); + + } } diff --git a/src/main/java/com/seacroak/plushables/block/BasePlushable.java b/src/main/java/com/seacroak/plushables/block/BasePlushable.java index 74dece5..01494fa 100644 --- a/src/main/java/com/seacroak/plushables/block/BasePlushable.java +++ b/src/main/java/com/seacroak/plushables/block/BasePlushable.java @@ -1,5 +1,6 @@ package com.seacroak.plushables.block; +import com.mojang.serialization.MapCodec; import com.seacroak.plushables.networking.ParticlePacketHandler; import com.seacroak.plushables.networking.PlushablesNetworking; import com.seacroak.plushables.networking.SoundPacketHandler; @@ -86,7 +87,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt // Custom breaking particle code @Override - public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { + public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { if (world.isClient) { for (int i = 0; i < 5; i++) { world.addParticle(ParticleTypes.POOF, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, rand.nextFloat(-0.05f, 0.05f), rand.nextFloat(-0.05f, 0.05f), rand.nextFloat(-0.05f, 0.05f)); @@ -95,6 +96,7 @@ public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity pl } world.addParticle(ParticleTypes.FIREWORK, true, pos.getX(), pos.getY(), pos.getZ(), 0.1, 0.1, 0.1); super.onBreak(world, pos, state, player); + return state; } @@ -149,4 +151,9 @@ protected void appendProperties(StateManager.Builder builder) builder.add(FACING, WATERLOGGED); } + /* Block Codec */ + @Override + protected MapCodec getCodec() { + return null; + } } diff --git a/src/main/java/com/seacroak/plushables/block/BasketBlock.java b/src/main/java/com/seacroak/plushables/block/BasketBlock.java index b47ac16..4f1f208 100644 --- a/src/main/java/com/seacroak/plushables/block/BasketBlock.java +++ b/src/main/java/com/seacroak/plushables/block/BasketBlock.java @@ -1,5 +1,6 @@ package com.seacroak.plushables.block; +import com.mojang.serialization.MapCodec; import com.seacroak.plushables.PlushablesMod; import com.seacroak.plushables.block.tile.BasketBlockEntity; import com.seacroak.plushables.config.ClientConfigValues; @@ -225,5 +226,8 @@ public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable Livi } - + @Override + protected MapCodec getCodec() { + return null; + } } diff --git a/src/main/java/com/seacroak/plushables/block/BuilderBlock.java b/src/main/java/com/seacroak/plushables/block/BuilderBlock.java index b1f988f..91b5a4c 100644 --- a/src/main/java/com/seacroak/plushables/block/BuilderBlock.java +++ b/src/main/java/com/seacroak/plushables/block/BuilderBlock.java @@ -1,5 +1,6 @@ package com.seacroak.plushables.block; +import com.mojang.serialization.MapCodec; import com.seacroak.plushables.PlushablesMod; import com.seacroak.plushables.util.VoxelShapeUtils; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; @@ -57,8 +58,9 @@ public BlockRenderType getRenderType(BlockState state) { // } @Override - public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { + public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { super.onBreak(world, pos, state, player); + return state; } // @Override @@ -105,4 +107,8 @@ protected void appendProperties(StateManager.Builder builder) builder.add(FACING); } + @Override + protected MapCodec getCodec() { + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/seacroak/plushables/block/CodexBlock.java b/src/main/java/com/seacroak/plushables/block/CodexBlock.java index becac1b..3e54924 100644 --- a/src/main/java/com/seacroak/plushables/block/CodexBlock.java +++ b/src/main/java/com/seacroak/plushables/block/CodexBlock.java @@ -1,5 +1,6 @@ package com.seacroak.plushables.block; +import com.mojang.serialization.MapCodec; import com.seacroak.plushables.registry.MainRegistry; import com.seacroak.plushables.util.VoxelShapeUtils; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; @@ -34,47 +35,52 @@ public CodexBlock() { @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - if (world instanceof ServerWorld serverWorld) { + if (world instanceof ServerWorld) { ItemScatterer.spawn(world, pos, DefaultedList.ofSize(1, new ItemStack(MainRegistry.CODEX_ITEM))); world.updateComparators(pos, this); world.removeBlock(pos, false); return ActionResult.CONSUME; } else if (world.isClient) { - world.playSound(player,pos, SoundEvents.BLOCK_CHISELED_BOOKSHELF_PICKUP, SoundCategory.BLOCKS,1f,1f); + world.playSound(player, pos, SoundEvents.BLOCK_CHISELED_BOOKSHELF_PICKUP, SoundCategory.BLOCKS, 1f, 1f); return ActionResult.SUCCESS; } return ActionResult.PASS; } - public VoxelShape getShape () { - VoxelShape shape = VoxelShapes.empty(); - shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.28125, 0, 0.25, 0.8, 0.172, 0.8)); - return shape; - } + public VoxelShape getShape() { + VoxelShape shape = VoxelShapes.empty(); + shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.28125, 0, 0.25, 0.8, 0.172, 0.8)); + return shape; + } - final VoxelShape blockShape = getShape(); - final VoxelShape[] blockShapes = VoxelShapeUtils.calculateBlockShapes(blockShape); + final VoxelShape blockShape = getShape(); + final VoxelShape[] blockShapes = VoxelShapeUtils.calculateBlockShapes(blockShape); - @Override - public VoxelShape getOutlineShape (BlockState state, BlockView world, BlockPos pos, ShapeContext context){ - Direction direction = state.get(FACING); - return VoxelShapeUtils.getSidedOutlineShape(direction, blockShape, blockShapes); - } + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + Direction direction = state.get(FACING); + return VoxelShapeUtils.getSidedOutlineShape(direction, blockShape, blockShapes); + } - // Render Type - @Override - public BlockRenderType getRenderType (BlockState state){ - return BlockRenderType.MODEL; - } - // Initial state upon placing - @Override - public BlockState getPlacementState (ItemPlacementContext context){ - return this.getDefaultState().with(Properties.HORIZONTAL_FACING, context.getHorizontalPlayerFacing().getOpposite()); - } - // Append initial properties - protected void appendProperties (StateManager.Builder < Block, BlockState > builder){ - builder.add(FACING); - } + // Render Type + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; + } + + // Initial state upon placing + @Override + public BlockState getPlacementState(ItemPlacementContext context) { + return this.getDefaultState().with(Properties.HORIZONTAL_FACING, context.getHorizontalPlayerFacing().getOpposite()); + } + // Append initial properties + protected void appendProperties(StateManager.Builder builder) { + builder.add(FACING); + } - } \ No newline at end of file + @Override + protected MapCodec getCodec() { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/com/seacroak/plushables/block/plushable/WispBlock.java b/src/main/java/com/seacroak/plushables/block/plushable/WispBlock.java index 452c26f..c47e66c 100644 --- a/src/main/java/com/seacroak/plushables/block/plushable/WispBlock.java +++ b/src/main/java/com/seacroak/plushables/block/plushable/WispBlock.java @@ -6,6 +6,7 @@ import com.seacroak.plushables.networking.PlushablesNetworking; import com.seacroak.plushables.networking.SoundPacketHandler; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.BlockState; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.player.PlayerEntity; @@ -18,6 +19,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; @@ -27,10 +29,21 @@ import java.util.List; public class WispBlock extends BaseInteractablePlushable { + public WispBlock() { super(FabricBlockSettings.create().sounds(BlockSoundGroup.WOOL).strength(0.7f).nonOpaque().luminance(14).pistonBehavior(PistonBehavior.DESTROY)); } + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + double d = (double) pos.getX() + 0.55 - (double) (random.nextFloat() * 0.25F); + double e = (double) pos.getY() + 0.55 - (double) (random.nextFloat() * 0.25F); + double f = (double) pos.getZ() + 0.55 - (double) (random.nextFloat() * 0.25F); + if (random.nextInt(5) == 0) { + world.addParticle(ParticleTypes.END_ROD, d, e, f, random.nextGaussian() * 0.01, random.nextGaussian() * 0.01, random.nextGaussian() * 0.01); + } + + } + @Override public VoxelShape getShape() { VoxelShape shape = VoxelShapes.empty(); diff --git a/src/main/resources/assets/plushables/lang/en_us.json b/src/main/resources/assets/plushables/lang/en_us.json index c38b7a0..a19a373 100644 --- a/src/main/resources/assets/plushables/lang/en_us.json +++ b/src/main/resources/assets/plushables/lang/en_us.json @@ -98,5 +98,8 @@ "block.plushables.builder.broken": "§7§oThe machine seems unfixable..", "block.plushables.codex.broken": "§7§oThe pages are torn..", - "item.plushables.codex.broken": "§7§oUnusable" + "item.plushables.codex.broken": "§7§oUnusable", + + "command.plushables.root": "You are using §cP§6l§eu§as§bh§9a§5b§cl§6e§es §r§oLite §r1.1.6", + "command.plushables.wiki": "Visit the Plushables wiki" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8d64a17..eb1f13c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "plushables", - "version": "1.1.5", + "version": "1.1.6", "name": "Plushables Lite", "description": "Craft cute plushies for your home", "authors": [ @@ -42,7 +42,7 @@ ], "depends": { "fabricloader": ">=0.15.7", - "minecraft": "~1.20.2", + "minecraft": "~1.20.4", "java": ">=17", "fabric-api": "*" },