Posted June 15, 20205 yr 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 June 15, 20205 yr by MaxAnimator typo
June 15, 20205 yr 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 June 15, 20205 yr 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/
June 15, 20205 yr 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); } } }
June 16, 20205 yr 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.
June 16, 20205 yr 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...
June 16, 20205 yr 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".
June 16, 20205 yr 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
June 16, 20205 yr 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.