Skip to content

Commit

Permalink
trough sounds and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lumiscosity committed Jun 22, 2024
1 parent 3bf234a commit 2222a5e
Show file tree
Hide file tree
Showing 21 changed files with 239 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/client/resources/assets/rounded/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"block.rounded.luster_cluster": "Luster Cluster",
"block.rounded.trough": "Trough",

"subtitles.rounded.block.trough_fill": "Trough filled",
"subtitles.rounded.block.trough_consume": "Trough consumed",

"tag.worldgen.biome.rounded.has_lustershrooms": "Has Lustershrooms",
"tag.worldgen.biome.rounded.has_more_lustershrooms": "Has more Lustershrooms",
"tag.item.rounded.trough_feed": "Trough Feed",
Expand Down
3 changes: 3 additions & 0 deletions src/client/resources/assets/rounded/lang/pl_pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"block.rounded.luster_cluster": "Skupiony lśniącogrzyb",
"block.rounded.trough": "Koryto",

"subtitles.rounded.block.trough_fill": "Napełniono koryto",
"subtitles.rounded.block.trough_consume": "Opróżniono koryto",

"tag.worldgen.biome.rounded.has_lustershrooms": "Ma lśniącogrzyby",
"tag.worldgen.biome.rounded.has_more_lustershrooms": "Ma więcej lśniącogrzybów",
"tag.item.rounded.trough_feed": "Pokarm w korycie",
Expand Down
4 changes: 2 additions & 2 deletions src/client/resources/assets/rounded/models/block/trough.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"textures": {
"particle": "rounded:block/trough_side",
"top": "rounded:block/trough_top",
"bottom": "rounded:block/trough_bottom",
"bottom": "minecraft:block/smooth_stone",
"side": "rounded:block/trough_side",
"inside": "rounded:block/trough_bottom"
"inside": "rounded:block/trough_inside"
},
"elements": [
{ "from": [ 0, 0, 0 ],
Expand Down
15 changes: 15 additions & 0 deletions src/client/resources/assets/rounded/sounds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"trough_fill": {
"subtitle": "subtitles.rounded.block.trough_fill",
"sounds": [
"rounded:block/trough_fill1",
"rounded:block/trough_fill2"
]
},
"trough_consume": {
"subtitle": "subtitles.rounded.block.trough_consume",
"sounds": [
"rounded:block/trough_consume"
]
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/main/java/com/lumiscosity/rounded/Rounded.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.lumiscosity.rounded.blocks.RegisterBlocks;
import com.lumiscosity.rounded.compat.ExtravaganzaCompat;
import com.lumiscosity.rounded.misc.RegisterSounds;
import net.fabricmc.api.ModInitializer;

import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -15,6 +16,7 @@ public class Rounded implements ModInitializer {
@Override
public void onInitialize() {
RegisterBlocks.initBlocks();
RegisterSounds.initSounds();

if (FabricLoader.getInstance().isModLoaded("extravaganza")) {
ExtravaganzaCompat.register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class RegisterBlocks {
AbstractBlock.Settings.create()
.mapColor(MapColor.CYAN)
.luminance(state -> 7)
.sounds(BlockSoundGroup.WOOD)
);
public static final BlockItem LUSTERSHROON_BLOCK_ITEM= new BlockItem(LUSTERSHROOM_BLOCK, new Item.Settings());
public static final Block LUSTER_CLUSTER = new Block(
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/lumiscosity/rounded/blocks/TroughBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lumiscosity.rounded.blocks;

import com.lumiscosity.rounded.misc.RegisterSounds;
import com.mojang.serialization.MapCodec;
import net.minecraft.block.*;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -36,6 +37,8 @@
import org.jetbrains.annotations.Nullable;

import static com.lumiscosity.rounded.Rounded.MOD_ID;
import static com.lumiscosity.rounded.misc.RegisterSounds.TROUGH_CONSUME;
import static com.lumiscosity.rounded.misc.RegisterSounds.TROUGH_FILL;

public class TroughBlock extends Block implements InventoryProvider {

Expand Down Expand Up @@ -68,9 +71,9 @@ public TroughBlock(Settings settings) {
this.setDefaultState(this.stateManager.getDefaultState().with(LEVEL, 0));
}

public static void playEffects(World world, BlockPos pos, boolean fill) {
public static void playEffects(WorldAccess world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
world.playSoundAtBlockCenter(pos, fill ? SoundEvents.BLOCK_COMPOSTER_FILL_SUCCESS : SoundEvents.BLOCK_COMPOSTER_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
world.playSound(null, pos, TROUGH_FILL, SoundCategory.BLOCKS);
double d = blockState.getOutlineShape(world, pos).getEndingCoord(Direction.Axis.Y, 0.5, 0.5) + 0.03125;
double e = 0.13125F;
double f = 0.7375F;
Expand Down Expand Up @@ -120,7 +123,6 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
if (stack.isIn(TagKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, "trough_feed")))) {
if (i < 7 && !world.isClient) {
BlockState blockState = addToTrough(player, state, world, pos, stack);
world.syncWorldEvent(WorldEvents.COMPOSTER_USED, pos, state != blockState ? 1 : 0);
player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem()));
stack.decrementUnlessCreative(1, player);
}
Expand All @@ -133,11 +135,12 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl

static BlockState addToTrough(@Nullable Entity user, BlockState state, WorldAccess world, BlockPos pos, ItemStack stack) {
int i = state.get(LEVEL);
if (((i != 0) && !(world.getRandom().nextDouble() < 0.5F)) || !stack.isIn(TagKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, "trough_feed")))) {
if (!stack.isIn(TagKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, "trough_feed")))) {
return state;
} else {
int j = i + 1;
BlockState blockState = state.with(LEVEL, j);
playEffects(world, pos);
world.setBlockState(pos, blockState, Block.NOTIFY_ALL);
world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(user, blockState));

Expand Down Expand Up @@ -270,6 +273,7 @@ public boolean canExtract(int slot, ItemStack stack, Direction dir) {
protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (state.get(LEVEL) > 0) {
if (growAnimals(world, pos)) {
world.playSound(null, pos, TROUGH_CONSUME, SoundCategory.BLOCKS);
world.setBlockState(pos, consumeTroughStack(state), Block.NOTIFY_ALL);
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/lumiscosity/rounded/misc/RegisterSounds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.lumiscosity.rounded.misc;

import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;

import static com.lumiscosity.rounded.Rounded.MOD_ID;

public class RegisterSounds {
public static final Identifier TROUGH_FILL_ID = Identifier.of(MOD_ID, "trough_fill");
public static final SoundEvent TROUGH_FILL = SoundEvent.of(TROUGH_FILL_ID);
public static final Identifier TROUGH_CONSUME_ID = Identifier.of(MOD_ID, "trough_consume");
public static final SoundEvent TROUGH_CONSUME = SoundEvent.of(TROUGH_CONSUME_ID);

public static void initSounds() {
Registry.register(Registries.SOUND_EVENT, TROUGH_FILL_ID, TROUGH_FILL);
Registry.register(Registries.SOUND_EVENT, TROUGH_CONSUME_ID, TROUGH_CONSUME);
}
}
6 changes: 6 additions & 0 deletions src/main/resources/data/c/tags/item/mushroom_caps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"rounded:lustershroom_block"
]
}
6 changes: 6 additions & 0 deletions src/main/resources/data/c/tags/item/mushrooms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"rounded:lustershroom"
]
}
21 changes: 21 additions & 0 deletions src/main/resources/data/minecraft/recipe/cartography_table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"#": {
"tag": "rounded:treated_planks"
},
"@": {
"item": "minecraft:paper"
}
},
"pattern": [
"@@",
"##",
"##"
],
"result": {
"count": 1,
"id": "minecraft:cartography_table"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"replace": false,
"values": [
"rounded:lustershroom_block",
"rounded:luster_cluster",
"rounded:treated_oak_planks",
"rounded:treated_spruce_planks",
"rounded:treated_jungle_planks",
Expand All @@ -12,4 +13,4 @@
"rounded:treated_mangrove_planks",
"rounded:treated_bamboo_planks"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_log": {
"conditions": {
"items": [
{
"items": "minecraft:brown_mushroom"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "rounded:brown_mushroom_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_log"
]
],
"rewards": {
"recipes": [
"rounded:brown_mushroom_block"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_log": {
"conditions": {
"items": [
{
"items": "rounded:lustershroom"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "rounded:lustershroom_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_log"
]
],
"rewards": {
"recipes": [
"rounded:lustershroom_block"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_log": {
"conditions": {
"items": [
{
"items": "minecraft:red_mushroom"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "rounded:red_mushroom_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_log"
]
],
"rewards": {
"recipes": [
"rounded:red_mushroom_block"
]
}
}
18 changes: 18 additions & 0 deletions src/main/resources/data/rounded/recipe/brown_mushroom_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "building",
"group": "rounded:mushroom_block",
"key": {
"#": {
"item": "minecraft:brown_mushroom"
}
},
"pattern": [
"##",
"##"
],
"result": {
"count": 1,
"id": "minecraft:brown_mushroom_block"
}
}
18 changes: 18 additions & 0 deletions src/main/resources/data/rounded/recipe/lustershroom_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "building",
"group": "rounded:mushroom_block",
"key": {
"#": {
"item": "rounded:lustershroom"
}
},
"pattern": [
"##",
"##"
],
"result": {
"count": 1,
"id": "rounded:lustershroom_block"
}
}
18 changes: 18 additions & 0 deletions src/main/resources/data/rounded/recipe/red_mushroom_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "building",
"group": "rounded:mushroom_block",
"key": {
"#": {
"item": "minecraft:red_mushroom"
}
},
"pattern": [
"##",
"##"
],
"result": {
"count": 1,
"id": "minecraft:red_mushroom_block"
}
}

0 comments on commit 2222a5e

Please sign in to comment.