I need help to change the gravity of a block!

Started by CraftMania41 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I need help to change the gravity of a block!

Hello! I create a mod that requires block that are afected by gravity. The problem is here: I would like to make the block so that if it touches two blocks or more on the sides, it does not fall. Is this possible, and if it is, how? 

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If somone needs a better
Sun, 06/11/2017 - 19:31

If somone needs a better explanation, here it is (because i would really like to know how to do it ;-;). The block, is not affected by gravity if there are two or more other blocks on its sides (+X,-X,+Z and -Z, Not on the Y axis). But if by an event it is touched by noly one other block, it will become affected by the gravity and fall down. I hope with this explanation somone can help me! If more info is needed, ask me! 

 

Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Your block must extend
Sun, 06/11/2017 - 21:25

Your block must extend BlockFalling (That yu should already have by default if you checked the "gravity" option in MCreator). Then you need to override BlockFalling #checkFallable()
Arguments of the method are World and BlockPos. Probably best to do is using EnumFacing to iterate each side and if there is a block on the side, increase some variable and if the value after increasing is 2, break the loop and call super method.

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Your block must extend
Mon, 06/12/2017 - 21:58

@#2 Ok thanks! I'll try but I am not sure to understand fully... So if it doesn't work could you please send me an exemple or something? (I am not that good in coding for now)

 

Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can show you a tutorial
Tue, 06/13/2017 - 16:21

I can show you a tutorial without coding... But you need to make 2 blocks :
One with gravity and another without gravity. These blocks have the same name and the same texture eand the 2nd block drops the first.
Add an event on the first. This will take some time because you need to make lots of stack events for all combinations. You need to make 4 stack events and each stack event has 3 events. In the condition put the isblockairat! (put coordinates) true (or something similar ;it is one of the default conditions). Then, as result of the last events, put add block and add the second block
For the second block put the same events but "isblockairat(coordinates)" is without the "!" and the result is that it removes the block.
I think that it is better to use Nuparu00's tutorial, but if you want a tutorial without coding, here is it!

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok! thanks I'll try it and as
Tue, 06/13/2017 - 21:10

Ok! thanks I'll try it and as you said maybe one day I'll use the method of Nuparu00!

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok, RaolTheBest, your technic
Wed, 06/14/2017 - 23:40

Ok, RaolTheBest, your technic worked! But not fo one block (I mean I can't find the way to do it) . I have one of these blocks that I need to be directional, and I don't know how. Then, (if I take example on the wood), to be stable it needs to have the two "cut sides" on another block. If not, it falls. Can you help me?

Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Ok, RaolTheBest, your technic
Thu, 06/15/2017 - 10:22

Sorry, but I am not English and so I can't understand it very well. Can you repeat what you have wrote?

I made a mistake :instead of removing the block, the 2nd block must add the gravity block. (like the first block, but instead of turning it into no-gravity block, it turns it into thr gravity block).
Another mistake, I forgot to say that the events must be tick events. If this doesn't work, set the tick rate to the minimum.

Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:Ok, RaolTheBest, your technic
Thu, 06/15/2017 - 21:10

No problem! I find the way to make it work with the events like you said. But it won't work for one type of block because it needs to be "Directional" (Facing from where you were looking at when you placed it). And this block needs to have at least 2 blocks on the sides but only on the "cut sides" as I name them. Here is the example: 

The cut sides on this image are the one that have light color and a spiral in it (The other one is behind at the opposite side) And the green is the place where it needs a block to stand in the air. But if the block has a rotation in the game, I need the green markers to change with it to. How do I make this?

Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:Ok, RaolTheBest, your technic
Fri, 06/16/2017 - 09:14

I don't know hoe to make directional blocks and so I don't know hoe to make this event, sorry. (I know that Nuparu00 has made a tutorial, but I always forgot to use it for making directional blocks XD)