Jump to content

How to place a block?


DeDxYk594

Recommended Posts

Henlo!

I do not know how to place a block. This trouble seems really stupid.

I tried to place a block using IWorld.setBlockState(BlockPos pos,BlockState state), but using of this method have caused a misunderstandings with ImmutableMap<K,V> (it needs for instantiating BlockState class)

How to place a block?

Link to comment
Share on other sites

Please post your code.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

I tried to use this code:

 

@SubscribeEvent

public void onBlockHarvested(BlockEvent.BreakEvent event)

{ IWorld world=event.getWorld();

world.setBlockState(event.getPos(),new BlockState(new Stump(),new ImmutableMap<String,String>()));

}

 

But I cannot instantiate the ImmutableMap class and I do not know how it uses

Link to comment
Share on other sites

7 minutes ago, DeDxYk594 said:

Problem did not solved. Can someone give me an example of block placing?

 

Show your updated code whenever you change something and need more help :) Also, be more descriptive with your errors, does the code compile? Run? Does it crash? Is there a log? The more detail you provide, the less time people will have to spend asking you questions

 

My suggestion when you are trying to do something, is to look through vanilla code for something that does something similar to what you are trying to do, and use it as an example. Find something that sets blockstates and look to see how it does it. Part of the problem I can see, is that you are not using setBlockState correctly. Where did you get your parameters from? I've never seen setBlockState used like that. Look at the method signature to see what parameters it wants.

Link to comment
Share on other sites

1 hour ago, DeDxYk594 said:

@SubscribeEvent

public void onBlockHarvested(BlockEvent.BreakEvent event)

{ IWorld world=event.getWorld();

world.setBlockState(event.getPos(),new BlockState(new Stump(),new ImmutableMap<String,String>()));

}

You are also setting the block on both sides. Interactions like block placement should only happen on the server side.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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.