예제 #1
0
  private void setDefaultDirection(World world, int x, int y, int z) {
    if (!DCsAppleMilk.noUseCupDirection) {
      TilePanHandle tileHandle = (TilePanHandle) world.getBlockTileEntity(x, y, z);

      if (!world.isRemote) {
        int var5 = world.getBlockId(x, y, z - 1);
        int var6 = world.getBlockId(x, y, z + 1);
        int var7 = world.getBlockId(x - 1, y, z);
        int var8 = world.getBlockId(x + 1, y, z);
        byte var9 = 0;

        if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) {
          var9 = 0;
        }

        if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) {
          var9 = 1;
        }

        if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) {
          var9 = 2;
        }

        if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) {
          var9 = 4;
        }

        tileHandle.setDirectionByte(var9);
      }
    }
  }
예제 #2
0
  public void onBlockPlacedBy(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityLivingBase par5EntityLivingBase,
      ItemStack par6ItemStack) {
    int playerFacing =
        MathHelper.floor_double((double) ((par5EntityLivingBase.rotationYaw * 4F) / 360F) + 0.5D)
            & 3;

    if (!DCsAppleMilk.noUseCupDirection) {
      byte facing = 0;
      if (playerFacing == 0) {
        facing = 0;
      }
      if (playerFacing == 1) {
        facing = 1;
      }
      if (playerFacing == 2) {
        facing = 2;
      }
      if (playerFacing == 3) {
        facing = 4;
      }

      TileEntity tileEntity = par1World.getBlockTileEntity(par2, par3, par4);
      if (tileEntity != null && tileEntity instanceof TilePanHandle) {
        ((TilePanHandle) tileEntity).setDirectionByte(facing);
        // System.out.println("[AppleMilk]Now fasing " + facing);
        par1World.markBlockForRenderUpdate(par2, par3, par4);
      }
    }
  }
예제 #3
0
  private void setPanMeta(
      World world, int x, int y, int z, EntityPlayer player, ItemStack itemstack, int setMeta) {
    TilePanHandle tile = (TilePanHandle) world.getBlockTileEntity(x, y, z);
    byte dir = tile.getDirectionByte();

    if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0) {
      player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null);
    }

    if (!world.isRemote && itemstack.getItemDamage() < 4) {
      world.setBlock(x, y, z, DCsAppleMilk.filledPan.blockID, setMeta, 3);
      TilePanHandle tile2 = (TilePanHandle) world.getBlockTileEntity(x, y, z);
      tile2.setDirectionByte(dir);
    } else if (!world.isRemote && itemstack.getItemDamage() >= 4 && itemstack.getItemDamage() < 8) {
      world.setBlock(x, y, z, DCsAppleMilk.filledPan2.blockID, setMeta, 3);
      TilePanHandle tile2 = (TilePanHandle) world.getBlockTileEntity(x, y, z);
      tile2.setDirectionByte(dir);
    } else if (!world.isRemote && itemstack.getItemDamage() == 8) {
      world.setBlock(x, y, z, DCsAppleMilk.filledChocoPan.blockID);
      TileChocoPan tile2 = (TileChocoPan) world.getBlockTileEntity(x, y, z);
      tile2.setRemainByte((byte) 11);
    }

    world.playSoundAtEntity(player, "random.pop", 0.4F, 1.8F);
  }