Skip to content

Commit

Permalink
it's something
Browse files Browse the repository at this point in the history
  • Loading branch information
DaFuqs committed Jan 6, 2025
1 parent 25bf1af commit 53836ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
23 changes: 8 additions & 15 deletions src/main/java/de/dafuqs/spectrum/events/SpectrumGameEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import de.dafuqs.spectrum.*;
import net.minecraft.registry.*;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.*;
import net.minecraft.registry.entry.*;
import net.minecraft.world.event.*;

import java.util.*;

public class SpectrumGameEvents {

public static RegistryEntry<GameEvent> ENTITY_SPAWNED;
Expand All @@ -19,17 +16,13 @@ public class SpectrumGameEvents {
public static RegistryEntry<GameEvent> WIRELESS_REDSTONE_SIGNAL;

public static void register() {
ENTITY_SPAWNED = register("entity_spawned");
BLOCK_CHANGED = register("block_changed");

HUMMINGSTONE_HUMMING = register("hummingstone_humming");
HUMMINGSTONE_HYMN = register("hummingstone_hymn");

WIRELESS_REDSTONE_SIGNAL = register("wireless_redstone_signal");
}

private static RegistryEntry<GameEvent> register(String id) {
return register(id, 16);
ENTITY_SPAWNED = register("entity_spawned", 16);
BLOCK_CHANGED = register("block_changed", 16);

HUMMINGSTONE_HUMMING = register("hummingstone_humming", 16);
HUMMINGSTONE_HYMN = register("hummingstone_hymn", 16);

WIRELESS_REDSTONE_SIGNAL = register("wireless_redstone_signal", 16);
}

private static RegistryEntry<GameEvent> register(String id, int range) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static boolean processBlock(@NotNull ServerWorld world, @Nullable Entity

if (state.getBlock().getBlastResistance() <= 9) {
if (random.nextFloat() < 0.15F) {
world.playSound(null, center.getX(), center.getY(), center.getZ(), block.getSoundGroup(state).getBreakSound(), SoundCategory.BLOCKS, 2F, 0.8F + random.nextFloat() * 0.5F);
world.playSound(null, center.getX(), center.getY(), center.getZ(), state.getSoundGroup().getBreakSound(), SoundCategory.BLOCKS, 2F, 0.8F + random.nextFloat() * 0.5F);
}

if (block.shouldDropItemsOnExplosion(explosion)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private boolean tryPlaceBlock(BlockState blockState, World world, BlockPos pos,

world.syncWorldEvent(null, WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(targetState));
world.playSound(null, pos, targetState.getSoundGroup().getPlaceSound(), SoundCategory.PLAYERS, 1.0F, 0.9F + world.getRandom().nextFloat() * 0.2F);
world.syncWorldEvent(WorldEvents.PLANT_FERTILIZED, pos, 0); // the particle here is jank
world.syncWorldEvent(WorldEvents.BONE_MEAL_USED, pos, 0);
return true;
}
return false;
Expand All @@ -268,16 +268,16 @@ private static void spawnParticlesAndEffect(World world, BlockPos blockPos) {
if (blockState.isIn(SpectrumBlockTags.NATURES_STAFF_STACKABLE)) {
int i = 0;
while (world.getBlockState(blockPos.up(i)).isOf(blockState.getBlock())) {
world.syncWorldEvent(WorldEvents.PLANT_FERTILIZED, blockPos.up(i), 0);
world.syncWorldEvent(WorldEvents.BONE_MEAL_USED, blockPos.up(i), 0);
i++;
}
world.syncWorldEvent(WorldEvents.PLANT_FERTILIZED, blockPos, 0);
world.syncWorldEvent(WorldEvents.BONE_MEAL_USED, blockPos, 0);
BoneMealItem.createParticles(world, blockPos.up(i + 1), 5);
for (int j = 1; world.getBlockState(blockPos.down(j)).isOf(blockState.getBlock()); j++) {
world.syncWorldEvent(WorldEvents.PLANT_FERTILIZED, blockPos.down(j), 0);
world.syncWorldEvent(WorldEvents.BONE_MEAL_USED, blockPos.down(j), 0);
}
} else {
world.syncWorldEvent(WorldEvents.PLANT_FERTILIZED, blockPos, 0);
world.syncWorldEvent(WorldEvents.BONE_MEAL_USED, blockPos, 0);
}
}

Expand Down

0 comments on commit 53836ee

Please sign in to comment.