Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14] Make some blocks affected by gravity.
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
cinsiian

[1.14] Make some blocks affected by gravity.

By cinsiian, October 13 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

cinsiian    1

cinsiian

cinsiian    1

  • Creeper Killer
  • cinsiian
  • Members
  • 1
  • 110 posts
Posted October 13

Hello, how can i make some vanilla blocks affected by gravity? Is it possible?

Like in a registry event do I check the block and then make it extends FallingBlock?

Thank you

  • Quote

Share this post


Link to post
Share on other sites

DavidM    101

DavidM

DavidM    101

  • World Shaper
  • DavidM
  • Members
  • 101
  • 1130 posts
Posted October 13

You need to replace the block with your own by overriding it in the block registry.

  • Quote

Share this post


Link to post
Share on other sites

cinsiian    1

cinsiian

cinsiian    1

  • Creeper Killer
  • cinsiian
  • Members
  • 1
  • 110 posts
Posted October 13
Spoiler

public void onRegister(RegistryEvent.Register<Block> event)
	{
		for(Entry<ResourceLocation, Block> e : event.getRegistry().getEntries())
		{
			if(e.getValue() == Blocks.DIRT)
			{
				e.setValue(new GravityBlock(Blocks.DIRT));
			}
		}
	}

 

Spoiler

public class GravityBlock extends FallingBlock {

	public GravityBlock(Block block) 
	{
		super(Block.Properties.from(block));
	}

}

 

I assume I didnt override the block correctly?

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14018 posts
Posted October 13
50 minutes ago, cinsiian said:

e.setValue(new GravityBlock(Blocks.DIRT));

This makes no sense, getEntries() returns an unmodifiable set:

 

    @Override
    public Set<Entry<ResourceLocation, V>> getEntries()
    {
        return Collections.unmodifiableSet(this.names.entrySet());
    }

 

  • Quote

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted October 13
3 hours ago, cinsiian said:

I assume I didnt override the block correctly?

Yes. You just need to register a Block with the same registry name and the same variants.

  • Quote

Share this post


Link to post
Share on other sites

cinsiian    1

cinsiian

cinsiian    1

  • Creeper Killer
  • cinsiian
  • Members
  • 1
  • 110 posts
Posted October 15
On 10/13/2019 at 10:59 PM, Animefan8888 said:

register a Block with the same registry name and the same variants.

event.getRegistry().register(new GravityBlock(Blocks.DIRT).setRegistryName("dirt"));

Nothing is changed. Am I doing something wrong?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6672

diesieben07

diesieben07    6672

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6672
  • 45646 posts
Posted October 15
45 minutes ago, cinsiian said:

event.getRegistry().register(new GravityBlock(Blocks.DIRT).setRegistryName("dirt"));

Nothing is changed. Am I doing something wrong?

This sets the registry name to <your mod id>:dirt. You have to explicitly specify the "minecraft" domain if you want it.

  • Quote

Share this post


Link to post
Share on other sites

cinsiian    1

cinsiian

cinsiian    1

  • Creeper Killer
  • cinsiian
  • Members
  • 1
  • 110 posts
Posted October 15
event.getRegistry().register(new GravityBlock(Blocks.DIRT).setRegistryName(Blocks.DIRT.getRegistryName()));

I tried also with new ResourceLocation("minecraft", "dirt") but nothing is happening :8

Do I have to make an itemblock as well?

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2091

Draco18s

Draco18s    2091

  • Reality Controller
  • Draco18s
  • Members
  • 2091
  • 14018 posts
Posted October 15
4 minutes ago, cinsiian said:

Do I have to make an itemblock as well?

Probably.

  • Quote

Share this post


Link to post
Share on other sites

cinsiian    1

cinsiian

cinsiian    1

  • Creeper Killer
  • cinsiian
  • Members
  • 1
  • 110 posts
Posted October 15
public Block dirt_gravity = new GravityBlock(Blocks.DIRT).setRegistryName(Blocks.DIRT.getRegistryName());
	
	@SubscribeEvent
	public void register_block(RegistryEvent.Register<Block> event)
	{
		event.getRegistry().register(dirt_gravity);
	}
	
	@SubscribeEvent
	public void register_item(RegistryEvent.Register<Item> event)
	{
		event.getRegistry().register(new BlockItem(dirt_gravity, new Item.Properties()).setRegistryName(Blocks.DIRT.getRegistryName()));
	}

still nothing 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6672

diesieben07

diesieben07    6672

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6672
  • 45646 posts
Posted October 15

Are the events called?
Please create your block in the event.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

cinsiian    1

cinsiian

cinsiian    1

  • Creeper Killer
  • cinsiian
  • Members
  • 1
  • 110 posts
Posted October 15

Oh I made the block in the event and now works. Thank you

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      [1.12.2] How can I close GUI in Forge?

      By diesieben07 · Posted 6 minutes ago

      You cannot call Minecraft methods from a separate thread. You need to wait a tick using ClientTickEvent.
    • bismuth210
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210 · Posted 20 minutes ago

      I'm creating a custom gamemode using forge in which players get teleported around regularly. I've run into a problem when I do the following:   I spawn a firework rocket near a player I teleport the player to a different location I wait a couple of seconds (or minutes) I teleport the player back to the same location as in step 1. Doing this will show the firework spawned in step 1 in step 4, despite significant time having passed in 3. This video shows what I mean:   I suspect the reason for why this happens is because once I teleport the player somewhere else, the chunk with the firework is no longer loaded and doesn't get updated.   Is there a simple way for me to simply "get rid" of all active fireworks shortly before teleporting players so that this doesn't occur? Or do I really have to forcibly keep all chunks loaded? To be more clear: I don't want to disable fireworks all together, but I don't want remnants of old fireworks showing up when I teleport players. "Killing" all firework rockets when I teleport a player would work fine, but I don't know if/how I can do that.   I've tried using /kill @e[type=!player] But that doesn't work for firework rockets apparently.
    • RunKeish
      Forge 14.4 crashes on statup

      By RunKeish · Posted 21 minutes ago

      It finally worked! Thankyou so much. The installation was dodgy for me so I had to download JDK8 using:       ~$ sudo apt install openjdk-8-jdk openjdk-8-jre   Followed by:     ~$ update-java-alternatives --config java   Then select the java-8-openjdk-amd64/jre/bin/java from the list (to make java 8 the default, can switch and whatever but it works!!!)   Thanks a tonne!
    • Filip4223
      [1.12.2] How can I close GUI in Forge?

      By Filip4223 · Posted 32 minutes ago

      OK, it works.Tthanks.     I wonder is there better way for doing it instead of creating new thread?    System.out.println("Turning off"); Thread thread = new Thread(new CloseGui()); thread.start(); //CloseGui class public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("closing"); Minecraft.getMinecraft().player.closeScreen(); }  
    • diesieben07
      [1.12.2] How can I close GUI in Forge?

      By diesieben07 · Posted 47 minutes ago

      Then you must first let the GUI open (GuiOpenEvent fires before its open!) and then call:
  • Topics

    • Filip4223
      5
      [1.12.2] How can I close GUI in Forge?

      By Filip4223
      Started 1 hour ago

    • bismuth210
      0
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210
      Started 21 minutes ago

    • RunKeish
      4
      Forge 14.4 crashes on statup

      By RunKeish
      Started 2 hours ago

    • Differentiation
      12
      [SOLVED] [1.12.2] Modifying player capabilities for offline players?

      By Differentiation
      Started 9 hours ago

    • DragonITA
      4
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started 3 hours ago

  • Who's Online (See full list)

    • bismuth210
    • saxon564
    • Filip4223
    • alox
    • imacatlolol
    • diesieben07
    • DavidM
    • geduardcatalindev
    • Enterman
    • EmerProd
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14] Make some blocks affected by gravity.
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community