Started by
Nuparu00
on
Topic category: User side tutorials
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
@#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)
@#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]
It actually really seems like missing bracket. Can I see your code?
@#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]
@Nuparu00
Were you able to determine if the problem was just a missing bracket?
Sure lots of ppl need this 4 their mods.
@#14 I think the problem might be that the code was copied from youtube, as youtube likes to put in random invisible characters.
@#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?
@#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.
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.
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.
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 :/
Yes, it is possible. There is one method where you can check the facing and make a bounding box dependent on it
can you pls write a description how to do that? or a video tutorial? this would be great :)