Skip to content

Commit

Permalink
AGONY AUDIO
Browse files Browse the repository at this point in the history
  • Loading branch information
adenator0 committed Dec 10, 2024
1 parent 6986774 commit 5c2ec32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.block.Block;
import com.mojang.serialization.MapCodec;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.particle.DustParticleEffect;
Expand All @@ -15,10 +16,13 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;

public class Agony extends Block {
public static final MapCodec<Agony> CODEC = createCodec(Agony::new);
protected static final VoxelShape SHAPE = Block.createCuboidShape((double)1.0F, (double)0.0F, (double)1.0F, (double)16.0F, (double)15.0F, (double)16.0F);

public MapCodec<Agony> getCodec() {
return CODEC;
Expand All @@ -28,21 +32,19 @@ public Agony(AbstractBlock.Settings settings) {
super(settings);
}

protected VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return SHAPE;
}

public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
if (!entity.bypassesSteppingEffects() && entity instanceof LivingEntity livingEntity) {
//DamageSource damageSource = new DamageSource( //this sucks
// world.getRegistryManager()
// .get(RegistryKeys.DAMAGE_TYPE)
// .entryOf(ModDamageTypes.AGONY_DAMAGE));
livingEntity.serverDamage(entity.getDamageSources().create(ModDamageTypes.AGONY_DAMAGE, null), livingEntity.getMaxHealth() / 7);
if (world instanceof ServerWorld serverWorld) {
serverWorld.spawnParticles(new DustParticleEffect(ColorHelper.fromFloats(1, 1, 0, 0), 2), livingEntity.getPos().getX(), livingEntity.getPos().getY(), livingEntity.getPos().getZ(), 4, 0.2, 0, 0.2, 0);
}
if (!world.isClient) {
//todo find a better way to do this so that it doesnt run every single tick
//world.playSound(null, pos, ModSounds.BLOCK_AGONY_ACTIVATE_FANGSNAP, SoundCategory.BLOCKS);
//world.playSound(null, pos, ModSounds.BLOCK_AGONY_ACTIVATE_ZOMBIESTEP, SoundCategory.BLOCKS);

if (!world.isClient && (livingEntity.hurtTime == 10)) {
world.playSound(null, pos, ModSounds.BLOCK_AGONY_ACTIVATE_FANGSNAP, SoundCategory.BLOCKS);
world.playSound(null, pos, ModSounds.BLOCK_AGONY_ACTIVATE_ZOMBIESTEP, SoundCategory.BLOCKS);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/svbcr/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"item.svbcr.radioactive_bucket": "Radioactive Waste Barrel",

"itemGroup.svbcr.functional_blocks": "Serverboss Functional Blocks",
"itemGroup.svbcr.decorational_blocks": "Serverboss Decorational Blocks",
"itemGroup.svbcr.decorational_blocks": "Serverboss Decoration Blocks",

"subtitles.block.agony.activate": "Agony"
}

0 comments on commit 5c2ec32

Please sign in to comment.