Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

NyasRoryo

Members
  • Joined

  • Last visited

  1. I look tf's code just now. Almost same, and I fail
  2. emm... How a correct createBlockState like, plz show me thanks!!! and about BlockBase.class, I put hardness, resistance setter in it(because my mod's block's data is integrated in a class
  3. @Draco18s Sorry, I just commented it when I was debugging, but it throws NullPointerExpection after removing the comment. And how can I do now... Plz help me thx
  4. ... I mean multi block use an ID, use damage to distinguish. Who can give a example .java file with basic code to create and registry it and its ItemBlock? If you can show me how to give a TranslationKey, that's fantastic! Please help me... I've been trying for three days, I look ic2, te5 and even gtce, and I still can't understand how to meta-hack the block... my code: package com.github.nyasroryo.lanticaltech.common.block.buildmaterial; import com.github.nyasroryo.lanticaltech.common.block.BlockBase; import net.minecraft.block.Block; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; import net.minecraft.util.NonNullList; public class CeramicTile extends BlockBase { private static final String NAME = "CeramicTile"; public static final Block THIS_BLOCK = new CeramicTile(); public static final Item THIS_ITEMBLOCK = new ItemBlock(THIS_BLOCK).setRegistryName(NAME); public static final PropertyEnum<EnumColor> COLOR = PropertyEnum.create("color", EnumColor.class); public CeramicTile() { super(NAME); //set Hardness, resistance, sound etc. in other class setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumColor.WHITE)); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, COLOR); } @Override public IBlockState getStateFromMeta(int metadata) { return this.getDefaultState().withProperty(COLOR, EnumColor.values()[metadata]); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(COLOR).ordinal(); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } @Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) { for (EnumDyeColor enumdyecolor : EnumDyeColor.values()) { items.add(new ItemStack(this, 1, enumdyecolor.getMetadata())); } } public static enum EnumColor implements IStringSerializable { WHITE("white"), BLACK("black"), RED("red"), BLUE("blue"), GREEN("green"), YELLOW("yellow"), ORANGE("orange"), GREY("grey"), PURPLE("purple"), CYAN("cyan"), PINK("pink"), MAGENTA("magenta"), BROWN("brown"), LIGHTBLUE("lightblue"), LIGHTGREY("lightgrey"), LIGHTGREEN("lightgreen"); private String name; private EnumColor(String color) { this.name = color; } @Override public String getName() { return this.name; } @Override public String toString() { return this.name; } } } Registry and error: ForgeRegistries.BLOCKS.register(CeramicTile.THIS_BLOCK); ForgeRegistries.ITEMS.register(CeramicTile.THIS_ITEMBLOCK); ModelLoader.setCustomModelResourceLocation(CeramicTile.THIS_ITEMBLOCK, 0, new ModelResourceLocation("CeramicTile","inventory")); ModelLoader.setCustomModelResourceLocation(CeramicTile.THIS_ITEMBLOCK, 1, new ModelResourceLocation("CeramicTile","inventory")); ModelLoader.setCustomModelResourceLocation(CeramicTile.THIS_ITEMBLOCK, 2, new ModelResourceLocation("CeramicTile","inventory")); Caused by: java.lang.NullPointerException at net.minecraft.block.state.BlockStateContainer.validateProperty(BlockStateContainer.java:103) at net.minecraft.block.state.BlockStateContainer.<init>(BlockStateContainer.java:77) at net.minecraft.block.state.BlockStateContainer.<init>(BlockStateContainer.java:62) at com.github.nyasroryo.lanticaltech.common.block.buildmaterial.CeramicTile.createBlockState(CeramicTile.java:32) at net.minecraft.block.Block.<init>(Block.java:313) at net.minecraft.block.Block.<init>(Block.java:322) at com.github.nyasroryo.lanticaltech.common.block.BlockBase.<init>(BlockBase.java:13) at com.github.nyasroryo.lanticaltech.common.block.buildmaterial.CeramicTile.<init>(CeramicTile.java:26) at com.github.nyasroryo.lanticaltech.common.block.buildmaterial.CeramicTile.<clinit>(CeramicTile.java:20) ... 51 more

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.