Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
package de.dafuqs.spectrum.blocks.decoration;

import com.mojang.serialization.*;
import de.dafuqs.spectrum.registries.*;
import net.minecraft.core.*;
import net.minecraft.core.particles.*;
import net.minecraft.core.registries.*;
import net.minecraft.resources.*;
import net.minecraft.server.level.*;
import net.minecraft.sounds.*;
import net.minecraft.tags.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraft.world.entity.player.*;
import net.minecraft.world.item.*;
import net.minecraft.world.item.context.*;
import net.minecraft.world.level.*;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.*;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraft.world.level.pathfinder.*;
import net.minecraft.world.phys.*;
import net.minecraft.world.phys.shapes.*;
import net.neoforged.bus.api.*;
import net.neoforged.neoforge.common.*;
import net.neoforged.neoforge.event.entity.player.*;
import org.jspecify.annotations.*;

public class GemstoneChimeBlock extends Block {
Expand All @@ -21,11 +35,14 @@ public class GemstoneChimeBlock extends Block {

protected final SoundEvent soundEvent;
protected final ParticleOptions particleEffect;
//Is Muted holder
public static final BooleanProperty IS_MUTED = BooleanProperty.create("is_muted");

public GemstoneChimeBlock(Properties settings, SoundEvent soundEvent, ParticleOptions particleEffect) {
super(settings);
this.soundEvent = soundEvent;
this.particleEffect = particleEffect;
registerDefaultState(stateDefinition.any().setValue(IS_MUTED, false));
}

@Override
Expand All @@ -36,16 +53,19 @@ public GemstoneChimeBlock(Properties settings, SoundEvent soundEvent, ParticleOp

@Override
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
super.animateTick(state, world, pos, random);

world.addParticle(particleEffect,
pos.getX() + 0.25 + random.nextDouble() * 0.5,
pos.getY() + 0.15 + random.nextDouble() * 0.5,
pos.getZ() + 0.25 + random.nextDouble() * 0.5,
0, -0.02 - random.nextDouble() * 0.025, 0);

if (random.nextFloat() < 0.2) {
world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), soundEvent, SoundSource.BLOCKS, 0.7F + random.nextFloat() * 0.4F, 0.75F + random.nextFloat() * 0.5F, true);
//Check if it's muted before running the following code.
boolean muteState = state.getValue(IS_MUTED);
if (!muteState) {
super.animateTick(state, world, pos, random);
world.addParticle(particleEffect,
pos.getX() + 0.25 + random.nextDouble() * 0.5,
pos.getY() + 0.15 + random.nextDouble() * 0.5,
pos.getZ() + 0.25 + random.nextDouble() * 0.5,
0, -0.02 - random.nextDouble() * 0.025, 0);

if (random.nextFloat() < 0.2) {
world.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), soundEvent, SoundSource.BLOCKS, 0.7F + random.nextFloat() * 0.4F, 0.75F + random.nextFloat() * 0.5F, true);
}
}
}

Expand Down Expand Up @@ -74,4 +94,37 @@ public ParticleOptions getParticleEffect() {
return this.particleEffect;
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder){
pBuilder.add(IS_MUTED);
}

//Mute with wool, Unmute with Empty
@Override
public ItemInteractionResult useItemOn(ItemStack handStack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
//If the hand contains an item version of what is in the block tag #c:wools, switch block state to the muted variant and set isMuted to true

if (handStack.is(SpectrumItemTags.WOOLS)){
setMuted(state.setValue(IS_MUTED, true), world, pos);
return ItemInteractionResult.SUCCESS;
}else if (handStack.isEmpty()){
setMuted(state.setValue(IS_MUTED, false), world, pos);
return ItemInteractionResult.SUCCESS;
}
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;

}
//
static void setMuted(BlockState state, Level world, BlockPos pos){
world.setBlockAndUpdate(pos, state);
}

//Additional Helper for BlockStates
@Override
@Nullable
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
// code that determines which state will be used when
// placing down this block, depending on the BlockPlaceContext
return defaultBlockState();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class SpectrumItemTags {
// "c" namespace
public static final TagKey<Item> SKULLS = conventional("skulls");
public static final TagKey<Item> FRUITS = conventional("foods/fruit");
public static final TagKey<Item> WOOLS = conventional("wools");

// "spectrum" namespace
public static final TagKey<Item> FISHING_RODS = spectrum("fishing_rods");
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/spectrum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,8 @@
"book.spectrum.guidebook.gemstone_armor.page5.text": "Gives me a short burst of Speed and Invisibility when hit, allowing me to retreat. Perfect for ranged combat.",
"book.spectrum.guidebook.gemstone_chimes.name": "Gemstone Chimes",
"book.spectrum.guidebook.gemstone_chimes.page0.text": "Having tinkered with the gems long enough, I find myself able to shape these fragile resources in the finest of ways. Slowly swaying in the breeze, the chimes' sounds remind me of the beginning of my journey – the first time I set foot in a geode. I remember it well. What a time it was!\\\nEach chime emits the soothing sound of its corresponding gemstone.",
"book.spectrum.guidebook.gemstone_chimes.muting.name": "Chime Muting",
"book.spectrum.guidebook.gemstone_chimes.page1.text": "If for some reason it's getting on my nerves, I can silence them by interacting with a little bit of wool, and I can undo this with bare hands.",
"book.spectrum.guidebook.gemstone_glass.name": "Gemstone Glass",
"book.spectrum.guidebook.gemstone_glass.page0.text": "Gemstones are already slightly transparent by nature. What could be more natural than using them to make a kind of glass?\\\nI can also make matching Glass Panes from them.",
"book.spectrum.guidebook.gemstone_glass.page1.text": "I can build them out of every gemstone I found.",
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/data/c/tags/item/wools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"values": [
"minecraft:black_wool",
"minecraft:blue_wool",
"minecraft:brown_wool",
"minecraft:cyan_wool",
"minecraft:gray_wool",
"minecraft:green_wool",
"minecraft:light_blue_wool",
"minecraft:light_gray_wool",
"minecraft:lime_wool",
"minecraft:magenta_wool",
"minecraft:orange_wool",
"minecraft:pink_wool",
"minecraft:purple_wool",
"minecraft:red_wool",
"minecraft:white_wool",
"minecraft:yellow_wool"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"title": "book.spectrum.guidebook.gemstone_chimes.name",
"text": "book.spectrum.guidebook.gemstone_chimes.page0.text"
},
{
"type": "modonomicon:text",
"title": "book.spectrum.guidebook.gemstone_chimes.muting.name",
"text": "book.spectrum.guidebook.gemstone_chimes.page1.text"
},
{
"type": "spectrum:pedestal_crafting",
"title": "container.spectrum.rei.pedestal_recipe",
Expand Down
Loading