Skip to content

Commit

Permalink
Merge pull request #1 from Khazoda/1.20.4
Browse files Browse the repository at this point in the history
1.20.4
  • Loading branch information
Khazoda authored Apr 23, 2024
2 parents 3318498 + f263311 commit 1c917ba
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 51 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down
17 changes: 8 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
midnightlib_version=1.5.3-fabric
2 changes: 1 addition & 1 deletion src/main/java/com/seacroak/plushables/PlushablesMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onInitialize() {
PlushablesNetworking.registerGlobalSoundPacketReceiverWithoutPlayer();
PlushablesNetworking.registerGlobalParticlePacketReceiver();
PlushablesNetworking.registerGlobalAnimationPacketReceiver();

LOGGER.info("[Plushables] Finished loading!");
}
}
40 changes: 35 additions & 5 deletions src/main/java/com/seacroak/plushables/PlushablesModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
});
Expand All @@ -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(() -> {
Expand All @@ -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;
Expand All @@ -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(() -> {
Expand All @@ -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(() -> {
Expand All @@ -121,5 +149,7 @@ public void onInitializeClient() {

});
}));


}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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;
}


Expand Down Expand Up @@ -149,4 +151,9 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
builder.add(FACING, WATERLOGGED);
}

/* Block Codec */
@Override
protected MapCodec<? extends HorizontalFacingBlock> getCodec() {
return null;
}
}
6 changes: 5 additions & 1 deletion src/main/java/com/seacroak/plushables/block/BasketBlock.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -225,5 +226,8 @@ public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable Livi

}


@Override
protected MapCodec<? extends BlockWithEntity> getCodec() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -105,4 +107,8 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
builder.add(FACING);
}

@Override
protected MapCodec<? extends HorizontalFacingBlock> getCodec() {
return null;
}
}
64 changes: 35 additions & 29 deletions src/main/java/com/seacroak/plushables/block/CodexBlock.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Block, BlockState> builder) {
builder.add(FACING);
}

}
@Override
protected MapCodec<? extends HorizontalFacingBlock> getCodec() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/assets/plushables/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -42,7 +42,7 @@
],
"depends": {
"fabricloader": ">=0.15.7",
"minecraft": "~1.20.2",
"minecraft": "~1.20.4",
"java": ">=17",
"fabric-api": "*"
},
Expand Down

0 comments on commit 1c917ba

Please sign in to comment.