Jump to content
  • Home
  • Files
  • Docs
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.12.2] Help rotating block
The update for 1.13 is being worked on - please be patient. (Updated 02/14/19)
Sign in to follow this  
Followers 3
adrianrv1999

[1.12.2] Help rotating block

Started by adrianrv1999, June 19, 2018

13 posts in this topic

adrianrv1999    0

adrianrv1999

adrianrv1999    0

  • Tree Puncher
  • adrianrv1999
  • Members
  • 0
  • 4 posts
  • Report post
Posted June 19, 2018 (edited)

Hello, i'm really new at minecraft modding but i know some java,

i created a block chair and i want it to rotate when i place it, i mean, like stairs do in vanilla,

i don't know how to look into vanilla code and i don't fing nothing searching,

thanks for the help and sorry for probably sh*tt* question

Edited June 19, 2018 by adrianrv1999

Share this post


Link to post
Share on other sites

diesieben07    6104

diesieben07

diesieben07    6104

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6104
  • 40199 posts
  • Report post
Posted June 19, 2018

Forge and vanilla code is attached as a library in your IDE. Find it and open it to browse the code.

  • Confused 1

Share this post


Link to post
Share on other sites

adrianrv1999    0

adrianrv1999

adrianrv1999    0

  • Tree Puncher
  • adrianrv1999
  • Members
  • 0
  • 4 posts
  • Report post
Posted June 19, 2018
1 minute ago, diesieben07 said:

Forge and vanilla code is attached as a library in your IDE. Find it and open it to browse the code.

Where i can find it in eclipse

Share this post


Link to post
Share on other sites

diesieben07    6104

diesieben07

diesieben07    6104

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6104
  • 40199 posts
  • Report post
Posted June 19, 2018
Just now, adrianrv1999 said:

Where i can find it in eclipse

This is not an Eclipse support forum. If I remember correctly, Eclipse will list libraries under "Referenced Libraries".

  • Confused 1

Share this post


Link to post
Share on other sites

adrianrv1999    0

adrianrv1999

adrianrv1999    0

  • Tree Puncher
  • adrianrv1999
  • Members
  • 0
  • 4 posts
  • Report post
Posted June 19, 2018 (edited)
1 hour ago, diesieben07 said:

This is not an Eclipse support forum. If I remember correctly, Eclipse will list libraries under "Referenced Libraries".

finded it, thanks ❤️ but still haven't idea to rotate blocks

Edited June 19, 2018 by adrianrv1999

Share this post


Link to post
Share on other sites

aw_wolfe    13

aw_wolfe

aw_wolfe    13

  • Stone Miner
  • aw_wolfe
  • Members
  • 13
  • 90 posts
  • Report post
Posted June 20, 2018

if you are looking for simple rotation, then stairs may not be the best example. Stairs rotate, but also can be placed upside down and their bounding boxes change.

 

1) add property facing to your block

 public static final PropertyDirection FACING = BlockHorizontal.FACING;

2) set default blockstate in the block constructor

this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));

3) create the proper blockstatecontainer

@Override
	protected BlockStateContainer createBlockState() {
		 return new BlockStateContainer(this, new IProperty[] { FACING});
	}

4) meta-> blockstate and blockstate->meta. a meta value is store with each blockstate. you have to convert this to and from the blockstate property value (below is taken from one of my blocks with other properties removed manually without testing, but think it is ok)

@Override
	public IBlockState getStateFromMeta(int meta) {
		
		EnumFacing enumfacing = EnumFacing.getFront(meta);

	        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	        {
	            enumfacing = EnumFacing.NORTH;
	        }
	        
	        

	        return this.getDefaultState().withProperty(FACING, enumfacing);
	}
	@Override
	public int getMetaFromState(IBlockState state) {
		
		EnumFacing facing=state.getValue(FACING);
		
		int meta=((EnumFacing)state.getValue(FACING)).getIndex();
		
		return meta;
	}
	

5)set the property values in the blockstate json. (the "mod" is your modid, the "model" is your model json which should be located in assets/[mod]/models/block. If you wanted different models for different directions, just change here.

{
    "variants": {
        "facing=north": { "model": "mod:model" },
        "facing=east":  { "model": "mod:model", "y": 90 },
        "facing=south": { "model": "mod:model", "y": 180 },
        "facing=west":  { "model": "mod:model", "y": 270 },
        
    }
}

 

I think that is all you need. Good luck. Don't get discouraged modding, once you get used to looking into the minecraft code, it gets easier.

  • Thanks 1

Share this post


Link to post
Share on other sites

diesieben07    6104

diesieben07

diesieben07    6104

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6104
  • 40199 posts
  • Report post
Posted June 20, 2018
36 minutes ago, aw_wolfe said:

Don't get discouraged modding, once you get used to looking into the minecraft code, it gets easier.

Yes, and "just copy this" posts like yours don't help...

Share this post


Link to post
Share on other sites

adrianrv1999    0

adrianrv1999

adrianrv1999    0

  • Tree Puncher
  • adrianrv1999
  • Members
  • 0
  • 4 posts
  • Report post
Posted June 20, 2018
1 hour ago, aw_wolfe said:

Don't get discouraged modding, once you get used to looking into the minecraft code, it gets easier.

i'm so lost in minecraft code, always i don't know really what does what

Share this post


Link to post
Share on other sites

aw_wolfe    13

aw_wolfe

aw_wolfe    13

  • Stone Miner
  • aw_wolfe
  • Members
  • 13
  • 90 posts
  • Report post
Posted June 20, 2018

There are tutorials out there. Just put some time into your problem before posting here. People (often the same people) have answered the same questions over and over and over again. If your issue looks like you thought it through and did some research, people will be more helpful (in general).

 

https://shadowfacts.net/tutorials/forge-modding-112/

http://jabelarminecraft.blogspot.com/p/minecraft-modding-containers.html

https://github.com/TheGreyGhost/MinecraftByExample

  • Confused 1

Share this post


Link to post
Share on other sites

Draco18s    1928

Draco18s

Draco18s    1928

  • Reality Controller
  • Draco18s
  • Members
  • 1928
  • 12860 posts
  • Report post
Posted June 20, 2018
4 hours ago, aw_wolfe said:

	@Override
	public IBlockState getStateFromMeta(int meta) {
		EnumFacing enumfacing = EnumFacing.getFront(meta);
	        if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
	            enumfacing = EnumFacing.NORTH;
	        }
	        return this.getDefaultState().withProperty(FACING, enumfacing);
	}

 

This is over-engineered. The check for the Axis being Y and setting the facing to North isn't really needed. The only way this could ever happen is if you used external tools to force the block metadata to be something other than what the allowable states are.

 

Use EnumFacing.getHorizontal(meta) instead.

Quote

	@Override
	public int getMetaFromState(IBlockState state) {
		EnumFacing facing=state.getValue(FACING);
		int meta=((EnumFacing)state.getValue(FACING)).getIndex();
		return meta;
	}

 

 

This is likewise over-engineered copy paste "I don't know what the fuck I'm doing" garbage. You created a local facing variable and then don't even use it. You even cast the property to an EnumFacing (why?) and use getIndex, which is wrong. No wonder you have to fix things with the getAxis == Y....

 

return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();

Share this post


Link to post
Share on other sites

Drachenbauer    0

Drachenbauer

Drachenbauer    0

  • Tree Puncher
  • Drachenbauer
  • Members
  • 0
  • 47 posts
  • Report post
Posted February 10 (edited)
On 6/20/2018 at 4:53 PM, Draco18s said:

This is over-engineered. The check for the Axis being Y and setting the facing to North isn't really needed. The only way this could ever happen is if you used external tools to force the block metadata to be something other than what the allowable states are.

 

Use EnumFacing.getHorizontal(meta) instead.

 

This is likewise over-engineered copy paste "I don't know what the fuck I'm doing" garbage. You created a local facing variable and then don't even use it. You even cast the property to an EnumFacing (why?) and use getIndex, which is wrong. No wonder you have to fix things with the getAxis == Y....

 

return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();

As i copyed aw_wolfe´s stuff into my block-class, i get purple, black blocks instead of my model, if I placing it in my Minecraft-test-world.

 

I don´t know, what exactly i have to replace with the lines, you show here as a better choice...

Edited February 10 by Drachenbauer

Share this post


Link to post
Share on other sites

Meldexun    3

Meldexun

Meldexun    3

  • Stone Miner
  • Meldexun
  • Members
  • 3
  • 59 posts
  • Report post
Posted February 10 (edited)

I'm not sure if you should make your own thread. But you should show us what you already have so that we can help you.

Edited February 10 by Meldexun

Share this post


Link to post
Share on other sites

Cadiboo    142

Cadiboo

Cadiboo    142

  • World Shaper
  • Cadiboo
  • Members
  • 142
  • 2090 posts
  • Report post
Posted February 11
2 hours ago, Meldexun said:

make your own thread

And

2 hours ago, Meldexun said:

show us what you already have so that we can help you.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 3
Go To Topic Listing Modder Support

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Xander402
      How to add a tooltip using ItemTooltipEvent?

      By Xander402 · Posted 41 minutes ago

      Yeah, thank you. Everything works fine.
    • Mclovintits
      Need Help

      By Mclovintits · Posted 1 hour ago

      My client keeps crashing when I join my server, I don't know what to do.    This is the error it give me on my server. [21:12:03] [Server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught io.netty.handler.codec.EncoderException: java.lang.RuntimeException: Undefined discriminator for message type journeymap.common.network.DimensionPermissionPacket in channel jm_dim_permission at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:106) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) ~[AbstractChannelHandlerContext.class:?] at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:801) ~[AbstractChannelHandlerContext.class:?] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814) ~[AbstractChannelHandlerContext.class:?] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794) ~[AbstractChannelHandlerContext.class:?] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831) ~[AbstractChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1032) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:296) ~[AbstractChannel.class:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:250) [SimpleNetworkWrapper.class:?] at journeymap.common.network.PacketHandler.sendDimensionPacketToPlayer(PacketHandler.java:57) [PacketHandler.class:1.12.2-5.5.3] at journeymap.server.events.ForgeEvents.on(ForgeEvents.java:73) [ForgeEvents.class:1.12.2-5.5.3] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_753_ForgeEvents_on_EntityJoinWorldEvent.invoke(.dynamic) [?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) [ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?] at net.minecraft.world.World.func_72838_d(World.java:1206) [amu.class:?] at net.minecraft.world.WorldServer.func_72838_d(WorldServer.java:1058) [oo.class:?] at net.minecraft.server.management.PlayerList.func_72377_c(PlayerList.java:377) [pl.class:?] at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:166) [pl.class:?] at shadows.fastbench.net.HijackedDedicatedPlayerList.initializeConnectionToPlayer(HijackedDedicatedPlayerList.java:19) [HijackedDedicatedPlayerList.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:255) [NetworkDispatcher.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.access$100(NetworkDispatcher.java:72) [NetworkDispatcher.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:205) [NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:285) [gw.class:?] at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180) [oz.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:790) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] Caused by: java.lang.RuntimeException: Undefined discriminator for message type journeymap.common.network.DimensionPermissionPacket in channel jm_dim_permission at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:76) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:88) ~[MessageToMessageEncoder.class:?] ... 29 more    
    • DavidM
      How to add a tooltip using ItemTooltipEvent?

      By DavidM · Posted 2 hours ago

      Check my updated reply (I misunderstood your question at first).
    • Xander402
      How to add a tooltip using ItemTooltipEvent?

      By Xander402 · Posted 2 hours ago

      Okay, so I'll do. I know what to do with my custom mod items, I don't have any trouble with adding tooltips to them.
      I do similarly to what you said, but I have all the tooltips in my lang file in case I wanted to translate the mod.
      But I don't think I'm allowed to re-initialize and override a VANILLA item, like minecraft:diamond...
    • DavidM
      How to add a tooltip using ItemTooltipEvent?

      By DavidM · Posted 2 hours ago

      1. Do NOT use static initializers. 2.  1.12.2: event.getTooltip.add(String);   1.13.2: event.getTooltip.add(ITextComponent);  
  • Topics

    • Xander402
      4
      How to add a tooltip using ItemTooltipEvent?

      By Xander402
      Started 2 hours ago

    • Mclovintits
      0
      Need Help

      By Mclovintits
      Started 1 hour ago

    • DavidM
      0
      [1.13.2] Replacing Entity#setDead

      By DavidM
      Started 2 hours ago

    • DavidM
      0
      [1.13.2] Creating Entity From NBT

      By DavidM
      Started 2 hours ago

    • Drachenbauer
      29
      [1.13.2] converting mod from 1.12.2 How to fix the errors?

      By Drachenbauer
      Started Saturday at 08:17 PM

  • Who's Online (See full list)

    • Kaelym
    • ModMCdl
    • Cadiboo
    • Trhod177
    • Laike_Endaril
    • DaemonUmbra
    • MoreThanHidden
    • Paul Malyarevich
    • 20LeeBrian1
    • daruskiy
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Help rotating block
  • Theme
  • Contact Us

Copyright © 2017 ForgeDevelopment LLC Powered by Invision Community