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

Recommended Posts

Good place to start, but it is out of date.  I'm want to click on a  block and save position , 2nd click use new position and  first position  to change some blocks.  I have it working but using a hard coded 2nd position.

Link to post
Share on other sites

my first problem is onItemUse  seems to fire twice , maybe click, and release click? 

	public ActionResultType onItemUse(ItemUseContext context) {
		   World world = context.getWorld();
		   Direction facing = context.getFace().getOpposite();
		   BlockPos newPos = context.getPos();
		   BlockPos pos = newPos;
		   
		   
		   // first use
		   ItemStack iStack = context.getItem();
		   CompoundNBT nbtTagCompound = iStack.getTag();
		   if (nbtTagCompound == null) {
			   nbtTagCompound = new CompoundNBT();
		       iStack.setTag(nbtTagCompound);

		       nbtTagCompound.putBoolean("first", true);
		       nbtTagCompound.putInt("x", pos.getX());
		       nbtTagCompound.putInt("y", pos.getY());
		       nbtTagCompound.putInt("z", pos.getZ());
		       nbtTagCompound.putInt("face", facing.getHorizontalIndex());
		       return ActionResultType.SUCCESS;
		  	}

		   // second use
		   pos = new BlockPos(nbtTagCompound.getInt("x"), nbtTagCompound.getInt("y"), nbtTagCompound.getInt("z") );

 

 

Link to post
Share on other sites
20 minutes ago, blinky000 said:

my first problem is onItemUse  seems to fire twice , maybe click, and release click? 

It's fired on the logical client and logical server. Most likely you'll only need to execute the logic on the server.

Link to post
Share on other sites
Posted (edited)

If i understand correctly , the tag data is saved in the game data.  How to i make sure at the start of a new game the tag is nulled out  or deleted?

or  after i finish using the item?

 

Edited by blinky000
Link to post
Share on other sites
4 hours ago, blinky000 said:

How to i make sure at the start of a new game the tag is nulled out  or deleted?

Start of a new game? I assume you mean world, to which the answer is: You have to do nothing.

Link to post
Share on other sites

That makes no sense. Why would you want to clear the data just because the player logged out and logged back in again?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
53 minutes ago, blinky000 said:

bad phrasing ,  when i reload the world, the data from the tag is still there from the last session.  Is the a way when a new session is started to have the tag deleted

you could simply not store the data in the first place? then there will be no data when the world loads

Link to post
Share on other sites

im having an issue  , where the sequence of things is out of order.  where im expecting the first click, it's on the 2nd.  Maybe on need better logic.  just thinking if i new on reload make it easier to know im in the correct order

 

d.

Link to post
Share on other sites

Sorry, I'm telepathetic, not telepathic. You're going to explain this to your local rubber duck.

  • Haha 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
2 hours ago, blinky000 said:

kiou.23   how could i  have the data from the first click if i don't save it?

I have absolutely no clue what it is that you're trying to accomplish

Link to post
Share on other sites
57 minutes ago, blinky000 said:

Its at the top of the post

this is the top of the post:

On 4/15/2021 at 10:01 PM, blinky000 said:

anybody know of some good nbt examples for 1.16

please be clearer

also, if your issue with "nbt examples" has been solved, and now you're facing a different issue, you should make new thread

Link to post
Share on other sites

this post has gone strange.

you sent me to https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe12_item_nbt_animate

I have been working off of that.

 

what i want to do is:  item first click save position && facing  , send click get the new position ,  execute code using those positions.

I'm starting over from the top trying to understand TheGreyGhost code.

 

Ty for you patience.

 

 

 

Link to post
Share on other sites
54 minutes ago, blinky000 said:

this post has gone strange.

you sent me to https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe12_item_nbt_animate

I have been working off of that.

what i want to do is:  item first click save position && facing  , send click get the new position ,  execute code using those positions.

I'm starting over from the top trying to understand TheGreyGhost code.

Ty for you patience

I think I understand now what you're trying to do, but correct me if I'm mistaken:

you want to store a position in a nbt on an ItemStack when that Item is used, andafterwards, use of the stored values?

you could store a boolean that holds the "state" of the nbt in it, in one state you would store a position, and in the other you would execute something now that you have a position.

I don't know what you can do to clear the nbt when the world is reloaded however, as that's not a common behaviour to expect

Link to post
Share on other sites

thats pretty much it.  the problem i was running into,  if the sequence is broken (game crash, switching to a new item or block, re-logging in) that the next use would start over  to the first state.

TheGreyGhost code, after the gem was used it was destroyed , so no issues about starting over

Link to post
Share on other sites
On 4/19/2021 at 9:51 PM, blinky000 said:

thats pretty much it.  the problem i was running into,  if the sequence is broken (game crash, switching to a new item or block, re-logging in) that the next use would start over  to the first state.

TheGreyGhost code, after the gem was used it was destroyed , so no issues about starting over

perhaps the method you're going after is all wrong...  like thinking a mechanically aligned & operated laser is the right tool for the job when a pair of scissors is better adjusted for opening your packages.

I'm not the sharpest of a bunch.... but it sounds like you're after some world edit functionality, or extending the native commands in minecraft.

perhaps rethinking what you're really doing with the tool, and exactly how ya using it might help you a bit.

 

I'm sorta confused myself...  if it's a wand tool that works as world edit.. and if it's purpose is to select two points & you call a command to be ran...   Why don't you just store/modify the tooltip with a string of numbers? 

--  eh, far as I can know I would consider rethinking how an item is used,  and limiting it to one item only (that otherwise isn't used for clicking on things.

You know that you can separate the 'clicks' right?
- a click, can 'delete' the prior data & store a new set of cords,
- a 'Shift' click, could get 2nd cords, do it's thing... and delete the data as well. >.>

On 4/19/2021 at 9:51 PM, blinky000 said:

thats pretty much it.  the problem i was running into,  if the sequence is broken (game crash, switching to a new item or block, re-logging in) that the next use would start over  to the first state.

TheGreyGhost code, after the gem was used it was destroyed , so no issues about starting over

if that's the thing,  maybe consider setting up clear conditions 'after' it has done it's thing, & on each 'first' click before it stores new info.

Link to post
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.

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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • protected static final DimensionType NETHER_TYPE = new DimensionType(OptionalLong.of(18000L), false, true, true, false, 8.0D, false, true, false, true, false, 128, FuzzedBiomeMagnifier.INSTANCE, BlockTags.INFINIBURN_NETHER.getName(), THE_NETHER_ID, 0.1F); This code in DimensionType class. I found that 8.0D its what i need but i dosent know how to change this or override nether_type. If mod with same functionality exist you can give me url (i need it for my mod pack).
    • Please post your server log, it should give a clue what's going on.
    • It looks like you may be trying to reply to someone's support post, you instead you created a new one.
    • compactstorage-1.16.5-5.1b17.jarcarryon-1.16.5-1.15.5.15.jarAdHooks-1.16.4-6.1.5.0-build.0124.jarXaerosWorldMap_1.14.1_Forge_1.16.5.jarXaeros_Minimap_21.10.0.3_Forge_1.16.5.jartrashcans-1.0.10-mc1.16.5.jarSuperTools-1.2_1.16.5.jarSpartanShields-1.16.5-2.1.2.jarrandomite-1.16.4-1.0.1.jaroverloadedarmorbar-5.1.0.jaroresplusmod_1.16.5,0.1.0.jarturtle_armor-1.3.4.jartoyguns-0.1-1.16.4.jartoughnessbar-6.1.jartorchmaster-2.3.7.jarToast-Control-1.16.4-4.3.1.jartitanium-1.16.5-3.2.8.4-10.jarthermal_expansion-1.16.4-1.2.0.jartheoneprobe-1.16-3.1.4.jarthedragonlib-1.16.3-1.1.0.jarswingthroughgrass-1.16.4-1.5.3.jarsuper+armor-5.0.4(EN).jarStorageDrawers-1.16.3-8.2.2.jarsteveGolemMod_1.3.0.jarSteelArmory.jarSoulBound-1.1.3-1.16.5.jarSimplyBetter.jarSimple guns reworked 1.16.5 v1.4.jarsilent-lib-1.16.3-4.9.6.jarRunelic-1.16.5-7.0.1.jarrftoolsbase-1.16-2.0.10.jarReAuth-1.16-Forge-3.9.3.jarrandompatches-2.4.4-forge.jarprecious_armor-1.16.5.jarPlacebo-1.16.4-4.5.0.jarPatchouli-1.16.4-51.jaroverloadedarmorbar-5.1.0.jarOreExcavation-1.8.157.jarOp Armor Plus 1.16.5 0.6.jarobserverlib-1.16.5-1.5.3.jarobfuscate-0.6.2-1.16.3.jarnetheritehorsearmor-1.7.jarNeat 1.7-27.jarNaturesCompass-1.16.5-1.9.0.jarMouseTweaks-2.14-mc1.16.2.jarMorpheus-1.16.5-4.2.70.jarMoreOresArmorsAndTools 1.2.5.jarMoreArmor-1-4-0.jarMekanismTools-1.16.5-10.0.21.448.jarMekanismGenerators-1.16.5-10.0.21.448.jarmcjtylib-1.16-5.0.19.jarMantle-1.16.5-1.6.103.jarMachineBoy's ArmorTool v1.2b1.jarJustEnoughResources-1.16.5-0.12.1.121.jarJEITweaker-1.16.5-1.0.1.28.jarjei-1.16.5-7.7.0.106.jarJ0T0S0 Weapons 1.0.0.jarironchest-1.16.4-11.2.10.jarillagersweararmor-1.0.4.jariChunUtil-1.16.5-10.4.1.jarhitscan-1.0.1.jarHandyGuns2.0.jargunswithoutroses-1.16.5-1.0.9.jarGuns'N'Glory-2.0.jarGuns and Rifes.jarftb-backups-2.1.1.6.jarForgeEndertech-1.16.4-7.1.0.0-build.0075.jarFluxNetworks-1.16.5-6.1.7.12.jarFastWorkbench-1.16.4-4.5.1.jarFastLeafDecay-v25.jarFastFurnace-1.16.4-4.4.0.jarfabric-api-0.35.0+1.16.jarExtraArmor-1.12.1-1.16.5.jarEnderStorage-1.16.4-2.7.1.166-universal.jarEnchantmentDescriptions-1.16.5-7.0.8.jarEnameledArmor-1.16.2-1.0.0.8.jaremeraldtoolsandarmor1.16.x.jarEmeraldArmorAndTools.jarelevatorid-1.16.5-1.7.13.jarDiceMC-TieredArmor-1.16.5-1.1a.jarDefaultOptions_1.16.5-12.2.1.jarDecraftHorseArmor-1.16.5-r1.jarDarkUtilities-1.16.5-8.0.10.jarCyclopsCore-1.16.5-1.11.7.jarCurious Armor Stands-1.16.5-2.1.1.jarcurios-forge-1.16.5-4.0.5.2.jarCucumber-1.16.4-4.1.10.jarCTM-MC1.16.1-1.1.2.6.jarCraftingTweaks_1.16.5-12.2.1.jarCraftableChainmail-1.16.5-1.1.0.jarcraftable_chainmail_1.16.5.jarOresAboveDiamonds-1.16.4-v6.3.3.jarCraftable Saddle and Horse Armors.jarCosmeticArmorReworked-1.16.5-v3a.jarCookingForBlockheads_1.16.5-9.3.2.jarControlling-7.0.0.23.jarcomforts-forge-1.16.5-4.0.0.4.jarColtCosmeticArmorMod-1.2.5.jarCodeChickenLib-1.16.4-3.5.1.408-universal.jarClumps-6.0.0.25.jarcitadel-1.7.1-1.16.5.jarchiselsandbits-0.3.4-RELEASE.jarcarryon-1.16.5-1.15.5.15.jarbuildinggadgets-1.16.5-3.8.0.jarBookshelf-1.16.5-10.1.11.jarBomb and guns.jarBlockArmor-1.16.5-2.6.2.jarBetterMineshafts-Forge-1.16.4-2.0.4.jarBetterHorseArmor-1.16.3-1.0.1.1.jarBetterAdvancements-1.16.5-0.1.0.108.jarBedrock Armor 1.16.5-1.0.2.jarAutoRegLib-1.6-49.jararmor-visibility-2.0.1-forge.jarArmorUp-1.0.5-BETA.jarArmorUnlocked-1.16.3-1.0.1.jararmorunder-mc1.16.5-2.0b11.jararmor-stand-editor-1.1.0.jarArmorPoser-1.16.5-1.0.1.jararmorpointspp-1.16.5-2.0.0.jararmorhotswap-1.16-1.8.jarArmoredElytra-1.0.8.jararmorcurve-2.3.jarAquaculture-1.16.5-2.1.19.jarAppleSkin-mc1.16.2-forge-1.0.14.jarApotheosis-1.16.4-4.6.1.jarAncientGuns_3.2_1.16.4.jarAkashicTome-1.4-16.jar1.7.4.1-1.16.5ATOp.jar[1.16.5] BobLib-0.2.0.jar[1.16.5] Armor Status HUD-1.4.0.jarEmerald armor and tools 1.15.16 v3.jarYungsApi-1.16.4-Forge-6.jaryeni modum.jarxnet-1.16-3.0.13.jarwolveswitharmor-1.1.0-1.16.2.jarWaystones_1.16.5-7.6.2.jarvisiblearmorslots-2.0-1.16.5.jarNeat 1.7-27.jarNaturesCompass-1.16.5-1.9.0.jarMoreOresInONE-1.2_1.16.5.jarmcw-windows-1.0.3-mc1.16.5.jarmcw-bridges-1.0.5-mc1.16.5-4.jarlongfallboots-1.6.0a.jarJustEnoughResources-1.16.5-0.12.1.121.jarjei-1.16.5-7.7.0.106.jarForgeEndertech-1.16.4-7.1.0.0-build.0075.jarextcaves-2.4.jarcurios-forge-1.16.5-4.0.5.2.jarcorpse-1.16.5-1.0.5.jarAdHooks-1.16.4-6.1.5.0-build.0124.jar
    • Dude, then try to click the down arrow near "Open" then select   Java(TM) Platform SE binary then it should work or if it doesn't work then it means you don't have Java or you computer is broken.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.