How to make Rotatable Block [VIDEO TUTORIAL]

Started by Nuparu00 on

Topic category: User side tutorials

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make Rotatable Block [VIDEO TUTORIAL]
Wed, 01/04/2017 - 20:31 (edited)

Hi. Because there is not his feature in MCreater itself and many of you need it for your mod , I decided to make a video tutorial how to make custom block rotatable , using PropertyDirection.
LINK

 

 

Edited by Klemen on Wed, 01/04/2017 - 20:31
Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:@Nuparu00
Sat, 11/26/2016 - 21:18

@#12 Well ,yes you can have just a template and then change values , the tutorial is important mainly because i try tell here what is where why + brackets. Also what is your error? (I have such feeling that you maybe forgot somwhere bracket)

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:@Nuparu00
Sat, 11/26/2016 - 23:26

@#12.1

This is the error. Hopefully the spoiler works works:

[spoiler]Executing gradle command: clean build
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Pylo\MCreator166>cd forge
C:\Pylo\MCreator166\forge>SET "JAVA_HOME=C:\Pylo\MCreator166\jdk64\"
C:\Pylo\MCreator166\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
C:\Pylo\MCreator166\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
C:\Pylo\MCreator166\forge>SET "JAVA_OPTS=-Xmx2519m -Xms128m"
C:\Pylo\MCreator166\forge>gradlew clean build
This mapping 'stable_20' was designed for MC 1.8.8! Use at your own peril.
#################################################
         ForgeGradle 2.1-SNAPSHOT-da90449        
  https://github.com/MinecraftForge/ForgeGradle  
#################################################
               Powered by MCP unknown               
             http://modcoderpack.com             
         by: Searge, ProfMobius, Fesh0r,         
         R4wk, ZeuX, IngisKahn, bspkrs           
#################################################
:clean
:deobfCompileDummyTask
:getVersionJson
:extractUserdev UP-TO-DATE
:downloadClient SKIPPED
:downloadServer SKIPPED
:splitServerJar SKIPPED
:mergeJars SKIPPED
:applyBinaryPatches SKIPPED
:deobfProvidedDummyTask
:extractDependencyATs SKIPPED
:extractMcpData SKIPPED
:extractMcpMappings SKIPPED
:genSrgs SKIPPED
:deobfMcMCP SKIPPED
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:102: error: class, interface, or enum expected
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
                    ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:104: error: class, interface, or enum expected
this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:107: error: class, interface, or enum expected
public IBlockState getStateForEntityRender(IBlockState state) {
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:110: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:113: error: class, interface, or enum expected
public IBlockState getStateFromMeta(int meta) {
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:116: error: class, interface, or enum expected
if(facing.getAxis()==EnumFacing.Axis.Y) {
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:118: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:121: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:124: error: class, interface, or enum expected
public int getMetaFromState(IBlockState state) {
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:126: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:129: error: class, interface, or enum expected
protected BlockState createBlockState() {
          ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:131: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:133: error: class, interface, or enum expected
public IBlockState onBlockPlaced(World worldIn, BlockPos pos,
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:137: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:146: error: class, interface, or enum expected
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
                    ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:148: error: class, interface, or enum expected
this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:153: error: class, interface, or enum expected
public IBlockState getStateFromMeta(int meta) {
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:156: error: class, interface, or enum expected
if(facing.getAxis()==EnumFacing.Axis.Y) {
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:158: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:161: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:164: error: class, interface, or enum expected
public int getMetaFromState(IBlockState state) {
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:166: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:169: error: class, interface, or enum expected
protected BlockStateContainer createBlockState() {
          ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:171: error: class, interface, or enum expected
}
^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:173: error: class, interface, or enum expected
public IBlockState onBlockPlaced(World worldIn, BlockPos pos,
       ^
C:\Pylo\MCreator166\forge\build\sources\main\java\mod\mcreator\mcreator_smokyquartzPillar.java:177: error: class, interface, or enum expected
}
^
:compileJava FAILED
26 errors
BUILD FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
Total time: 46.268 secs
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
C:\Pylo\MCreator166\forge>
Task completed with return code 0 in 48985 milliseconds [/spoiler]

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It actually really seems like
Sun, 11/27/2016 - 00:37

It actually really seems like missing bracket. Can I see your code?

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:It actually really seems like
Sun, 11/27/2016 - 02:03

@#13

I literally copied the code from the youtube video description, pasted it into microsoft office Word and had it replace all instance of "Chair" with "SmokyquartzPillar" (the name of the mod block I want to rotate) and pasted it into the code immediately after the last line that started with the word "input"

[spoiler]

import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;

public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

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

@Override
public IBlockState getStateForEntityRender(IBlockState state) {

return getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
}

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

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

return getDefaultState().withProperty(FACING, facing);
}

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

@Override
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[]{FACING});
}
@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos,
EnumFacing facing, float hitX, float hitY, float hitZ, int meta,
EntityLivingBase placer) {
return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}

CODE(version 1.9+):
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.entity.EntityLivingBase;

public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

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

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

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

return getDefaultState().withProperty(FACING, facing);
}

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

@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[]{FACING});
}
@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos,
EnumFacing facing, float hitX, float hitY, float hitZ, int meta,
EntityLivingBase placer) {
return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}

.JSON file:

{ "variants": { "facing=up": { "model": "TestEnvironmentMod:SmokyquartzPillar" },
"facing=south": { "model": "TestEnvironmentMod:SmokyquartzPillar" },
"facing=east": { "model": "TestEnvironmentMod:SmokyquartzPillar","y":270 },
"facing=west": { "model": "TestEnvironmentMod:SmokyquartzPillar","y":90 },
"facing=north": { "model": "TestEnvironmentMod:SmokyquartzPillar","y":180 } }
} [/spoiler]

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Nuparu00 
Wed, 11/30/2016 - 12:26

@Nuparu00 

Were you able to determine if the problem was just a missing bracket?

Last seen on 13:38, 21. Aug 2018
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sure lots of ppl need this 4
Wed, 11/30/2016 - 14:34

Sure lots of ppl need this 4 their mods.

Last seen on 03:49, 1. May 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:@Nuparu00 
Sun, 12/04/2016 - 14:58

@#14 I think the problem might be that the code was copied from youtube, as youtube likes to put in random invisible characters.

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:@Nuparu00 
Sun, 12/04/2016 - 19:19

@#14.1

I copied it into microsoft office word first, then changed the block name, and then put it into the code source. I did not see any random characters show up. If they are there, how do I get rid of them?

Last seen on 03:49, 1. May 2023
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:@Nuparu00 
Mon, 12/05/2016 - 03:40

@#14.1.1 The only way I know how is pasting the code into a command block, removing the characters that look like a bunch of numbers in a box, and copying it again.

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Or it is just not supposed to
Mon, 12/05/2016 - 07:59

Or it is just not supposed to copy-paste. For example I do not know why do you use both versions of code. If you have versions 1.8.x , use the fist one , if you have 1.9+ (1.9.x , 1.10.x ) , use the second one. + also in the video you can see that the code in my editor is much longer . It is because in description the code is only the parts that i write because the other parts are generated by MCreator.

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That could very well be the
Mon, 12/05/2016 - 12:28

That could very well be the problem. I did not notic that there were 2 codes there. Duh! I feel stupid now. Thanks for all the help though.

Last seen on 21:48, 16. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It worked for me, very
Thu, 12/22/2016 - 02:10

It worked for me, very helpfull ;) but is there a way to rotate the collider also in players direction? the model rotates but not the collider :/

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, it is possible. There is
Thu, 12/22/2016 - 06:15

Yes, it is possible. There is one method where you can check the facing and make a bounding box dependent on it

Last seen on 21:48, 16. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Yes, it is possible. There is
Thu, 12/22/2016 - 13:09

can you pls write a description how to do that? or a video tutorial? this would be great :)