private void createData(final byte data) { Material mat = Material.getMaterial(type); if (mat == null) { this.data = new MaterialData(type, data); } else { this.data = mat.getNewData(data); } }
@Override public void loadNbt(CompoundTag tag) { super.loadNbt(tag); tag.tryGetMaterial("Item").ifPresent( item -> this.contents = item.getNewData( (byte) (int) (tag.tryGetInt("Data").orElse(0)))); }
private void makeData(byte data) { Material mat = Material.getMaterial(typeId); if (mat == null) { this.data = new MaterialData(typeId, data); } else { this.data = mat.getNewData(data); } }
@Override public MaterialData getTypeAndData(int x, int y, int z) { return getType(x, y, z).getNewData(getData(x, y, z)); }
/** * Gets the MaterialData for this stack of items * * @return MaterialData for this item */ public MaterialData getData() { Material mat = getType(); if (data == null && mat != null && mat.getData() != null) { data = mat.getNewData((byte) this.getDurability()); } return data; }
private void createData(final byte data) { Material mat = Material.getMaterial(type); if (mat == null) { this.data = new MaterialData(type, data); } else { this.data = mat.getNewData(data); } }
/** * Gets the MaterialData for this stack of items * * @return MaterialData for this item */ public MaterialData getData() { Material mat = getType(); if (data == null && mat != null && mat.getData() != null) { data = mat.getNewData((byte) this.getDurability()); } return data; }
/** * Obtains the Material Data using the material type Id and data value specified * * @param type of the material * @param rawData for the material * @return new MaterialData instance for this type of material and data */ @SuppressWarnings("deprecation") public static MaterialData getData(Material type, int rawData) { if (type == null) { return new MaterialData(0, (byte) rawData); } final MaterialData mdata = type.getNewData((byte) rawData); // Fix attachable face returning NULL sometimes if (mdata instanceof Attachable) { Attachable att = (Attachable) mdata; if (att.getAttachedFace() == null) { att.setFacingDirection(BlockFace.NORTH); } } return mdata; }