Skip to content

Commit

Permalink
Snowball hit sounds + changelog file
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Nov 30, 2024
1 parent f70e2ab commit e7936b7
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 12 deletions.
9 changes: 9 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CHANGELOG

1. **Snow Golems** can now be interacted with set items.
- Interacting with **_any color_** of Carpets will add a scarf of that color.
- Interacting with **_Carrots, Beetroots, Potatoes, or Wheat_** will add noses or hair made of that material.
- This can only be done if they do not have a Pumpkin head.
- Interacting with **_Carved Pumpkins_** will add back their Pumpkin head.
- Items can be sheared off of Snow Golems, and will prioritize head items over scarves.
2. **Snowballs** now have sounds when they hit things.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.starfish_studios.seasons_greetings.mixin;

import com.starfish_studios.seasons_greetings.registry.SGSoundEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Snowball;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Snowball.class)
public abstract class SnowballMixin extends ThrowableItemProjectile {
public SnowballMixin(EntityType<? extends ThrowableItemProjectile> entityType, Level level) {
super(entityType, level);
}

@Inject(method = "onHit", at = @At("HEAD"))
private void sg$onHit(HitResult hitResult, CallbackInfo ci) {
if (!this.level().isClientSide) {
this.playSound(SGSoundEvents.SNOWBALL_HIT, 0.5F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class SGRegistry {

public static void registerAll() {
// SeasonsGreetingsEntityType.registerEntities();
SGSoundEvents.registerSoundEvents();
SGPotions.registerPotions();
SGItems.registerItems();
SGCreativeTabs.registerCreativeTabs();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.starfish_studios.seasons_greetings.registry;

import com.starfish_studios.seasons_greetings.SeasonsGreetings;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;

public class SGSoundEvents {
public static final SoundEvent SNOWBALL_HIT = registerSoundEvent("entity.snowball.hit");
// }

public static void registerSoundEvents() {
}

private static SoundEvent registerSoundEvent(String id) {
ResourceLocation resourceLocation = SeasonsGreetings.id(id);
return Registry.register(BuiltInRegistries.SOUND_EVENT, resourceLocation, SoundEvent.createVariableRangeEvent(resourceLocation));
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/seasonsgreetings/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"seasonsgreetings.subtitles.entity.snowball.hit": "Snowball hits"
}
10 changes: 10 additions & 0 deletions src/main/resources/assets/seasonsgreetings/sounds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"entity.snowball.hit": {
"sounds": [
"entity/snowman/hurt1",
"entity/snowman/hurt2",
"entity/snowman/hurt3"
],
"subtitle": "seasonsgreetings.subtitles.entity.snowball.hit"
}
}
25 changes: 13 additions & 12 deletions src/main/resources/seasonsgreetings.mixins.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"required": true,
"package": "com.starfish_studios.seasons_greetings.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"SnowGolemMixin"
],
"injectors": {
"defaultRequire": 1
},
"client": [
"SnowGolemModelMixin",
"SnowGolemRendererMixin"
"required": true,
"package": "com.starfish_studios.seasons_greetings.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"SnowballMixin",
"SnowGolemMixin"
],
"injectors": {
"defaultRequire": 1
},
"client": [
"SnowGolemModelMixin",
"SnowGolemRendererMixin"
]
}

0 comments on commit e7936b7

Please sign in to comment.