本文整理汇总了Java中net.minecraft.world.World.setBlockState方法的典型用法代码示例。如果您正苦于以下问题:Java World.setBlockState方法的具体用法?Java World.setBlockState怎么用?Java World.setBlockState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.setBlockState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryFlowInto
import net.minecraft.world.World; //导入方法依赖的package包/类
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level)
{
if (this.canFlowInto(worldIn, pos, state))
{
if (state.getBlock() != Blocks.air)
{
if (this.blockMaterial == Material.lava)
{
this.triggerMixEffects(worldIn, pos);
}
else
{
state.getBlock().dropBlockAsItem(worldIn, pos, state, 0);
}
}
worldIn.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(level)), 3);
}
}
示例2: onItemUse
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (side != EnumFacing.UP)
{
return false;
}
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
{
return false;
}
else if (worldIn.getBlockState(pos).getBlock() == this.soilBlockID && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
--stack.stackSize;
return true;
}
else
{
return false;
}
}
示例3: generateDispenserContents
import net.minecraft.world.World; //导入方法依赖的package包/类
protected boolean generateDispenserContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, int meta, List<WeightedRandomChestContent> listIn, int max)
{
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
if (boundingBoxIn.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getBlock() != Blocks.dispenser)
{
worldIn.setBlockState(blockpos, Blocks.dispenser.getStateFromMeta(this.getMetadataWithOffset(Blocks.dispenser, meta)), 2);
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if (tileentity instanceof TileEntityDispenser)
{
WeightedRandomChestContent.generateDispenserContents(rand, listIn, (TileEntityDispenser)tileentity, max);
}
return true;
}
else
{
return false;
}
}
示例4: generate
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
{
position = position.down();
}
for (int i = 0; i < 128; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
{
worldIn.setBlockState(blockpos, this.tallGrassState, 2);
}
}
return true;
}
示例5: onBlockActivated
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
state = state.cycleProperty(POWERED);
worldIn.setBlockState(pos, state, 3);
float f = ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F;
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, f);
worldIn.notifyNeighborsOfStateChange(pos, this);
EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
return true;
}
}
示例6: generateChestContents
import net.minecraft.world.World; //导入方法依赖的package包/类
protected boolean generateChestContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, List<WeightedRandomChestContent> listIn, int max)
{
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
if (boundingBoxIn.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.air)
{
int i = rand.nextBoolean() ? 1 : 0;
worldIn.setBlockState(blockpos, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, i)), 2);
EntityMinecartChest entityminecartchest = new EntityMinecartChest(worldIn, (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F));
WeightedRandomChestContent.generateChestContents(rand, listIn, entityminecartchest, max);
worldIn.spawnEntityInWorld(entityminecartchest);
return true;
}
else
{
return false;
}
}
示例7: rotateBlock
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
{
IBlockState state = world.getBlockState(pos);
for (IProperty prop : (java.util.Set<IProperty<?>>)state.getProperties().keySet())
{
if (prop.getName().equals("variant"))
{
world.setBlockState(pos, state.cycleProperty(prop));
return true;
}
}
return false;
}
示例8: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (this.isOn && !worldIn.isBlockPowered(pos))
{
worldIn.setBlockState(pos, Blocks.REDSTONE_LAMP.getDefaultState(), 2);
}
}
}
示例9: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
int i = ((Integer)state.getValue(AGE)).intValue();
if (i < 3 && rand.nextInt(10) == 0)
{
state = state.withProperty(AGE, Integer.valueOf(i + 1));
worldIn.setBlockState(pos, state, 2);
}
super.updateTick(worldIn, pos, state, rand);
}
示例10: onBlockActivated
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (((Boolean)state.getValue(HAS_RECORD)).booleanValue())
{
this.dropRecord(worldIn, pos, state);
state = state.withProperty(HAS_RECORD, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 2);
return true;
}
else
{
return false;
}
}
示例11: tryAndSpawn
import net.minecraft.world.World; //导入方法依赖的package包/类
private void tryAndSpawn(World w, MutableBlockPos p) {
int oy = p.getY();
for (int dy = -5; dy <= 5; dy++) {
p.setY(oy + dy);
if ((w.isAirBlock(p) || w.getBlockState(p).getBlock().isReplaceable(w, p)) && w.getBlockState(p.down()).getBlock() == Blocks.DIRT) {
w.setBlockState(p, this.getDefaultState().withProperty(placed, false), 3);
return;
}
}
}
示例12: onBlockPlacedBy
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFurnace)
{
((TileEntityFurnace)tileentity).setCustomInventoryName(stack.getDisplayName());
}
}
}
示例13: checkForMixing
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean checkForMixing(World worldIn, BlockPos pos, IBlockState state)
{
boolean flag = false;
for (EnumFacing enumfacing : EnumFacing.values())
{
if (enumfacing != EnumFacing.DOWN && (worldIn.getBlockState(pos.offset(enumfacing)).getMaterial().isLiquid() == true))
{
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() != this.getBlockState().getBlock())
{
flag = true;
break;
}
}
}
if (flag)
{
Integer integer = (Integer)state.getValue(LEVEL);
if (integer.intValue() == 0)
{
worldIn.setBlockState(pos, getBlockWhenSourceHit().getDefaultState(), 3);
return true;
}
if (integer.intValue() <= 4)
{
worldIn.setBlockState(pos, getBlockWhenOtherHit().getDefaultState(), 3);
return true;
}
}
return false;
}
示例14: onItemUse
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
ItemStack itemstack = stack.getHeldItem(pos);
if (stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack) && iblockstate.getBlock() == Blocks.END_PORTAL_FRAME && !((Boolean)iblockstate.getValue(BlockEndPortalFrame.EYE)).booleanValue())
{
if (playerIn.isRemote)
{
return EnumActionResult.SUCCESS;
}
else
{
playerIn.setBlockState(worldIn, iblockstate.withProperty(BlockEndPortalFrame.EYE, Boolean.valueOf(true)), 2);
playerIn.updateComparatorOutputLevel(worldIn, Blocks.END_PORTAL_FRAME);
itemstack.func_190918_g(1);
for (int i = 0; i < 16; ++i)
{
double d0 = (double)((float)worldIn.getX() + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);
double d1 = (double)((float)worldIn.getY() + 0.8125F);
double d2 = (double)((float)worldIn.getZ() + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);
double d3 = 0.0D;
double d4 = 0.0D;
double d5 = 0.0D;
playerIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
}
BlockPattern.PatternHelper blockpattern$patternhelper = BlockEndPortalFrame.getOrCreatePortalShape().match(playerIn, worldIn);
if (blockpattern$patternhelper != null)
{
BlockPos blockpos = blockpattern$patternhelper.getFrontTopLeft().add(-3, 0, -3);
for (int j = 0; j < 3; ++j)
{
for (int k = 0; k < 3; ++k)
{
playerIn.setBlockState(blockpos.add(j, 0, k), Blocks.END_PORTAL.getDefaultState(), 2);
}
}
}
return EnumActionResult.SUCCESS;
}
}
else
{
return EnumActionResult.FAIL;
}
}
示例15: onItemUse
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack itemstack = player.getHeldItem(hand);
if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack))
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
BlockPos blockpos = pos;
if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
{
blockpos = pos.offset(facing);
iblockstate = worldIn.getBlockState(blockpos);
block = iblockstate.getBlock();
}
if (block == this.block)
{
int i = iblockstate.getValue(BlockSnow.LAYERS);
if (i < 8)
{
IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, i + 1);
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos);
if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10))
{
SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player);
worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
if (player instanceof EntityPlayerMP)
{
CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
}
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
}
}
}
return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
else
{
return EnumActionResult.FAIL;
}
}