-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a data map for vibration frequencies (#594)
- Loading branch information
1 parent
c21ccd2
commit 77c8899
Showing
5 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java.patch
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,22 @@ | ||
--- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java | ||
+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java | ||
@@ -48,6 +_,8 @@ | ||
GameEvent.RESONATE_14, | ||
GameEvent.RESONATE_15 | ||
}; | ||
+ /** @deprecated Neo: use the {@link net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps#VIBRATION_FREQUENCIES data map} instead. */ | ||
+ @Deprecated | ||
ToIntFunction<GameEvent> VIBRATION_FREQUENCY_FOR_EVENT = Util.make(new Object2IntOpenHashMap<>(), p_297981_ -> { | ||
p_297981_.defaultReturnValue(0); | ||
p_297981_.put(GameEvent.STEP, 1); | ||
@@ -101,7 +_,9 @@ | ||
VibrationSystem.User getVibrationUser(); | ||
|
||
static int getGameEventFrequency(GameEvent p_281355_) { | ||
- return VIBRATION_FREQUENCY_FOR_EVENT.applyAsInt(p_281355_); | ||
+ var data = p_281355_.builtInRegistryHolder().getData(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.VIBRATION_FREQUENCIES); | ||
+ // TODO 1.20.5 - remove fallback | ||
+ return data == null ? VIBRATION_FREQUENCY_FOR_EVENT.applyAsInt(p_281355_) : data.frequency(); | ||
} | ||
|
||
static GameEvent getResonanceEventByFrequency(int p_282105_) { |
169 changes: 169 additions & 0 deletions
169
src/generated/resources/data/neoforge/data_maps/game_event/vibration_frequencies.json
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,169 @@ | ||
{ | ||
"values": { | ||
"minecraft:block_activate": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:block_attach": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:block_change": { | ||
"frequency": 11 | ||
}, | ||
"minecraft:block_close": { | ||
"frequency": 9 | ||
}, | ||
"minecraft:block_deactivate": { | ||
"frequency": 9 | ||
}, | ||
"minecraft:block_destroy": { | ||
"frequency": 12 | ||
}, | ||
"minecraft:block_detach": { | ||
"frequency": 9 | ||
}, | ||
"minecraft:block_open": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:block_place": { | ||
"frequency": 13 | ||
}, | ||
"minecraft:container_close": { | ||
"frequency": 9 | ||
}, | ||
"minecraft:container_open": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:drink": { | ||
"frequency": 8 | ||
}, | ||
"minecraft:eat": { | ||
"frequency": 8 | ||
}, | ||
"minecraft:elytra_glide": { | ||
"frequency": 4 | ||
}, | ||
"minecraft:entity_action": { | ||
"frequency": 4 | ||
}, | ||
"minecraft:entity_damage": { | ||
"frequency": 7 | ||
}, | ||
"minecraft:entity_die": { | ||
"frequency": 15 | ||
}, | ||
"minecraft:entity_dismount": { | ||
"frequency": 5 | ||
}, | ||
"minecraft:entity_interact": { | ||
"frequency": 6 | ||
}, | ||
"minecraft:entity_mount": { | ||
"frequency": 6 | ||
}, | ||
"minecraft:entity_place": { | ||
"frequency": 14 | ||
}, | ||
"minecraft:equip": { | ||
"frequency": 5 | ||
}, | ||
"minecraft:explode": { | ||
"frequency": 15 | ||
}, | ||
"minecraft:flap": { | ||
"frequency": 1 | ||
}, | ||
"minecraft:fluid_pickup": { | ||
"frequency": 12 | ||
}, | ||
"minecraft:fluid_place": { | ||
"frequency": 13 | ||
}, | ||
"minecraft:hit_ground": { | ||
"frequency": 2 | ||
}, | ||
"minecraft:instrument_play": { | ||
"frequency": 3 | ||
}, | ||
"minecraft:item_interact_finish": { | ||
"frequency": 3 | ||
}, | ||
"minecraft:lightning_strike": { | ||
"frequency": 14 | ||
}, | ||
"minecraft:note_block_play": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:prime_fuse": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:projectile_land": { | ||
"frequency": 2 | ||
}, | ||
"minecraft:projectile_shoot": { | ||
"frequency": 3 | ||
}, | ||
"minecraft:resonate_1": { | ||
"frequency": 1 | ||
}, | ||
"minecraft:resonate_10": { | ||
"frequency": 10 | ||
}, | ||
"minecraft:resonate_11": { | ||
"frequency": 11 | ||
}, | ||
"minecraft:resonate_12": { | ||
"frequency": 12 | ||
}, | ||
"minecraft:resonate_13": { | ||
"frequency": 13 | ||
}, | ||
"minecraft:resonate_14": { | ||
"frequency": 14 | ||
}, | ||
"minecraft:resonate_15": { | ||
"frequency": 15 | ||
}, | ||
"minecraft:resonate_2": { | ||
"frequency": 2 | ||
}, | ||
"minecraft:resonate_3": { | ||
"frequency": 3 | ||
}, | ||
"minecraft:resonate_4": { | ||
"frequency": 4 | ||
}, | ||
"minecraft:resonate_5": { | ||
"frequency": 5 | ||
}, | ||
"minecraft:resonate_6": { | ||
"frequency": 6 | ||
}, | ||
"minecraft:resonate_7": { | ||
"frequency": 7 | ||
}, | ||
"minecraft:resonate_8": { | ||
"frequency": 8 | ||
}, | ||
"minecraft:resonate_9": { | ||
"frequency": 9 | ||
}, | ||
"minecraft:shear": { | ||
"frequency": 6 | ||
}, | ||
"minecraft:splash": { | ||
"frequency": 2 | ||
}, | ||
"minecraft:step": { | ||
"frequency": 1 | ||
}, | ||
"minecraft:swim": { | ||
"frequency": 1 | ||
}, | ||
"minecraft:teleport": { | ||
"frequency": 14 | ||
}, | ||
"minecraft:unequip": { | ||
"frequency": 4 | ||
} | ||
} | ||
} |
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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/VibrationFrequency.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,24 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.registries.datamaps.builtin; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.util.ExtraCodecs; | ||
|
||
/** | ||
* Data map value for {@linkplain NeoForgeDataMaps#VIBRATION_FREQUENCIES vibration frequencies}. | ||
* | ||
* @param frequency the vibration frequency of the game event | ||
*/ | ||
public record VibrationFrequency(int frequency) { | ||
public static final Codec<VibrationFrequency> FREQUENCY_CODEC = Codec.intRange(1, 15) | ||
.xmap(VibrationFrequency::new, VibrationFrequency::frequency); | ||
public static final Codec<VibrationFrequency> CODEC = ExtraCodecs.withAlternative( | ||
RecordCodecBuilder.create(in -> in.group( | ||
Codec.intRange(1, 15).fieldOf("frequency").forGetter(VibrationFrequency::frequency)).apply(in, VibrationFrequency::new)), | ||
FREQUENCY_CODEC); | ||
} |