User:Umucraft/Game mechanics/Internal representation of item and blocks - minecraft.fandom.com

Jump to navigation Jump to search
Treść tej podstrony pochodzi z artykułu „User:Umucraft/Game mechanics/Internal representation of item and blocks” w domenie minecraft.fandom.com na licencji CC BY-NC-SA 3.0
Gear (item)
This user page is a work in progress. 
Please help in the expansion or creation of this user page by expanding or improving it. The talk page may contain suggestions.
Information icon
This feature is exclusive to Java Edition. 

This page is about how items and blocks are internally represented in Minecraft, which is important for how the technical ItemBlocks were removed from the game and how to add new item and blocks.

Versions prior 1.3[]

Items

Items were represented as this in versions prior 12w18a:

// Representation and registry of items! Item ID is defined by int id + 255 offset, which makes item ids equal to 256 or bigger than 256. setIconCoord means the icon coordinate of the item in items.png

itemName = (new Item<the constructor of the item, necessary for extra functionality>(<int id>, <extra registry, is optional>, <extra id, is necessary for ItemFood constructor>)).setIconCoord(<horizontal coordinate>, <vertical coordinate>).setItemName("<translation key>");

A working example of this:

axeWood = (new ItemAxe(15, EnumToolMaterial.WOOD)).setIconCoord(0, 7).setItemName("hatchetWood");

And an example without extra constructors:

public static Item arrow = (new Item(6)).setIconCoord(5, 2).setItemName("arrow");

Blocks

Blocks were represented as this in versions prior 1.3:

// Representation and registry of blocks! Block ID is defined without any offset, which makes block ids equal to 255 or smaller than 255. Texture ID defines the texture of the block in terrain.png.

blockName = (new Block<the extra constructor of the block, necessary for extra functionality>(<item id>, <texture id>, <block material, necessary for "Block" constructor)).setHardness(<how hard is it to break this block, returns positive infinity when negative>).setResistance(<how hard is it to blow up this block>).setBlockName("<translation key>");

A working example of this without an extra constructor:

cobblestoneMossy = (new Block(48, 36, Material.rock)).setHardness(2.0F).setResistance(10F).setStepSound(soundStoneFootstep).setBlockName("stoneMoss");

And with an extra constructor:

obsidian = (new BlockObsidian(49, 37)).setHardness(10F).setResistance(2000F).setStepSound(soundStoneFootstep).setBlockName("obsidian");

Versions between 1.3 and 1.5[]

Items

In versions between 1.3.x (inclusive) and 1.5 (exclusive), the items were represented as this (there is id + 255 offset for items):

public static Item itemName = (new Item<extra constructor>(<item id>, <extra descriptor>)).setIconCoord(<horizontal position>, <vertical position>).setItemName("<translation key>").setTabToDisplayOn(CreativeTabs.<creative tab for display, is optional>);

A working example of this:

public static Item diamond = (new Item(8)).setIconCoord(7, 3).setItemName("diamond").setTabToDisplayOn(CreativeTabs.tabMaterials);

And with an extra constructor:

public static Item swordSteel = (new ItemSword(11, EnumToolMaterial.IRON)).setIconCoord(2, 4).setItemName("swordIron");


Blocks

In versions between 1.3.x (inclusive) and 1.5 (exclusive), the blocks were represented as this (there is no offset for blocks):

public static final Block blockName = (new Block<extra constructor>(<item id>, <texture id>), <material>).setHardness(<hardness>).setResistance(<resistance>).setStepSound(<step sound>).setLightValue(<level of light that block emits>).setLightOpacity(<opacity>).setBlockName("<translation key>");

A working example:

public static final Block stone = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stone");
And without extra constructor:

public static final Block planks = (new BlockWood(5)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundWoodFootstep).setBlockName("wood").setRequiresSelfNotify();

Versions between 1.5 and 1.6[]

Items

Items were represented as this in versions between 1.5 (inclusive) and 1.6 (exclusive):

public static itemName = (new Item<extra constructor, necessary for extra functionality>(<item id>, <extra descriptor>, <extra descriptor>).setUnlocalizedName(<name of the item>).setCreativeTab(<creative tab of the item>);

A working example:

public static Item bed = (new ItemBed(99)).setMaxStackSize(1).setUnlocalizedName("bed");

And without extra constructor:

public static Item pocketSundial = (new Item(91)).setUnlocalizedName("clock").setCreativeTab(CreativeTabs.tabTools);

Blocks

Blocks were represented as this:

public static final Block blockName = (new Block<extra constructor>(<id>, <material, necessary for "Block">).setHardness(<hardness>).setStepSound(<step sound>).setResistance(<resistance>).setLightValue(<light value>).setLightOpacity(<opacity>).setUnlocalizedName("<registered name>").setCreativeTab(CreativeTabs.<displayed creative tab>);

A working example:

public static final Block snow = (new BlockSnow(78)).setHardness(0.1F).setStepSound(soundSnowFootstep).setUnlocalizedName("snow").setLightOpacity(0);

And without extra constructor:

public static final Block brick = (new Block(45, Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("brick").setCreativeTab(CreativeTabs.tabBlock);

In versions 1.7.x[]