-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Snowball hit sounds + changelog file
- Loading branch information
1 parent
f70e2ab
commit e7936b7
Showing
7 changed files
with
92 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/starfish_studios/seasons_greetings/mixin/SnowballMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/starfish_studios/seasons_greetings/registry/SGSoundEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"seasonsgreetings.subtitles.entity.snowball.hit": "Snowball hits" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |