Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] How to add gold?


HappyKiller1O1
 Share

Recommended Posts

Hey! So, to get right to the point I am trying to add a currency to my mod that will be saved digitally. What I mean is when you pick up a coin it will add it to your overall amount and such. I easily did this in 1.6.4 but in 1.7.10 that's not the case. I just need someone to explain to me how to use the new packet system to communicate with the server about how many coins a specific player has and to add or subtract accordingly. I'm not asking to be hand-fed code here, just for someone to explain how to use the packet system in 1.7.10 with maybe a few examples.

 

Thank you in advance,

 

- Joey

 

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

I have seen that tutorial before but, I still couldn't figure out how to tell the server the player got a coin then, add it to their overall amount and update them. I'm sorry if I seem ignorant towards programming; packets just always go over my head.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

So, to add gold to someone; I'd send a packet to the server to run the "addGold" method in my GoldKeeper class and that's it?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Ok that's what slightly confuses me. When someone picks up an item, I would use that event and send the packet to the server, correct?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

You don't.

 

To send entity reference through packet you want to use entity ID.

 

On IMessage (on server)

entity.getEntityId();

And write it into buffer (int).

 

On receiver client: (read from buffer)

Entity e = world.getEntityByID(msg.entityId);

 

As to your main question - UUID is a 2x long, you can get UUID.getLeastSignificant() and MostSignificant. Those are 2 longs, you can write them to NBT.

1.7.10 is no longer supported by forge, you are on your own.

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello I made a server forge with mods but when I changed it from other pc some mods are bug. I have identified the mods that are bug, here are the logs: Logs of the server with the bug mods removed: https://pastebin.com/wDxeM00A Logs of the server with all the bug mods: https://pastebin.com/ssGLVy2W                                                                                                                                                                                                                                                                                                                  Logs of the server with one bug mod: https://pastebin.com/4XnAuUic I tried to download an older version of the mods but it didn't work. How can I insert that mods? Thanks.
    • I'm not asking for a solution only for 1.16.5, a solution for more current versions will be fine as well
    • I know this chat is outdated but can you guys help me with this because i'm having the same problem and i am unable to get into the files because i am on mac
    • You only ever set the block on the client. See HoneycombItem.useOn() for the "correct" logic.
    • public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult blockHitResult) { ItemStack itemstack = player.getItemInHand(hand); boolean successfullyDyed = false; if (level.isClientSide) { if(player.getAbilities().mayBuild == true){ if(itemstack.getItem() == Items.RED_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,0),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.ORANGE_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,1),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.YELLOW_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,2),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.GREEN_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,3),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.BLUE_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,4),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.PURPLE_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,5),0); successfullyDyed = true; } else{ player.displayClientMessage(Component.translatable("block.thingamajigs.lava_lamp.wrong_dye"), true); return InteractionResult.CONSUME; } // update THIS block, no matter what happens if(successfullyDyed == true){ level.updateNeighborsAt(blockPos,this); level.playSound(null, blockPos, SoundEvents.DYE_USE, SoundSource.BLOCKS, 1.0F, 1.0F); return InteractionResult.SUCCESS; } if(!player.isCreative()) { if (itemstack.getCount() > 1) { itemstack.setCount(itemstack.getCount() - 1); } else { itemstack.setCount(0); } } } } return InteractionResult.CONSUME; } Hey there, I was working on a block's 'use' method, however the behavior is not quite what I wanted. In-game, the block will flash to the desired state, then revert back to the state it was in previously, and won't actually update. I was wondering if perhaps I was updating the block wrong? The only state I am trying to update is an Integer value called 'TYPE' from 0-5 by using dyes.
  • Topics

×
×
  • Create New...

Important Information

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