本文整理了Java中net.minecraft.block.Block.getBlockFromName()
方法的一些代码示例,展示了Block.getBlockFromName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getBlockFromName()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getBlockFromName
暂无
代码示例来源:origin: EngineHub/WorldEdit
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, Property<?>> map = new TreeMap<>();
Collection<IProperty<?>> propertyKeys = Block.getBlockFromName(blockType.getId())
.getDefaultState()
.getPropertyKeys();
for (IProperty<?> key : propertyKeys) {
map.put(key.getName(), ForgeAdapter.adaptProperty(key));
}
return map;
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public BlockMaterial getMaterial(BlockType blockType) {
return materialMap.computeIfAbsent(Block.getBlockFromName(blockType.getId()).getDefaultState().getMaterial(),
m -> new ForgeBlockMaterial(m, super.getMaterial(blockType)));
}
代码示例来源:origin: EngineHub/WorldEdit
BlockPos pos = new BlockPos(x, y, z);
IBlockState old = chunk.getBlockState(pos);
Block mcBlock = Block.getBlockFromName(block.getBlockType().getId());
IBlockState newState = mcBlock.getDefaultState();
Map<Property<?>, Object> states = block.getStates();
代码示例来源:origin: Vazkii/Botania
public static Block getBlock(ItemStack stack) {
Block block = Block.getBlockFromName(getBlockName(stack));
if(block == null)
return Blocks.AIR;
return block;
}
代码示例来源:origin: Vazkii/Botania
@Nullable
public static Block getBlock(ItemStack stack) {
return Block.getBlockFromName(getBlockName(stack));
}
代码示例来源:origin: Vazkii/Botania
public static Block getTargetBlock(ItemStack stack) {
Block block = Block.getBlockFromName(getTargetBlockName(stack));
return block;
}
代码示例来源:origin: Vazkii/Botania
public static Block getBlock(ItemStack stack) {
Block block = Block.getBlockFromName(getBlockName(stack));
return block;
}
代码示例来源:origin: Vazkii/Botania
@Override
public void readPacketNBT(NBTTagCompound cmp) {
Block b = Block.getBlockFromName(cmp.getString(TAG_CAMO));
if (b != null) {
camoState = b.getStateFromMeta(cmp.getInteger(TAG_CAMO_META));
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public boolean doParticles(IManaBurst burst, ItemStack stack) {
EntityThrowable entity = (EntityThrowable) burst;
ItemStack lens = burst.getSourceLens();
String id = ItemNBTHelper.getString(lens, TAG_BLOCK_NAME, "minecraft:air");
Block b = Block.getBlockFromName(id);
int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
entity.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ, Block.getStateId(b.getStateFromMeta(meta)));
return true;
}
代码示例来源:origin: Vazkii/Botania
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
this.xTile = compound.getInteger("xTile");
this.yTile = compound.getInteger("yTile");
this.zTile = compound.getInteger("zTile");
if (compound.hasKey("inTile", 8))
{
this.inTile = Block.getBlockFromName(compound.getString("inTile"));
}
else
{
this.inTile = Block.getBlockById(compound.getByte("inTile") & 255);
}
this.throwableShake = compound.getByte("shake") & 255;
this.inGround = compound.getByte("inGround") == 1;
this.thrower = null;
this.throwerName = compound.getString("ownerName");
if (this.throwerName != null && this.throwerName.isEmpty())
{
this.throwerName = null;
}
this.thrower = this.getThrower();
}
代码示例来源:origin: Vazkii/Botania
public static void init() {
redstoneRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.REDSTONE, 2), new ItemStack(Items.REDSTONE), 5000);
glowstoneRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.GLOWSTONE_DUST, 2), new ItemStack(Items.GLOWSTONE_DUST), 5000);
quartzRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.QUARTZ, 2), new ItemStack(Items.QUARTZ), 2500);
coalRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.COAL, 2), new ItemStack(Items.COAL), 2100);
snowballRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Items.SNOWBALL, 2), new ItemStack(Items.SNOWBALL), 200);
netherrackRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.NETHERRACK, 2), new ItemStack(Blocks.NETHERRACK), 200);
soulSandRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.SOUL_SAND, 2), new ItemStack(Blocks.SOUL_SAND), 1500);
gravelRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Block.getBlockFromName("gravel"), 2), new ItemStack(Block.getBlockFromName("gravel")), 720);
leavesRecipes = new ArrayList<>();
for(int i = 0; i < 4; i++)
leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.LEAVES, 2, i), new ItemStack(Blocks.LEAVES, 1, i), 2000));
for(int i = 0; i < 2; i++)
leavesRecipes.add(BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.LEAVES2, 2, i), new ItemStack(Blocks.LEAVES2, 1, i), 2000));
grassRecipe = BotaniaAPI.registerManaConjurationRecipe(new ItemStack(Blocks.TALLGRASS, 2, 1), new ItemStack(Blocks.TALLGRASS, 1, 1), 800);
}
代码示例来源:origin: Vazkii/Botania
redstoneToGlowstoneRecipes.add(BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Items.GLOWSTONE_DUST), new ItemStack(Items.REDSTONE), 300));
sandRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Block.getBlockFromName("sand")), new ItemStack(Blocks.COBBLESTONE), 50);
redSandRecipe = BotaniaAPI.registerManaAlchemyRecipe(new ItemStack(Block.getBlockFromName("sand"), 1, 1), new ItemStack(Blocks.HARDENED_CLAY), 50);
代码示例来源:origin: PrinceOfAmber/Cyclic
private void init() {
if (baked == null)
baked = Block.getBlockFromName(Const.MODRES + "peat_baked");
if (unbaked == null)
unbaked = Block.getBlockFromName(Const.MODRES + "peat_unbaked");
if (outer == null) {
outer = getShape();
List<BlockPos> waterShape = UtilShape.squareHorizontalHollow(this.pos, 6);
outer.addAll(waterShape);
}
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
public IBlockState getBlockState() {
if (isModded() || block == null) {
if (hasMeta) {
return Block.getBlockFromName(blockName).getStateFromMeta(blockMeta);
}
return Block.getBlockFromName(blockName).getDefaultState();
} else {
return block;
}
}
代码示例来源:origin: ldtteam/minecolonies
@Override
public void fromBytes(@NotNull final ByteBuf buf)
{
colonyId = buf.readInt();
block = Block.getBlockFromName(ByteBufUtils.readUTF8String(buf));
pos = BlockPosUtil.readFromByteBuf(buf);
type = MessageType.values()[buf.readInt()];
mode = MessageMode.values()[buf.readInt()];
dimension = buf.readInt();
}
代码示例来源:origin: CyclopsMC/EvilCraft
/**
* Get the inner blockState.
* @return The inner blockState.
*/
public IBlockState getInnerBlockState() {
if(blockName == null || blockName.isEmpty()) return Blocks.STONE.getDefaultState();
Block block = Block.getBlockFromName(blockName);
if (block == null) return Blocks.STONE.getDefaultState();
return block.getStateFromMeta(this.meta);
}
代码示例来源:origin: NanamiArihara/FoodCraft-Reloaded
public static IBlockQuery of(String blockName, boolean negated) throws BlockQueryParseException {
Block block = Block.getBlockFromName(blockName);
if (block == null) {
throw new BlockQueryParseException("No block called " + blockName);
} else {
IBlockQuery bm = new BlockQueryBlock(block);
return negated ? new BlockQueryNot(bm) : bm;
}
}
}
代码示例来源:origin: Vazkii/Botania
if (lens.hasTagCompound()) {
if (lens.getTagCompound().hasKey(TAG_BLOCK_NAME)) {
block = Block.getBlockFromName(ItemNBTHelper.getString(lens, TAG_BLOCK_NAME, ""));
} else if (lens.getTagCompound().hasKey(TAG_BLOCK)) {
代码示例来源:origin: CoFH/ThermalDynamics
@SuppressWarnings ("deprecation")
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
Block block = Block.getBlockFromName(tag.getString("block"));
if (block == null) {
state = Blocks.AIR.getDefaultState();
} else {
state = block.getStateFromMeta(tag.getByte("meta"));
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
tuneData.readFromNBT(tag.getCompoundTag("tuneData"));
tuneIndex = tag.getInteger("tuneIndex");
playerRange = tag.getInteger("range");
String id = tag.getString("block");
if (!id.isEmpty()) {
disguiseState = Block.getBlockFromName(id).getStateFromMeta(tag.getInteger("meta"));
}
}
内容来源于网络,如有侵权,请联系作者删除!