Jump to content

Bernasss12

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Bernasss12

  1. Try changing the "parent" from "momod:fast_cooker" to just "fast_cooker". Or try creating the .json files with the forge structure. Play around and try things out.
  2. Well, maybe you forgot to set a hardness value, and when you do that, if the material you chose is something that needs a pick to drop the block that behavior could happen and the bugginess if for some odd reason the block was only being destroyed on the client side. Tbh haven´t done anything related to tile entities so I can´t help you with it.
  3. Yes, the blocks i have right now all have 3 different textures, just like the vannila furnace, pumpkin, dispenser, dropper etc. You could probably just go take a look on the code but here's what i think makes it work: BaseBlock class must have (in my case): public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); This is a direct copy of the vannila classes but basically this makes the direction only include north, south, east and west, not having up or down. Then in the BaseBlock constructor you must have a default "facing" state (I believe this only affects the block while it is not placed in the world): setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); Vanilla mc uses North for example. The other things I have on that same class are: public void registerItemModel(ItemBlock itemBlock) { PlusBlazeToolsMain.proxy.registerItemRenderer(itemBlock, 0, name); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[]{FACING}); } public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.setDefaultFacing(worldIn, pos, state); } private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } I'm sure im not the best to explain but I understand most of it. Go check the proxys and stuff i have on my repo so i dont have to say everything. But in general: registerItemModel() will register the inventory icon of your block, it is a model file that can be however you like (block or item). I made it just like the block when placed. createBlockState() will create the block state based on the property you created. onBlockAdded() in this case is used to change the default state of the your property to your real world use in this case based on: setDefaultFacing() setDefaultFacing() will return the direction the player is currently facing, im not sure how this works bc it's a direct copy from vanila and I still haven´t really thought about it. getStateForPlacement() will get the direction of the player and make the block be placed facing the opposite direction, you can change it acconding to your needs by just not using .getOpposite().0 getMetaFromState() the game will ask for it, just copy it and use it. The files you need in your assets: assets/modid/blockstates/yourblock_registry_name.json { "variants": { "facing=north": { "model": "modid:yourblock_registry_name_normal" }, "facing=east": { "model": "modid:yourblock_registry_name_normal", "y": 90 } "facing=south": { "model": "modid:yourblock_registry_name_normal", "y": 180 }, "facing=west": { "model": "modid:yourblock_registry_name_normal", "y": 270 }, } } assets/modid/models/block/yourblock_registry_name_normal.json { "parent": "block/orientable", "textures": { "top": "modid:blocks/yourblock_texturename_top", "front": "modid:blocks/yourblock_texturename_front", "side": "modid:blocks/yourblock_texturename_side" } } I used the vanilla parent block/orientable bc i dont reall need forge's json complexity, i think this is easier. assets/modid/models/item/yourblock_registry_name.json { "parent": "yourblock_registry_name_normal", "display": { "thirdperson": { "rotation": [ 10, -45, 170], "translation": [ 0, 1.5, -2.75], "scale": [ 0.375, 0.375, 0.375] } } } I don't have much experience, I rely heavily on vanilla code and tutorials but i like to try things out until they work. I hope this was useful or that at least you understood something from this. Good luck!
  4. Just noticed my mistake, forgot to create the json files for gold diamond and emerald blocks. Sorry to bother you and thanks for helping me.
  5. Hello, I'm new to modding and know just a little bit of Java but while making a mod just to learn the basics I stumbled across a problem I can´t really understand. I'm using the same ModBlock class for every block on my mod, they are basic blocks (Iron, Gold, Diamond and Emerald Blocks for their Blazed versions) and while everything works great with the Iron Block, the others don't seem to have a ItemBlock model. This was working fine on 1.10.2 but now in 1.11 this happens. System: (https://github.com/Bernasss12/PlusBlazeToolsMod/tree/master/src/main/java/com/bernasss12/pbtmod/block) ModBlock (extends Block): package com.bernasss12.pbtmod.block; import com.bernasss12.pbtmod.PlusBlazeToolsMain; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** * Created by Bernardo on 30/11/2016. */ public class ModBlock extends Block { protected String name; public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public ModBlock(Material material, String unlocalizedName, String textureName) { super(material); this.name = textureName; setUnlocalizedName(unlocalizedName); setRegistryName(name); setHardness(3.0F); setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } public void registerItemModel(ItemBlock itemBlock) { PlusBlazeToolsMain.proxy.registerItemRenderer(itemBlock, 0, name); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[]{FACING}); } public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.setDefaultFacing(worldIn, pos, state); } private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public ModBlock setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } @Override public ModBlock setLightOpacity(int opacity) { super.setLightOpacity(opacity); return this; } @Override public ModBlock setLightLevel(float value) { super.setLightLevel(value); return this; } @Override public ModBlock setResistance(float resistance) { super.setResistance(resistance); return this; } } ModBlocks (registers everything): package com.bernasss12.pbtmod.block; import com.bernasss12.pbtmod.PlusBlazeToolsMain; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; /** * Created by Bernardo on 06/12/2016. */ public class ModBlocks { /** Creating variable to every block. */ public static ModBlock blazedGoldBlock; public static ModBlock blazedDiamondBlock; public static ModBlock blazedEmeraldBlock; public static ModBlock blazedIronBlock; public static void preInit(){ /** Registering every block. */ blazedGoldBlock = register(new ModBlock(Material.IRON, "blazedGoldBlock", "blazed_gold_block").setCreativeTab(PlusBlazeToolsMain.tabGeneral).setLightLevel(7.5F)); blazedDiamondBlock = register(new ModBlock(Material.IRON, "blazedDiamondBlock", "blazed_diamond_block").setCreativeTab(PlusBlazeToolsMain.tabGeneral).setLightLevel(11.25F)); blazedEmeraldBlock = register(new ModBlock(Material.IRON, "blazedEmeraldBlock", "blazed_emerald_block").setCreativeTab(PlusBlazeToolsMain.tabGeneral).setLightLevel(15F)); blazedIronBlock = register(new ModBlock(Material.IRON, "blazedIronBlock", "blazed_iron_block").setCreativeTab(PlusBlazeToolsMain.tabGeneral).setLightLevel(3.75F)); } private static <T extends Block> T register(T block, ItemBlock itemBlock) { GameRegistry.register(block); GameRegistry.register(itemBlock); if (block instanceof ModBlock) { ((ModBlock)block).registerItemModel(itemBlock); } return block; } private static <T extends Block> T register(T block) { ItemBlock itemBlock = new ItemBlock(block); itemBlock.setRegistryName(block.getRegistryName()); return register(block, itemBlock); } } Images: The code is heavily influenced by wehavecookies YouTube tutorials, ShadowFact's web tutorials, TheGreyGhost's Minecraft By Example and more. Hope you can help.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.