net.minecraft.block.Block.onBlockPlacedBy()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中net.minecraft.block.Block.onBlockPlacedBy()方法的一些代码示例,展示了Block.onBlockPlacedBy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.onBlockPlacedBy()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:onBlockPlacedBy

Block.onBlockPlacedBy介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

private boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
  if (!world.setBlockState(pos, newState, 3)) return false;
  IBlockState state = world.getBlockState(pos);
  if (state.getBlock() == ModBlocks.buriedPetals)
  {
    // setTileEntityNBT(world, player, pos, stack);
    ModBlocks.buriedPetals.onBlockPlacedBy(world, pos, state, player, stack);
  }
  return true;
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
 super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
  if(placer instanceof EntityPlayer)
  {
    Triggers.trigger(Triggers.PLACE_OUTDOOR_FURNITURE, (EntityPlayer) placer);
  }
  super.onBlockPlacedBy(world, pos, state, placer, stack);
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
  if(placer instanceof EntityPlayer)
  {
    Triggers.trigger(Triggers.PLACE_OUTDOOR_FURNITURE, (EntityPlayer) placer);
  }
  super.onBlockPlacedBy(world, pos, state, placer, stack);
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
  if(placer instanceof EntityPlayer)
  {
    Triggers.trigger(Triggers.PLACE_OUTDOOR_FURNITURE, (EntityPlayer) placer);
  }
  super.onBlockPlacedBy(world, pos, state, placer, stack);
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
 super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
 TileEntity tileentity = worldIn.getTileEntity(pos);
 if (tileentity instanceof TileEntityMBE21) { // prevent a crash if not the right type, or is null
  TileEntityMBE21 tileEntityMBE21 = (TileEntityMBE21)tileentity;
  // chose a random colour for the gem:
  Color [] colorChoices = {Color.BLUE, Color.CYAN, Color.YELLOW, Color.GREEN, Color.WHITE, Color.ORANGE, Color.RED};
  Random random = new Random();
  Color gemColor = colorChoices[random.nextInt(colorChoices.length)];
  tileEntityMBE21.setGemColour(gemColor);
 }
}

代码示例来源:origin: Vazkii/Botania

public boolean exchange(World world, EntityPlayer player, BlockPos pos, ItemStack stack, IBlockState state) {
  TileEntity tile = world.getTileEntity(pos);
  if(tile != null)
    return false;
  ItemStack placeStack = removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), false);
  if(!placeStack.isEmpty()) {
    IBlockState stateAt = world.getBlockState(pos);
    Block blockAt = stateAt.getBlock();
    if(!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
      if(!world.isRemote) {
        world.destroyBlock(pos, !player.capabilities.isCreativeMode);
        if(!player.capabilities.isCreativeMode) {
          removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), true);
        }
        world.setBlockState(pos, state, 1 | 2);
        state.getBlock().onBlockPlacedBy(world, pos, state, player, placeStack);
      }
      displayRemainderCounter(player, stack);
      return true;
    }
  }
  return false;
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
 super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
 TileEntity tileentity = worldIn.getTileEntity(pos);
 if (tileentity instanceof TileEntityData) { // prevent a crash if not the right type, or is null
  TileEntityData tileEntityData = (TileEntityData)tileentity;
  tileEntityData.setTicksLeftTillDisappear(TIMER_COUNTDOWN_TICKS);
 }
}

代码示例来源:origin: SleepyTrousers/EnderIO

private boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos,
  @Nonnull IBlockState newState) {
 if (!world.setBlockState(pos, newState, 3)) {
  return false;
 }
 IBlockState state = world.getBlockState(pos);
 if (state.getBlock() == newState.getBlock()) {
  state.getBlock().onBlockPlacedBy(world, pos, state, player, stack);
 }
 return true;
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
  if(placer instanceof EntityPlayer)
  {
    EntityPlayer player = (EntityPlayer) placer;
    Triggers.trigger(Triggers.PLACE_TABLE, player);
    Triggers.trigger(Triggers.PLACE_CHAIR_OR_TABLE, player);
  }
  super.onBlockPlacedBy(world, pos, state, placer, stack);
}

代码示例来源:origin: OpenMods/OpenModsLib

@Override
public void onBlockPlacedBy(World world, BlockPos blockPos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) {
  super.onBlockPlacedBy(world, blockPos, state, placer, stack);
  if (hasCapability(TileEntityCapability.PLACE_LISTENER)) {
    final TileEntity te = world.getTileEntity(blockPos);
    if (te instanceof IPlaceAwareTile)
      ((IPlaceAwareTile)te).onBlockPlacedBy(state, placer, stack);
  }
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
 super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
 TileEntity tileentity = worldIn.getTileEntity(pos);
 if (tileentity instanceof TileEntityRedstoneColouredLamp) { // prevent a crash if not the right type, or is null
  TileEntityRedstoneColouredLamp tileEntityRedstoneColouredLamp = (TileEntityRedstoneColouredLamp)tileentity;
  int rgbColour = calculateLampColour(worldIn, pos, state);
  tileEntityRedstoneColouredLamp.setRGBcolour(rgbColour);
 }
}

代码示例来源:origin: squeek502/VeganOption

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack itemStack)
{
  EnumFacing rotation = DirectionHelper.getDirectionFromYaw(placer);
  world.setBlockState(pos, state.withProperty(FACING, rotation));
  super.onBlockPlacedBy(world, pos, state, placer, itemStack);
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
@Nonnull
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
  super.onBlockPlacedBy(world, pos, state, placer, stack);
  TileEntity tile = world.getTileEntity(pos);
  if (tile instanceof LogisticsCraftingTableTileEntity) {
    ((LogisticsCraftingTableTileEntity) tile).placedBy(placer);
  }
  if (tile instanceof IRotationProvider) {
    ((IRotationProvider) tile).setFacing(placer.getHorizontalFacing().getOpposite());
  }
}

代码示例来源:origin: Chisel-Team/Chisel

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
  super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
  if (stack.hasDisplayName()) {
    TileEntity tileentity = worldIn.getTileEntity(pos);
    if (tileentity instanceof TileAutoChisel) {
      ((TileAutoChisel) tileentity).setCustomName(stack.getDisplayName());
    }
  }
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState)
  {
    if(!world.setBlockState(pos, newState, 11)) return false;

    IBlockState state = world.getBlockState(pos);
    if(state.getBlock() == FurnitureBlocks.CUP)
    {
      ItemBlock.setTileEntityNBT(world, player, pos, stack);
      FurnitureBlocks.CUP.onBlockPlacedBy(world, pos, state, player, stack);
    }

    return true;
  }
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, ItemStack stack) {
  super.onBlockPlacedBy(world, pos, state, entityliving, stack);
  if (world.isRemote) {
    return;
  }
  final IMachine machine = Machine.getMachine(world.getTileEntity(pos));
  if (machine == null) {
    return;
  }
  if (entityliving instanceof EntityPlayer) {
    machine.setOwner(((EntityPlayer) entityliving).getGameProfile());
  }
}

代码示例来源:origin: amadornes/MCMultiPart

public default void onPartPlacedBy(IPartInfo part, EntityLivingBase placer, ItemStack stack) {
  part.getState().getBlock().onBlockPlacedBy(part.getPartWorld(), part.getPartPos(), part.getState(), placer, stack);
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public void handlePlacement(World world, int turns, BlockPos pos, IStructureBuilder builder) {
  if (world.setBlockState(pos, state, 3)) {
    WorldTools.getTile(world, pos).ifPresent(t -> {
      tag.setInteger("x", pos.getX());
      tag.setInteger("y", pos.getY());
      tag.setInteger("z", pos.getZ());
      t.readFromNBT(tag);
    });
    BlockTools.notifyBlockUpdate(world, pos);
    state.getBlock().onBlockPlacedBy(world, pos, state, null, null);
  }
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
  super.onBlockPlacedBy(world, pos, state, placer, stack);
  if(!world.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey("EntityNBT")) {
    TileEntityPreservedBlock tile = Utils.getTileEntity(world, pos, TileEntityPreservedBlock.class);
    if (tile != null) {
      NBTTagCompound nbt = stack.getTagCompound().getCompoundTag("EntityNBT");
      tile.setEntityNBT(nbt);
      tile.rotation = (byte) (((MathHelper.floor((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3)) % 4);
    }
    world.notifyBlockUpdate(pos, state, state, 3);
  }
}

相关文章

Block类方法