So many ways that do not work, is there one that does?

So much dependant on the Data API, but between multiple posts on the site, and numerous variations of the help pages, and ongoing changes with the api and implimentations… so much code examples that just don’t work anymore, or were ‘this is how you would do it when’ which isn’t applicable due to so many changes between that time and when parts were implimented rendering other parts of the example code invalid.

Is there ANY code, that as of today, as of the api + forgesponge implimentation today, can be used to place / change a block into one of its flavored blocks, specifically Granite or Andesite blocks, or the dark prismarine bricks?

How about ones that are used in the help pages, and modified, and modified, and found modified in the forums – placing a wet sponge?

Or are all these block flavors stilll “Waiting for data manipulators/etc” implimentation of ANY level – is there at least code to place /change some particular block with flavor to its base block in the same way as andesite is to stone, darkprismarine is to prismarine , and qualify it by saying “This is the only flavored block system that is actually written sofar, granite and prismarine and quartz and x and y are not yet written”

Im not that good enough of a programmer to know when I just haven’t poked through enough variations of whats available in the changed code, and when I’m chasing an impossibility…

If you are referring to the Blocks pages on the SpongeDocs, those are on my to do list, but I have recently been busy with the Data API itself.

The API and implementation currently support setting blocks and altering them, with the BlockStates acting as ImmutableDataHolders and Location being a DataHolder. You can make alterations to a block with all the Data API has to offer (bear in mind though that not all DataManipulators are implemented yet.

Here are two example functions. The first one will try to set the StoneType of a location to andesite, which will fail if the Block at the target location is not already a stone. (result.getType() would be DataTransactionResult.Type.FAILURE in that case). The second function creates a BlockState representing an andesite block and sets it to a target location. I hope the examples are sufficient to push you into the right direction. If not, don’t hesitate to ask again.

public boolean changeStoneToAndesite(Location<World> blockLoc) {
    final DataTransactionResult result = blockLoc.offer(Keys.STONE_TYPE, StoneTypes.ANDESITE);
    return result.getType() == DataTransactionResult.Type.SUCCESS;
}

public void replaceWithAndesite(Location<World> blockLoc) {
    final BlockState andesite = BlockTypes.STONE.getDefaultState().with(Keys.STONE_TYPE, StoneTypes.ANDESITE).get();
    blockLoc.setBlock(andesite);
}

Thank you @Saladoc mostly for confirming so many ways my attempts converged, but… with no luck sofar.

Is this honest-to-god, working, tested code ripped from a demostrated-to-work example? Because I’ve rolled over this code or very very close to it so many times, but I always keep getting a blast of “…preconditions … checknotnull” errors before…

And just now, I threw your code into a testing plugin, where I get a block location by tapping with a sword … then passed that location into one of these functions. First test was replace-with – Errored out, tapping a grass block, or a stone block.
Second test was piped into changestonetoandesite, requriing to tap stone or else expect failure… similar blast of java errors.

[16:07:00] [Server thread/INFO]: Given [Wooden Sword] * 1 to BooMod
give boomod wooden_sword[16:07:17] [Server thread/INFO]: <BooMod> going to tap on stone block
[16:07:20] [Server thread/ERROR] [Sponge]: Could not pass InteractBlockEvent$Primary$Impl to SpongePlugin:Idea Tester{0.0}
java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) ~[minecraft_server.1.8.jar:?]
        at net.minecraft.block.state.BlockState$StateImplementation.supports(BlockState.java:287) ~[beg.class:?]
        at net.minecraft.world.World.offer(World.java:1106) ~[aqu.class:?]
        at net.minecraft.world.World.offer(World.java:388) ~[aqu.class:?]
        at org.spongepowered.api.world.Location.offer(Location.java:612) ~[Location.class:1.8-1519-2.1DEV-707+spongeproject-ci-b707.git-ad5d
1837ce61e662f0ced67a6d6b89d949a6a9da]
        at com.prennet.boomod.ideatester.IdeaTester.changeStoneToAndesite(IdeaTester.java:78) ~[IdeaTester.class:?]
        at com.prennet.boomod.ideatester.IdeaTester.onTap(IdeaTester.java:64) ~[IdeaTester.class:?]
        at org.spongepowered.common.event.listener.PrimaryListener_IdeaTester_onTap2.handle(Unknown Source) ~[?:?]
        at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:92) ~[RegisteredListener.class:1.8-1519-2.1DEV-7
07+spongeproject-ci-b707.git-ad5d1837ce61e662f0ced67a6d6b89d949a6a9da]
        at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:210) [SpongeModEventManager.class:1.8-1519-2.1D
EV-707+spongeproject-ci-b707.git-ad5d1837ce61e662f0ced67a6d6b89d949a6a9da]
        at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:174) [SpongeModEventManager.class:1.8-1519-2.1D
EV-707+spongeproject-ci-b707.git-ad5d1837ce61e662f0ced67a6d6b89d949a6a9da]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:64) [EventBus.class:?]
        at net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(ForgeEventFactory.java:123) [ForgeEventFactory.class:?]
        at net.minecraft.server.management.ItemInWorldManager.func_180784_a(ItemInWorldManager.java:142) [qx.class:?]
        at net.minecraft.network.NetHandlerPlayServer.func_147345_a(NetHandlerPlayServer.java:526) [rj.class:?]
        at net.minecraft.network.play.client.C07PacketPlayerDigging.func_180763_a(SourceFile:40) [ml.class:?]
        at net.minecraft.network.play.client.C07PacketPlayerDigging.func_148833_a(SourceFile:10) [ml.class:?]
        at net.minecraft.network.PacketThreadUtil$1.onProcessPacket(SourceFile:45) [ih.class:?]
        at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [ih.class:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_60]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60]
        at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) [FMLCommonHandler.class:?]
        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:656) [MinecraftServer.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:364) [po.class:?]
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:598) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:478) [MinecraftServer.class:?]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]

Forge 1519, Sponge Dev-707
spongeapi-2.1-20151012.175656-59-shaded api file used (due to maven not forcing api update the past few days)

Your code, all Im doing is passing the location of a block into it, and getting the all-to-familiar seen over-and-over in testing trials “Preconditions…” errors

I’d like feel really stupid and dumb by having it pointed out ‘ah, that means you’re imported x from the wrong library’ and be able to then hit the ground running and make up lost time for such a stumble… if it means that your code example does actually work.

But… I’m as stuck as before.

Apologies, the code was not tested. Also I did not bother to check the Implementation Checklist if the DataManipulators used are already implemented. Turns out they are not, as the unchecked boxes in the Blocks section prove. While the API may provide the means to set the data, sadly the DataProcessors that make it work in the implementation have yet to be implemented. Rest assured, if your code looked like this it was most likely correct, only Sponge lacks the foundation to support it.

Recently there has been a rush of help on the DataProcessor implementation, so chances are good that if you state which ones you need, they get implemented a little sooner.

Yeah, this is why I wondered “Is there code that actually works today”, or to findout if it was indeed impossible - the past many months of forums (not just the help pages) have numerous ways of “when we finish this step this week, you should be able to do it this way” and "this is how it would be done’ that keep changing and evolving over time, none of which use methods or types that are actually in existance at this point in evolution as well , so its the trying to follow evolving systems when every snip of 3 line code has 4 compiler issues, trying to extrapolate and explore from those… :wink:

I have been trying to follow various impilmentation checklists, but with so many changes between way back then and now, many of them dont seem to make sense anymore - like Event tracking checklists, when so many events no longer exist, or are regrouped into other events, etc - and so its hard to distinguish what is an active , accurate list of things, and what has been abandoned and tossed aside

Where would a request be made for getting the granite/stonebrick/etc stone-data flavors and prismarine-data flavor manipulators be best put?

The Event list seems to not have received an update for the Great Event Refactor, but the DataProcessor list is still up to date and in use.

I think the best way would be opening an issue on the SpongeCommon repository to show that there is particular interest for stone and prismarine to be implemented.

1 Like

Done - thank you

@TheBoomer block data is implemented