Skip to content

Commit

Permalink
Special case for 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dianliang233 committed Jan 17, 2024
1 parent 7f26ce2 commit 1f4e743
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tools/seedHashcode/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ref } from 'vue'
import { CdxTextInput } from '@wikimedia/codex'
import Field from '@/components/Field.vue'
const seed = ref('')
const seed = ref('Minecraft Wiki')
// Java String.hashCode() implementation
function hashCode(s: string) {
let h = 0
Expand All @@ -16,6 +16,10 @@ function hashCode(s: string) {
<Field>
<template #heading>Convert a string to actual seed</template>
<CdxTextInput v-model="seed" />
Actual seed: <code>{{ hashCode(seed) }}</code>
Actual seed: <code v-if="seed === ''">{{ hashCode(seed) }}</code
><template v-else
>This should be 0, but it is an empty string, so Minecraft actually generates a random
number.</template
>
</Field>
</template>

0 comments on commit 1f4e743

Please sign in to comment.