Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve hand command functionality #186

Merged
merged 17 commits into from
Jul 23, 2024

Conversation

WaitingIdly
Copy link
Collaborator

@WaitingIdly WaitingIdly commented Jul 5, 2024

changes in this PR:

  • add an Object Mapper to get dimensions based on their name.
  • add an Object Mapper to get Villager Careers based on their name.
  • convert existing IngredientHelper.asGroovyCode methods into GroovyScriptCodeConverter.asGroovyCode, and add functionality:
    • when metadata is equal to Short.MAX_VALUE, display the ItemStack metadata as mod:item:*' instead of displaying it as mod:item', 32767.
    • format ItemStack and FluidStack to include item quantity in the generation text.
    • add a few helper methods for common operations.
    • add basic compat for biome, profession, career, dimension, entity, creativeTab, enchantment, potion, and block.
    • add instantiation helper and use it for PotionEffect.
    • add this functionality to a large number of mods (most mods which have Object Mappers)
  • split the /gs hand command into four commands:
    • /gs hand remains, but only uses an item in the main hand or offhand.
    • /gs looking ignores any item in a hand, and gets the block or entity being looked at, preferring to target an entity, if any exist.
    • /gs self uses the player and attaches no other information.
    • /gs info checks items in hand, then entity being looked at, then block being looked at, and then uses the self.
  • add a failure message describing what went wrong if no messages are logged after a command was executed.
  • create an info parser registry which is used to add tab complete, standardize the printing of information, and simplify adding new formats.
  • keep the existing GsHandEvent, and add entity and blockpos fields to it.
  • add a number of info parsers:
    • vanilla: biome, block, blockstate, creativetab, dimension, enchantment, entity, fluid, item, oredict, potioneffect, nbt, translation, villagercareer, and villagerprofession.
    • modded: aspect, brew, compound, constellation, element, gas, herb, infusion, jeitab, modifier, spell, tunnel, and weather.
  • use the parsers for command tab complete and filter, allowing showing only specific types or showing all but a few - eg /gs hand item block or /gs info -entity -dimension
  • fix tileentity information not respecting the pretty setting.
  • change the title formatting from being light purple to white.

tldr: standardize hand command and make it more usable

@brachy84 brachy84 added enhancement New feature or request refactor Something is rewritten labels Jul 22, 2024
Copy link
Member

@brachy84 brachy84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally not a fan of adding many classes with only ~5 lines of difference

Copy link
Member

@brachy84 brachy84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall nice, but

  1. the 'modid:name', meta -> 'modid:name:meta' needs to be changed back. I absolutly hate that. You could add a W = Short.MAX_VALUE global variable.
  2. As is said having 20+ classe with only ~5 lines of difference is a waste i think. Builders would be much more beatiful (debatable).
  3. I don't really like the colors of the printed info (the bold pink headers for example). I know this was not done in this pr.

@brachy84
Copy link
Member

Also where entity nbt

@brachy84
Copy link
Member

Error when i do /grs self

[14:32:19] [Server thread/WARN] [minecraft/CommandHandler]: Couldn't process command: grs self
java.lang.NullPointerException: Null string not allowed
	at java.util.Objects.requireNonNull(Objects.java:228) ~[?:1.8.0_372]
	at net.minecraft.nbt.NBTTagString.<init>(NBTTagString.java:20) ~[NBTTagString.class:?]
	at net.minecraft.nbt.NBTTagCompound.setString(NBTTagCompound.java:168) ~[NBTTagCompound.class:?]
	at net.minecraft.entity.Entity.serializeNBT(Entity.java:3644) ~[Entity.class:?]
	at com.cleanroommc.groovyscript.compat.vanilla.command.infoparser.InfoParserNBT.parse(InfoParserNBT.java:70) ~[InfoParserNBT.class:?]
	at com.cleanroommc.groovyscript.compat.vanilla.command.infoparser.GenericInfoParser.parse(GenericInfoParser.java:213) ~[GenericInfoParser.class:?]
	at com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage.lambda$parse$0(InfoParserPackage.java:178) ~[InfoParserPackage.class:?]
	at java.util.ArrayList.forEach(ArrayList.java:1259) ~[?:1.8.0_372]
	at com.cleanroommc.groovyscript.api.infocommand.InfoParserPackage.parse(InfoParserPackage.java:178) ~[InfoParserPackage.class:?]
	at com.cleanroommc.groovyscript.command.BaseInfoCommand.execute(BaseInfoCommand.java:145) ~[BaseInfoCommand.class:?]
	at net.minecraftforge.server.command.CommandTreeBase.execute(CommandTreeBase.java:170) ~[CommandTreeBase.class:?]
	at net.minecraft.command.CommandHandler.tryExecute(CommandHandler.java:124) [CommandHandler.class:?]
	at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:96) [CommandHandler.class:?]
	at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:1005) [NetHandlerPlayServer.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:981) [NetHandlerPlayServer.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(CPacketChatMessage.java:47) [CPacketChatMessage.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(CPacketChatMessage.java:8) [CPacketChatMessage.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_372]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_372]
	at net.minecraft.util.Util.runTask(Util.java:50) [Util.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:797) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:742) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:591) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372]

@brachy84 brachy84 merged commit abe8bc6 into CleanroomMC:master Jul 23, 2024
@WaitingIdly WaitingIdly deleted the more-in-hand branch July 23, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Something is rewritten
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants