Jump to content

[1.12.2] FallingBlockEntity addVelocity


Pikachu923

Recommended Posts

I don't understand why this isn't working. No matter what I do, the blocks always fall strait down.

 

public void execute(Chunk chunk, int topIn){
		World world = chunk.getWorld();
		
		if(world.isRemote) return;
		
		Random rand = new Random();
		int x = (chunk.getPos().getXEnd() - chunk.getPos().getXStart())/2 + chunk.getPos().getXStart();
		int z = (chunk.getPos().getZEnd() - chunk.getPos().getZStart())/2 + chunk.getPos().getZStart();	
		BlockPos top = new BlockPos(x,topIn,z);
		
		for(MutableBlockPos pos : BlockPos.getAllInBoxMutable(top.add(-3, -3, -3), top.add(3, 3, 3))){
			EntityFallingBlock entity = new EntityFallingBlock(world, pos.getX(), pos.getY()+2, pos.getZ(), Blocks.STONE.getDefaultState());
			if(rand.nextInt(100)+1 < 20){
				world.spawnEntity(entity);
				entity.fallTime = 1;
				entity.addVelocity(range(rand,10,20), range(rand,10,20), range(rand,10,20));
			}	
		}
	}
	
	private int range(Random rand, int min, int max){
		return rand.nextInt((max - min) + 1) + min;
	}

 

Any help is appreciated, Thanks!

Link to comment
Share on other sites

On 7/23/2019 at 12:00 PM, Pikachu923 said:

entity.addVelocity(range(rand,10,20), range(rand,10,20), range(rand,10,20));

Your velocity is way to high. That's 10-20 blocks per tick.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

26 minutes ago, Pikachu923 said:

I turned it up a lot because they're not moving at all. And they still don't move, just fall.

What did you change it to?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

3 hours ago, Pikachu923 said:

The 10-20 was the change

What? Make it like 1 or a decimal maximum.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.