Jump to content

[1.10] Scoreboard Physical Virtual Currency Design Questions


Durand1w

Recommended Posts

Thanks in advance for your time.  I have a few questions around the scoreboard system and implementing a currency system.  At the moment, I already have 3 physical coins in game, a block that removes the coin and runs a set time command for users.  I also have the scoreboard command working to add/remove points to the scoreboard on the list slot.  But, I have a few questions which may make this effort void.

 

-Is the scoreboard restricted to OPs on forge in multiplayer?

-Does having the command execute from within the mod, change the players ability to have it execute?

 

Minecraft.getMinecraft().thePlayer.sendChatMessage("/scoreboard players add " + playerIn.getName() + " Money 10");

 

-Is there a better approach than the command above  (/trigger command or)?

-Does anyone know of any issues with scoreboards for permanent worlds, rather than short minigames (value loss, resets)?

 

Ideally, I want to replace our virtual Cauldron Vault economy with scoreboards and physical coins, but I need to ensure that I'm not on a wild goose chase or that players are going to be able to spam chat commands to get rich quick.  Thanks for any suggestions/tips/known problems.

Link to comment
Share on other sites

Yes the vanilla scoreboard command is restricted to level 2 ops.

Does having the command execute from within the mod, change the players ability to have it execute?

No this will not change whether or not the player can execute it.

Is there a better approach than the command above  (/trigger command or)?

Well you can actually just code your own screen overlay and add a capability to the player to store the money.

Does anyone know of any issues with scoreboards for permanent worlds, rather than short minigames (value loss, resets)?

Scoreboards don't reset or loose values on there own.

 

Overall why are you using the Scoreboard when you have the ability to create anything and add it to Minecraft?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Thanks for the fast reply. 

 

So then my problem is to OP and deOP players each time they use a coin with a banking station.  I'm not sure if there is a way to avoid that since they could spam deposit a stack of coins.

 

On using the scoreboard, it's mostly out of convenience.  It already exists, it's light weight and eliminates the need for custom packets, mySQL database or other complication of the core game.  It also increases the likelyhood of me supporting it easily between world upgrades. 

 

This game over the last 5.5 years has resulted in me learning to create and manage a community website, learn Gimp for texturing, and create over 600+ blocks/models between two mods for our small server.  Those are not things you learn doing project technical support, but it's fun to see people build/adventure with the end result.

Link to comment
Share on other sites

  • 3 weeks later...

I ended up using the methods that the command use to bypass the need to OP/deOP players.  It works fine in single player, but I'm struggling to understand how to separate the scoreboard methods between server and client and to trigger a save of the value.  I don't believe I need to create a custom packet handler, since there should be an existing method to write score updates.

 

Item Code:

Spoiler

else if (iblockstate.getBlock() == TyrDropBlocks.banking_station)
        {
            double x = playerIn.posX;
            double y = playerIn.posY;
            double z = playerIn.posZ;
            playerIn.worldObj.playSound(null , x, y, z, TyrDropSounds.coins_sliding, SoundCategory.BLOCKS , 1.0F, 1.0F);
            Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();         
            ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(0);
            Score score = scoreboard.getOrCreateScore(playerIn.getName(), scoreobjective);
            score.increaseScore(10);
            playerIn.addChatComponentMessage(new TextComponentString("Bank Balance:  $" + TextFormatting.DARK_GREEN + NumberFormat.getNumberInstance(Locale.US).format(Integer.valueOf(score.getScorePoints()))));
            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }  
            return EnumActionResult.SUCCESS;

 

When on a server, the client shows the change in score, plays the sound and shows the chat message with the correct score.  It does not save and my score is reset when I relog.  I know it is partly due to server vs. client.  The server shows an error trying to run the Scoreboard scoreboard = (line 94) on the client side.  I have attempted numerous If world.isRemote variations to reorganize the code, so I'm not sure if I'm missing a save statement or if I should be using ServerScoreboard or something else entirely.

 

Server Log showing issue running scoreboard on client side:

Spoiler

[08:19:12] [Server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
    at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_91]
    at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_91]
    at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?]
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:668) [MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:387) [ld.class:?]
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:613) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
    at com.tyr.drops.ItemTyrLapisTenCoin.func_180614_a(ItemTyrLapisTenCoin.java:94) ~[ItemTyrLapisTenCoin.class:?]
    at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:780) ~[ForgeHooks.class:?]
    at net.minecraft.item.ItemStack.func_179546_a(ItemStack.java:144) ~[adz.class:?]
    at net.minecraft.server.management.PlayerInteractionManager.func_187251_a(PlayerInteractionManager.java:493) ~[lv.class:?]
    at net.minecraft.network.NetHandlerPlayServer.func_184337_a(NetHandlerPlayServer.java:679) ~[me.class:?]
    at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.func_148833_a(SourceFile:55) ~[jj.class:?]
    at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.func_148833_a(SourceFile:11) ~[jj.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[fl$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_91]
    at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_91]
    at net.minecraft.util.Util.func_181617_a(SourceFile:45) ~[h.class:?]
    ... 5 more

 

Image of what I have working:

Scoreboard Testing

 

Thanks for any assistance.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.