Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello there!

I'm fairly new to modding, and I'm trying to make a 1.15 mod for Minecraft.

So my problem is:

I made an end gravel block. It's nice and all, but I want it to fall upside down, e.g. up.

But:

at first, I made a new block using the class GravelBlock, and it worked! But it wasn't falling upside down yet of course.

So:

I made a new class called EndGravelBlock which extends FallingBlock(I tried expending GravelBlock first but it didn't work either), and I "overrided" a method which I assume to be what MOVES the falling block. The problem though is that after inverting values which I didn't know the use because there wasn't any variables, just floats and ints, I ended up in ALL cases with a block that DID NOT even SPAWN a falling block. So my question is: am I supposed to change the way it moves in the blocks class? If yes how? Or am I supposed to create a new Entity that expends EntityFallingBlock and change it's gravity? Cuz I haven't made a single entity ever in any of my tests with modding.

 

Sorry for bad english

Edited by MaxAnimator
typo

I don't know the answers to your questions, but we're gonna need some source code to help properly :).

If you have a Git repository, that'd be ideal.

Edited by GenElectrovise

How to ask a good coding question: https://stackoverflow.com/help/how-to-ask

Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy.

 

My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki)

Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/

  • Author

I don't have a git repository, but here's the class' code:

package com.maxandcarl.inan.objects.blocks;

import java.util.Random;

import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.entity.item.FallingBlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;

public class EndGravelBlock extends FallingBlock{

	public EndGravelBlock(Properties properties)
	{
		super(properties);
	}
	
	@Override
	public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand) {
	      if (worldIn.isAirBlock(pos.up()) || canFallThrough(worldIn.getBlockState(pos.up())) && pos.getY() <= 0) {
	         FallingBlockEntity fallingblockentity = new FallingBlockEntity(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() * -1, (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
	         this.onStartFalling(fallingblockentity);
	         worldIn.addEntity(fallingblockentity);
	      }
	   }
}

 

Its actually pretty simple. First of all, the constructor that you are modifying is the block's position and not its motion. If you want to be able to modify its gravity, you can either use world tick and get every entity and check if its your falling block and set its motion. Or you can implement a custom falling block and override its tick method.

  • Author
2 hours ago, [NoOneButNo] said:

Its actually pretty simple. First of all, the constructor that you are modifying is the block's position and not its motion. If you want to be able to modify its gravity, you can either use world tick and get every entity and check if its your falling block and set its motion. Or you can implement a custom falling block and override its tick method.

How do I "use world tick and get every entity and check if its your falling block and set its motion"?

I'm still beggining at modding and java...

3 minutes ago, MaxAnimator said:

How do I "use world tick and get every entity and check if its your falling block and set its motion"?

I'm still beggining at modding and java...

WorldTickEvent, get the ServerWorld and check all entities using getEntities, then check if an entity is instanceof your entity.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

  • Author

This is what I tried doing:

public class EndGravelBlock extends FallingBlock{

	public EndGravelBlock(Properties properties)
	{
		super(properties);
	}
	
	public void WorldTickEvent()
	{
		ServerWorld.getEntities(EntityFallingBlock);
	}
}

It gives me an error when using instanceof and it doesn't let me import EntityFallingBlock

4 minutes ago, MaxAnimator said:

This is what I tried doing:

Please learn basic Java before modding, also read the documentation, it explains basic concepts such as networking and events.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.