Skip to content

Commit 03c1884

Browse files
committed
Replace all hallucinations with fish on april fools day
1 parent 5550ba3 commit 03c1884

File tree

4 files changed

+42
-16
lines changed

4 files changed

+42
-16
lines changed

common/src/main/java/robotgiggle/hierophantics/Hierophantics.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import at.petrak.hexcasting.common.lib.HexAttributes
2323
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
2424
import at.petrak.hexcasting.api.casting.iota.IotaType;
2525
import at.petrak.hexcasting.api.casting.iota.Iota
26+
import java.time.LocalDate
2627

2728
object Hierophantics {
2829
const val MOD_ID = "hierophantics"
@@ -42,6 +43,12 @@ object Hierophantics {
4243
@JvmStatic
4344
fun id(string: String) = Identifier(MOD_ID, string)
4445

46+
@JvmStatic
47+
fun isAprilFools(): Boolean {
48+
val today = LocalDate.now()
49+
return (today.monthValue == 4 && today.dayOfMonth == 1)
50+
}
51+
4552
fun init() {
4653
HierophanticsAdvancements.init()
4754
HierophanticsNetworking.init()

common/src/main/java/robotgiggle/hierophantics/HierophanticsClient.kt

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ object HierophanticsClient {
2020
var clientOwnedMinds = 0;
2121

2222
var scalingTimestamp = 0L;
23+
24+
// item categories for hallucinations
25+
val fish = listOf(
26+
Items.COD, Items.SALMON, Items.PUFFERFISH, Items.TROPICAL_FISH
27+
)
28+
val mediaItems = listOf(
29+
HexItems.AMETHYST_DUST, Items.AMETHYST_SHARD,
30+
HexItems.CHARGED_AMETHYST, HexItems.QUENCHED_SHARD
31+
);
32+
val mediaBlocks = listOf(
33+
Items.AMETHYST_BLOCK, Items.BUDDING_AMETHYST,
34+
HexBlocks.QUENCHED_ALLAY.asItem()
35+
);
2336

2437
fun init() {
2538
HierophanticsConfig.initClient()
@@ -45,6 +58,7 @@ object HierophanticsClient {
4558
fun hallucinateItem(original: ItemStack): ItemStack {
4659
val config = HierophanticsConfig.client.itemHallucinations;
4760

61+
// hallucination rng is based on the item's hashcode and the current game time
4862
val hash = original.hashCode();
4963
val timeScramble = (ClientTickCounter.ticksInGame/(180 + (hash % 40))).toInt();
5064
val rng = Math.abs((hash + timeScramble * (150 + (hash % 300))) % 10000);
@@ -55,7 +69,9 @@ object HierophanticsClient {
5569
config.maxEmeraldRate
5670
);
5771
if (rng < emeraldChance * 10000) {
58-
if (original.getItem() is BlockItem)
72+
if (Hierophantics.isAprilFools())
73+
return ItemStack(fish.get(rng % 4), original.getCount());
74+
else if (original.getItem() is BlockItem)
5975
return ItemStack(Items.EMERALD_BLOCK, original.getCount());
6076
else
6177
return ItemStack(Items.EMERALD, original.getCount());
@@ -64,20 +80,14 @@ object HierophanticsClient {
6480
// hallucinate media items due to Manifold Mind
6581
if (MinecraftClient.getInstance().player!!.hasStatusEffect((HierophanticsEffects.MEDIA_DISCOUNT.value)) ) {
6682
if (rng > (1 - config.mediaRate) * 10000) {
67-
var items = listOf(
68-
HexItems.AMETHYST_DUST, Items.AMETHYST_SHARD,
69-
HexItems.CHARGED_AMETHYST, HexItems.QUENCHED_SHARD
70-
);
71-
var blocks = listOf(
72-
Items.AMETHYST_BLOCK, Items.BUDDING_AMETHYST,
73-
HexBlocks.QUENCHED_ALLAY.asItem()
74-
);
75-
if (original.getItem() is BlockItem)
76-
return ItemStack(blocks.get(rng % 3), original.getCount());
83+
if (Hierophantics.isAprilFools())
84+
return ItemStack(fish.get(rng % 4), original.getCount());
85+
else if (original.getItem() is BlockItem)
86+
return ItemStack(mediaBlocks.get(rng % 3), original.getCount());
7787
else if (original.getItem() is ToolItem || original.getItem() is ItemStaff)
7888
return ItemStack(HexItems.STAFF_QUENCHED, original.getCount());
7989
else
80-
return ItemStack(items.get(rng % 4), original.getCount());
90+
return ItemStack(mediaItems.get(rng % 4), original.getCount());
8191
}
8292
}
8393

common/src/main/java/robotgiggle/hierophantics/mixin/PlayerEntityMixin.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import robotgiggle.hierophantics.blocks.FlayBedBlock;
1313
import robotgiggle.hierophantics.inits.HierophanticsConfig;
1414
import robotgiggle.hierophantics.HierophanticsClient;
15-
1615
import robotgiggle.hierophantics.Hierophantics;
1716

1817
import org.spongepowered.asm.mixin.Mixin;
@@ -75,7 +74,11 @@ private void playVillagerHurtNoise(CallbackInfoReturnable<SoundEvent> ci) {
7574
if (player.getWorld().isClient()) minds = HierophanticsClient.clientOwnedMinds;
7675
else minds = HieroServerState.getPlayerState(player).getOwnedMinds();
7776
if (player.getRandom().nextDouble() < 0.3 - 1.0/(minds + 3)) {
78-
ci.setReturnValue(SoundEvents.ENTITY_VILLAGER_HURT);
77+
if (Hierophantics.isAprilFools()) {
78+
ci.setReturnValue(SoundEvents.ENTITY_SALMON_HURT);
79+
} else {
80+
ci.setReturnValue(SoundEvents.ENTITY_VILLAGER_HURT);
81+
}
7982
}
8083
}
8184
}

common/src/main/java/robotgiggle/hierophantics/mixin/client/AbstractClientPlayerEntityMixin.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,21 @@ private void hallucinateAudio(CallbackInfo ci) {
4040
);
4141
if (rand.nextDouble() < villagerChance) {
4242
Vec3d source = randomSpherePoint((rand.nextDouble() * 2.5) + 3.5, rand).add(cPlayer.getPos());
43-
cPlayer.clientWorld.playSound(source.x, source.y, source.z, SoundEvents.ENTITY_VILLAGER_AMBIENT, SoundCategory.PLAYERS, 0.5f, 1f, true);
43+
if (Hierophantics.isAprilFools()) {
44+
cPlayer.clientWorld.playSound(source.x, source.y, source.z, SoundEvents.ENTITY_SALMON_FLOP, SoundCategory.PLAYERS, 0.8f, 1f, true);
45+
} else {
46+
cPlayer.clientWorld.playSound(source.x, source.y, source.z, SoundEvents.ENTITY_VILLAGER_AMBIENT, SoundCategory.PLAYERS, 0.5f, 1f, true);
47+
}
4448
hallucinationCooldown = config.getCooldown();
4549
return;
4650
}
4751

4852
// hallucinate allay nosies and amethyst chimes due to Manifold Mind
4953
if (rand.nextDouble() < config.getAllayRate() && cPlayer.hasStatusEffect(HierophanticsEffects.MEDIA_DISCOUNT.getValue())) {
5054
Vec3d source = randomSpherePoint((rand.nextDouble() * 2.5) + 3, rand).add(cPlayer.getPos());
51-
if (rand.nextDouble() < 0.5) {
55+
if (Hierophantics.isAprilFools()) {
56+
cPlayer.clientWorld.playSound(source.x, source.y, source.z, SoundEvents.ENTITY_SALMON_FLOP, SoundCategory.PLAYERS, 0.8f, 1f, true);
57+
} else if (rand.nextDouble() < 0.5) {
5258
cPlayer.clientWorld.playSound(source.x, source.y, source.z, SoundEvents.BLOCK_AMETHYST_BLOCK_CHIME, SoundCategory.PLAYERS, 1f, (0.5f + rand.nextFloat() * 1.2F), true);
5359
} else {
5460
cPlayer.clientWorld.playSound(source.x, source.y, source.z, SoundEvents.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM, SoundCategory.PLAYERS, 0.3f, 1f, true);

0 commit comments

Comments
 (0)