Topic category: Help with Minecraft modding (Java Edition)
I figured that since log like rotation is different from the rotatable block code video (which is for rotation about the Y-axis), it should diverge into a new forum.
So @nuparu00, you previously posted this:
You can do it this way: extend BlockRotatedPillar and instead of the parts of code from the video use this alternative code (simply replace the most similar thing to it , other code from the video just remove):
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
And the blockstate file:
{
"variants": {
"axis=y": { "model": "testenvironmentmod:smokyquartzpillar" },
"axis=z": { "model": "testenvironmentmod:smokyquartzpillar", "x": 90 },
"axis=x": { "model": "testenvironmentmod:smokyquartzpillar", "x": 90, "y": 90 }
}
}
Well, I tried to add that code in where I thought it should go based on the sample code for rotation about the Y-axis, and I got this error:
#################################################
:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:86: error: cannot find symbol
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
^
symbol: variable AXIS
location: class BlockEnderquartzPillar
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
I'm not sure what to do to fix this problem. Can you help me?
Did you extend BlockRotatedPillar?
@#1
How do I do that? There is nothing in the code right now about BlockRotatedPillar.
Actually, here is the block's current code. I forgot to post it in the original comment:
[spoiler]
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraft.world.World; import net.minecraft.world.IBlockAccess; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.EnumFacing; import net.minecraft.util.BlockRenderLayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemBlock; import net.minecraft.item.Item; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.Minecraft; import net.minecraft.block.state.IBlockState; import net.minecraft.block.material.Material; import net.minecraft.block.SoundType; import net.minecraft.block.Block; import java.util.Random; public class mcreator_enderquartzPillar { public mcreator_enderquartzPillar() { } public static BlockEnderquartzPillar block; public static Object instance; public int addFuel(ItemStack fuel) { return 0; } public void serverLoad(FMLServerStartingEvent event) { } public void preInit(FMLPreInitializationEvent event) { block.setRegistryName("enderquartzpillar"); GameRegistry.register(block); GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); } public void registerRenderers() { } public void load(FMLInitializationEvent event) { if (event.getSide() == Side.CLIENT) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("testenvironmentmod:enderquartzpillar", "inventory")); } GameRegistry.addRecipe(new ItemStack(block, 2), new Object[]{"XXX", "X4X", "X7X", Character.valueOf('4'), mcreator_enderquartzblock.block, Character.valueOf('7'), mcreator_enderquartzblock.block,}); } static { block = (BlockEnderquartzPillar) (new BlockEnderquartzPillar().setHardness(0.8F).setResistance(4.0F).setLightLevel(0.0F) .setUnlocalizedName("EnderquartzPillar").setLightOpacity(0).setCreativeTab(mcreator_modBlocks.tab)); block.setHarvestLevel("pickaxe", 1); } public void generateSurface(World world, Random random, int chunkX, int chunkZ) { } public void generateNether(World world, Random random, int chunkX, int chunkZ) { } static class BlockEnderquartzPillar extends Block { int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0; boolean red = false; protected BlockEnderquartzPillar() { super(Material.ROCK); setSoundType(SoundType.STONE); this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y)); } @Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world)); } @Override public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return red ? 15 : 0; } @Override public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return red ? 15 : 0; } @SideOnly(Side.CLIENT) @Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.SOLID; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); } @Override public int tickRate(World world) { return 10; } @Override public int quantityDropped(Random par1Random) { return 1; } } }[/spoiler]
Your block is now extending Block , you have to extend BlockRotatedPillar
I got the log code working what was posted before by extending the BlockRotatedPillar part
The post what Nuparu00 posted
[spoiler]
You can do it this way: extend BlockRotatedPillar and instead of the parts of code from the video use this alternative code (simply replace the most similar thing to it , other code from the video just remove):
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
And the blockstate file:
{
"variants": {
"axis=y": { "model": "testenvironmentmod:smokyquartzpillar" },
"axis=z": { "model": "testenvironmentmod:smokyquartzpillar", "x": 90 },
"axis=x": { "model": "testenvironmentmod:smokyquartzpillar", "x": 90, "y": 90 }
}
}
[/spoiler]
Worked for me to rotate like wood, I this one worked out of the box.
@#4 Can you post some pastebin with the code please?, I'm having the same problems like Eonaut, Thanks.
@nuparuu00 and/or @luelusten
I'm sorry. I just don't understand what to do here.
The only thing I thought made sense was to replace the line:
static class BlockEnderquartzPillar extends Block
with
static class BlockEnderquartzPillar extends BlockRotatatedPillar
but when I did that, I went from one error to 20
[spoiler]
#################################################
:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:76: error: cannot find symbol
static class BlockEnderquartzPillar extends BlockRotatedPillar {
^
symbol: class BlockRotatedPillar
location: class mcreator_enderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:45: error: cannot find symbol
block.setRegistryName("enderquartzpillar");
^
symbol: method setRegistryName(String)
location: variable block of type BlockEnderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:46: error: no suitable method found for register(BlockEnderquartzPillar)
GameRegistry.register(block);
^
method GameRegistry.register(K#1) is not applicable
(inferred type does not conform to upper bound(s)
inferred: BlockEnderquartzPillar
upper bound(s): IForgeRegistryEntry?>)
method GameRegistry.register(K#2,ResourceLocation) is not applicable
(cannot infer type-variable(s) K#2
(actual and formal argument lists differ in length))
where K#1,K#2 are type-variables:
K#1 extends IForgeRegistryEntry?> declared in method register(K#1)
K#2 extends IForgeRegistryEntry?> declared in method register(K#2,ResourceLocation)
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:47: error: cannot find symbol
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
^
symbol: method getRegistryName()
location: variable block of type BlockEnderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:47: error: incompatible types: BlockEnderquartzPillar cannot be converted to Block
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:56: error: incompatible types: BlockEnderquartzPillar cannot be converted to Block
.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("testenvironmentmod:enderquartzpillar", "inventory"));
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:59: error: no suitable constructor found for ItemStack(BlockEnderquartzPillar,int)
GameRegistry.addRecipe(new ItemStack(block, 2), new Object[]{"XXX", "X4X", "X7X", Character.valueOf('4'), mcreator_enderquartzblock.block,
^
constructor ItemStack.ItemStack(Block,int) is not applicable
(argument mismatch; BlockEnderquartzPillar cannot be converted to Block)
constructor ItemStack.ItemStack(Item,int) is not applicable
(argument mismatch; BlockEnderquartzPillar cannot be converted to Item)
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:65: error: cannot find symbol
block = (BlockEnderquartzPillar) (new BlockEnderquartzPillar().setHardness(0.8F).setResistance(4.0F).setLightLevel(0.0F)
^
symbol: method setHardness(float)
location: class BlockEnderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:67: error: cannot find symbol
block.setHarvestLevel("pickaxe", 1);
^
symbol: method setHarvestLevel(String,int)
location: variable block of type BlockEnderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:85: error: cannot find symbol
setSoundType(SoundType.STONE);
^
symbol: method setSoundType(SoundType)
location: class BlockEnderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:86: error: cannot find symbol
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
^
symbol: variable AXIS
location: class BlockEnderquartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:86: error: cannot find symbol
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
^
symbol: variable blockState
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:90: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:95: error: incompatible types: BlockEnderquartzPillar cannot be converted to Block
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:99: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:104: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:110: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:115: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:120: error: method does not override or implement a method from a supertype
@Override
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_enderquartzPillar.java:125: error: method does not override or implement a method from a supertype
@Override
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
20 errors
:compileJava FAILED
[/spoiler]
I did not see any other lines with "extend in them". The only other thing I can think of is to replace every "Block" with "BlockRotatedPillar", but I doubt that is right.
Please help.
You need to import net.minecraft.block.BlockRotatatedPillar
Add the import or fix the imports, the BlockRotationedPillar was found on the fix option for me but if it does not add it like Nuparu00 said.
I would post the block but at the moment I am in another mod what I can't afford to mess up with creating it again, so right now you would have to wait.
I GOT IT TO WORK!
YAY!
Thank you for the help.
-Eonaut
Yes, thanks It worked, thanks for your help Napara00 and LueLusten.
It's all down to Napara00 :) sometimes it just takes someone else to explain a little to make it click lol