generated from nea89o/Forge1.8.9Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.5 inheritance improvement, expression evaluator
Implemented recursive descent parser to evaluate arithmetic expressions including suffixes "k", "m", "b". Updated the base feature classes and added a specific class for text overlay features that extends the base renderable feature.
- Loading branch information
Showing
14 changed files
with
367 additions
and
35 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
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/com/github/shmoe6/melody/command/EvaluateCommand.kt
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,33 @@ | ||
package com.github.shmoe6.melody.command | ||
|
||
import com.github.shmoe6.melody.handlers.math.ArithmeticExpressionHandler | ||
import net.minecraft.command.CommandBase | ||
import net.minecraft.command.ICommandSender | ||
import net.minecraft.util.ChatComponentText | ||
import java.util.* | ||
|
||
object EvaluateCommand : CommandBase() { | ||
override fun getCommandName(): String { | ||
return "evaluate" | ||
} | ||
|
||
override fun getCommandUsage(sender: ICommandSender?): String { | ||
return "" | ||
} | ||
|
||
override fun processCommand(sender: ICommandSender?, args: Array<out String>?) { | ||
|
||
var expr = "" | ||
args?.forEach { expr += it } | ||
|
||
sender?.addChatMessage(ChatComponentText("§5[Melody] §f$expr evaluates to: ${ArithmeticExpressionHandler.handle(expr)}")) | ||
} | ||
|
||
override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean { | ||
return true | ||
} | ||
|
||
override fun getCommandAliases(): MutableList<String> { | ||
return Arrays.asList("eval", "expr", "calcexpr") | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/github/shmoe6/melody/features/MelodyFeatureOverlayText.kt
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,13 @@ | ||
package com.github.shmoe6.melody.features | ||
|
||
import gg.essential.elementa.components.UIText | ||
|
||
|
||
interface MelodyFeatureOverlayText : MelodyFeatureRenderable { | ||
|
||
var xPos: Int | ||
var yPos: Int | ||
var selectedInEditGui: Boolean | ||
override val mainUiComponent: UIText | ||
} | ||
|
5 changes: 1 addition & 4 deletions
5
src/main/kotlin/com/github/shmoe6/melody/features/MelodyFeatureRenderable.kt
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,11 +1,8 @@ | ||
package com.github.shmoe6.melody.features | ||
|
||
import gg.essential.elementa.UIComponent | ||
import gg.essential.elementa.components.UIText | ||
|
||
interface MelodyFeatureRenderable : MelodyFeature { | ||
|
||
var xPos: Int | ||
var yPos: Int | ||
var mainUiComponent: UIText | ||
val mainUiComponent: UIComponent | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/com/github/shmoe6/melody/features/dungeons/DeathNotifier.kt
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 @@ | ||
package com.github.shmoe6.melody.features.dungeons | ||
|
||
import com.github.shmoe6.melody.Melody | ||
import com.github.shmoe6.melody.core.MelodyConfig | ||
import com.github.shmoe6.melody.features.MelodyFeature | ||
import net.minecraft.client.Minecraft | ||
import net.minecraftforge.client.event.ClientChatReceivedEvent | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
object DeathNotifier : MelodyFeature { | ||
|
||
@SubscribeEvent | ||
fun onDeath(event: ClientChatReceivedEvent) { | ||
if (!isFeatureEnabled() || Melody.currentWorld != "The Catacombs") return | ||
|
||
// TODO: play sound, add functionality | ||
} | ||
|
||
override fun isFeatureEnabled(): Boolean { | ||
return MelodyConfig.dungeonDeathNotifierEnabled | ||
} | ||
} |
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
Oops, something went wrong.