Topic category: Help with MCreator software
Hey there, @Nuparu00 or others could you please post the fill block code for 1.10.2 and 1.11.2
I watched the video and I am dyslexic so my brain is not able to put the code in place, if you could
post a default block with the rotation for them two version I sure I can do the json file part, long as
I edit the right json file.
Please guys I know this is a pest but this is how I can learn and others, I really did try watch the
video and I not getting it, but if I have the code I can look at a plane one and the modded one and learn
Please I know I am asking to take your time up here but it really would help, thanks.
And will it work on a model like so
Code:
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.Item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.creativetab.CreativeTabs;
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_testt {
public mcreator_testt() {
}
public static BlockTestt block;
public static Object instance;
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
}
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:Testt", "inventory"));
}
}
static {
block = (BlockTestt) (new BlockTestt().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F).setUnlocalizedName("Testt")
.setLightOpacity(0).setCreativeTab(CreativeTabs.BUILDING_BLOCKS));
block.setHarvestLevel("axe", 0);
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
static class BlockTestt extends Block {
int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
boolean red = false;
protected BlockTestt() {
super(Material.WOOD);
GameRegistry.registerBlock(this, "Testt");
setSoundType(SoundType.WOOD);
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@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;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@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, 1.0D, 1.0D, 1.0D, 0.87D);
}
@Override
public int tickRate(World world) {
return 10;
}
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
}
}
JSON:
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": {
"0": "blocks/planks_birch"
},
"elements": [
{
"name": "Top",
"from": [ 0.0, 15.0, 14.0 ],
"to": [ 16.0, 16.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 16.0, 6.0, 0.0, 7.0 ], "rotation": 180 },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 16.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 2.0, 16.0, 16.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 16.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 2.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 2.0 ] }
}
},
{
"name": "Side1",
"from": [ 0.0, 0.0, 15.0 ],
"to": [ 1.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side2",
"from": [ 15.0, 0.0, 15.0 ],
"to": [ 16.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side3",
"from": [ 2.0, 0.0, 15.0 ],
"to": [ 3.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side4",
"from": [ 13.0, 0.0, 15.0 ],
"to": [ 14.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side5",
"from": [ 4.0, 0.0, 15.0 ],
"to": [ 5.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side6",
"from": [ 11.0, 0.0, 15.0 ],
"to": [ 12.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side7",
"from": [ 6.0, 0.0, 15.0 ],
"to": [ 7.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Side8",
"from": [ 9.0, 0.0, 15.0 ],
"to": [ 10.0, 15.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] }
}
},
{
"name": "Middle1",
"from": [ 7.0, 10.0, 15.0 ],
"to": [ 9.0, 12.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 13.0, 7.0, 15.0, 9.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 3.0, 14.0, 5.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
"up": { "texture": "#0", "uv": [ 13.0, 7.0, 15.0, 8.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] }
}
},
{
"name": "Middle2",
"from": [ 7.0, 6.0, 15.0 ],
"to": [ 9.0, 8.0, 16.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 13.0, 7.0, 15.0, 9.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
"south": { "texture": "#0", "uv": [ 12.0, 7.0, 14.0, 9.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
"up": { "texture": "#0", "uv": [ 13.0, 7.0, 15.0, 8.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 2.0, 1.0 ] }
}
},
{
"name": "Bottom",
"from": [ 0.0, 0.0, 14.0 ],
"to": [ 16.0, 1.0, 15.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ], "rotation": 180 },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }
}
}
]
}
Having to make this model again 6 times is painful so far this means this item would have 12 blocks in game for only 2 block useages just because my dyslexia is blocking me to understand something.
This would be really helpful for me too, simply because I have watched the video, done the code edits, and never gotten it to work properly.
This is the code used in MCreator 1.7.5 for Minecraft 1.11.2.
https://pastebin.com/uXADaz8u
@#2 what do I have to change in this to make it work in 1.7.4 (1.10.2) and thank you for your reply
@Nuparu00
Can you please help me out with two things:
1- I tried making a new block called "Test" with the wood material and an axe as the tool to destroy it, just like in the sample code, then replaced all of the automaticlly generated code for that block with yours and it worked-- BUT the textures were the black and purple missing texture texture with the direction it was facing listed on the top surface in blue.
2- When I tried adding in all of the lines from the sample code into the code of one of my mod's blocks that were not there before, it did not work, and gave me 4 errors, as seen here:
[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_smokyQuartzPillar.java:100: error: cannot find symbol
return getDefaultState().withProperty(FACING, facing);
^
symbol: variable FACING
location: class BlockSmokyQuartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_smokyQuartzPillar.java:104: error: cannot find symbol
return ((EnumFacing) state.getValue(FACING)).getIndex();
^
symbol: variable FACING
location: class BlockSmokyQuartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_smokyQuartzPillar.java:108: error: cannot find symbol
return new BlockStateContainer(this, new IProperty[]{FACING});
^
symbol: variable FACING
location: class BlockSmokyQuartzPillar
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_smokyQuartzPillar.java:112: error: cannot find symbol
return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
^
symbol: variable FACING
location: class BlockSmokyQuartzPillar
4 errors
: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.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
[/spoiler]
I beleive this is the same error I was getting in all previous version of MCreator when I tried making rotatable blocks. My questions now are:
1.) is there still something i'm doing wrong and what is it?
2.) Do i need to create a variable for "Facing", since that seems to be the main problem? If so, what are the parameters for the new variable? I have no idea what any of them do (number, logic, or string) or what the initial value should be (new variable creation defaults to 1). I'm assuming the name would just be "FACING"
Variable FACING is declared by this line in the class of the block:
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
You can't use MCreator's variable system, as only data types it directly supports are String, Integer, and Boolean, facing is of type PropertyDirection.
The origin of your issue with the model/texture is most likely in the blockstate .json file of your block.
@#4
Well, I got all the code in, recompiled, and it worked in the sense that it did not spout any errors, but now the textures do not work, like when I tied the code alone by itself. See the image here: https://www.dropbox.com/s/ueslnncpeuon752/2017-10-13_17.29.53.png?dl=0
I'm using the normal block model for this, so I do not know how it could suddenly change something in that json file if there is one to begin with.How do I get the textures to work again?
The issue is not that something has changed the blockstate file. The issue is that you have not. The key is that you HAVE to edit the blockstate .json file so it has a model for every possible property value combination (simply for every meta value), no matter what model you are using. That is why in the video itself is the part from time 17:30 to 19:10. These two minutes there are not for making the video longer. They are there because of editing the blockstate .json file in a correct way.
Litlle explanation:
Every block placed in the world is not placed as the block class. The block class is a singleton - meaning that there is just one instance of the class in the whole session. The actual information about the exact block is in a BlockState class (+ TileEntity if you are using it). The blockstate can have properties, that are later "packed" to metadata, that means you can have up to 16 property values. Now, when the block is rendered, it first loads its blockstate file. In a normal block, it just directly points to the model. If you have any property (and you do not put them on a sort of "blacklist"), there is needed for each possible combinations of property values assign a model. It is a bit more complicated in reality, but this is roughly the concept.
The behavior of Minecraft is not always just in the java files. In the most recent versions, you can even edit recipes and loot tables just in files like this.
I followed the video and edited the correct file, but it still did not work.
Can you post it here + your console log, please?
@#7
Block Code:
[spoiler]
package mod.mcreator; 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.Item; import net.minecraft.entity.EntityLivingBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.Minecraft; import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.IProperty; import net.minecraft.block.material.Material; import net.minecraft.block.SoundType; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import java.util.Random; public class mcreator_smokyQuartzPillar { public mcreator_smokyQuartzPillar() { } public static BlockSmokyQuartzPillar block; public static Object instance; public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public int addFuel(ItemStack fuel) { return 0; } public void serverLoad(FMLServerStartingEvent event) { } public void preInit(FMLPreInitializationEvent event) { block.setRegistryName("smokyquartzpillar"); 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:smokyquartzpillar", "inventory")); } GameRegistry.addRecipe(new ItemStack(block, 2), new Object[]{"XXX", "X4X", "X7X", Character.valueOf('4'), mcreator_smokyquartzBlock.block, Character.valueOf('7'), mcreator_smokyquartzBlock.block,}); } static { block = (BlockSmokyQuartzPillar) (new BlockSmokyQuartzPillar().setHardness(0.8F).setResistance(4.0F).setLightLevel(0.0F) .setUnlocalizedName("SmokyQuartzPillar").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 BlockSmokyQuartzPillar extends Block { int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0; boolean red = false; protected BlockSmokyQuartzPillar() { super(Material.ROCK); setSoundType(SoundType.STONE); } @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 getStateForPlacement(World worldIn, BlockPos pos,EnumFacing facing, float hitX, float hitY, float hitZ, int meta,EntityLivingBase placer) { return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @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]
JSON file:
[spoiler]
{ "variants": { "facing=up": { "model": "testenvironmentmod:smokyquartzpillar" } "facing=south": { "model": "testenvironmentmod:smokyquartzpillar" } "facing=east": { "model": "testenvironmentmod:smokyquartzpillar","y":90 } "facing=west": { "model": "testenvironmentmod:smokyquartzpillar","y":270 } "facing=north": { "model": "testenvironmentmod:smokyquartzpillar","y":180 } } }[/spoiler]
In the blockstate .json file, there has to be a comma between each variant, for example like this: https://pastebin.com/zq2XfVPT
@#8
Now the texture is back, but it still does not rotate...
What does your blockstate .json file + console log look like?
@#9
I just added in the missing commas to the json file, so I don't know what could have changed...
Block Code:
[spoiler]
package mod.mcreator; 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.Item; import net.minecraft.entity.EntityLivingBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.Minecraft; import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.IProperty; import net.minecraft.block.material.Material; import net.minecraft.block.SoundType; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import java.util.Random; public class mcreator_smokyQuartzPillar { public mcreator_smokyQuartzPillar() { } public static BlockSmokyQuartzPillar block; public static Object instance; public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public int addFuel(ItemStack fuel) { return 0; } public void serverLoad(FMLServerStartingEvent event) { } public void preInit(FMLPreInitializationEvent event) { block.setRegistryName("smokyquartzpillar"); 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:smokyquartzpillar", "inventory")); } GameRegistry.addRecipe(new ItemStack(block, 2), new Object[]{"XXX", "X4X", "X7X", Character.valueOf('4'), mcreator_smokyquartzBlock.block, Character.valueOf('7'), mcreator_smokyquartzBlock.block,}); } static { block = (BlockSmokyQuartzPillar) (new BlockSmokyQuartzPillar().setHardness(0.8F).setResistance(4.0F).setLightLevel(0.0F) .setUnlocalizedName("SmokyQuartzPillar").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 BlockSmokyQuartzPillar extends Block { int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0; boolean red = false; protected BlockSmokyQuartzPillar() { super(Material.ROCK); setSoundType(SoundType.STONE); } @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 getStateForPlacement(World worldIn, BlockPos pos,EnumFacing facing, float hitX, float hitY, float hitZ, int meta,EntityLivingBase placer) { return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @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]
JSON
[spoiler]
{ "variants": { "facing=up": { "model": "testenvironmentmod:smokyquartzpillar" }, "facing=south": { "model": "testenvironmentmod:smokyquartzpillar" }, "facing=east": { "model": "testenvironmentmod:smokyquartzpillar","y":90 }, "facing=west": { "model": "testenvironmentmod:smokyquartzpillar","y":270 }, "facing=north": { "model": "testenvironmentmod:smokyquartzpillar","y":180 } } }[/spoiler]