Java Code Examples for net.minecraft.block.Block#getStateById()
The following examples show how to use
net.minecraft.block.Block#getStateById() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public void readFromNBTCustom(NBTTagCompound nbt) { if (nbt.hasKey("Rotation", Constants.NBT.TAG_BYTE)) { this.facing = EnumFacing.byIndex(nbt.getByte("Rotation")); } /* if (nbt.hasKey("Camo", Constants.NBT.TAG_COMPOUND)) { this.camoState = NBTUtils.readBlockStateFromTag(nbt.getCompoundTag("Camo")); } */ if (nbt.hasKey("Camo", Constants.NBT.TAG_INT)) { this.camoState = Block.getStateById(nbt.getInteger("Camo")); } if (nbt.hasKey("CamoData", Constants.NBT.TAG_COMPOUND)) { this.camoData = nbt.getCompoundTag("CamoData"); } this.ownerData = OwnerData.getOwnerDataFromNBT(nbt); }
Example 2
Source File: EntityBlock.java From OpenModsLib with MIT License | 6 votes |
@Override @SuppressWarnings("deprecation") protected void readEntityFromNBT(NBTTagCompound tag) { if (tag.hasKey(TAG_BLOCK_STATE_ID)) { final int blockStateId = tag.getInteger(TAG_BLOCK_STATE_ID); this.blockState = Block.getStateById(blockStateId); } else { int meta = tag.getByte(TAG_BLOCK_META) & 255; final ResourceLocation blockId = NbtUtils.readResourceLocation(tag.getCompoundTag(TAG_BLOCK_ID)); final Block block = Block.REGISTRY.getObject(blockId); this.blockState = block.getStateFromMeta(meta); } if (tag.hasKey(TAG_TILE_ENTITY, Constants.NBT.TAG_COMPOUND)) this.tileEntity = tag.getCompoundTag(TAG_TILE_ENTITY); else this.tileEntity = null; }
Example 3
Source File: BlockStorage.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public void fromBuf(ByteBuf buf, World world) { blockstate = Block.getStateById(buf.readInt()); light = buf.readInt(); NBTTagCompound tag = ByteBufUtils.readTag(buf); if(tag != null) { tileentity = TileEntity.create(world, tag); } }
Example 4
Source File: WrapperBlock.java From ClientBase with MIT License | 4 votes |
public static WrapperIBlockState getStateById(int var0) { return new WrapperIBlockState(Block.getStateById(var0)); }
Example 5
Source File: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void handleUpdateTag(NBTTagCompound tag) { if (tag.hasKey("r")) { this.setFacing(EnumFacing.byIndex((byte)(tag.getByte("r") & 0x07))); } if (tag.hasKey("o", Constants.NBT.TAG_STRING)) { this.ownerData = new OwnerData(tag.getString("o"), tag.getBoolean("pu")); } if (tag.hasKey("Camo", Constants.NBT.TAG_INT)) { this.camoState = Block.getStateById(tag.getInteger("Camo")); World world = this.getWorld(); BlockPos pos = this.getPos(); IBlockState stateSelf = world.getBlockState(pos); // Temporarily place the target block to be able to grab its data if (this.camoState != null && this.camoState.getBlock() != Blocks.AIR) { try { BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 16); if (world.setBlockState(pos, this.camoState, 16)) { if (tag.hasKey("CD", Constants.NBT.TAG_COMPOUND)) { this.camoData = tag.getCompoundTag("CD"); TileEntity te = world.getTileEntity(pos); if (te != null) { te.handleUpdateTag(this.camoData); } } this.camoState = this.camoState.getActualState(world, pos); this.camoStateExtended = this.camoState.getBlock().getExtendedState(this.camoState, world, pos); BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 16); world.setBlockState(pos, stateSelf, 16); this.validate(); // re-validate after being removed by the setBlockState() to air world.setTileEntity(pos, this); } } catch (Exception e) { EnderUtilities.logger.warn("Exception while trying to grab the Extended state for a camo block: {}", this.camoState, e); } } } else { this.camoState = null; this.camoStateExtended = null; } this.getWorld().checkLightFor(EnumSkyBlock.BLOCK, this.getPos()); this.notifyBlockUpdate(this.getPos()); }
Example 6
Source File: EntityBlock.java From OpenModsLib with MIT License | 4 votes |
@Override public void readSpawnData(ByteBuf additionalData) { this.blockState = Block.getStateById(additionalData.readInt()); this.hasGravity = additionalData.readBoolean(); }
Example 7
Source File: SyncableBlockState.java From OpenModsLib with MIT License | 4 votes |
@Override public void readFromStream(PacketBuffer buf) { final int id = buf.readVarInt(); state = Block.getStateById(id); }